From 2f31062b25b6d7cd531755745fb371e344743aeb Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 7 May 2013 17:02:02 +0000 Subject: [PATCH] 2013-05-07 Ramon Novoa * lib/PandoraFMS/Tools.pm: Added a function to resolve hostnames. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8111 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 4 ++++ pandora_server/lib/PandoraFMS/Tools.pm | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index fef54809a5..4563866630 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,7 @@ +2013-05-07 Ramon Novoa + + * lib/PandoraFMS/Tools.pm: Added a function to resolve hostnames. + 2013-05-07 Ramon Novoa * lib/PandoraFMS/DB.pm, diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index c709fcb761..ca5ac38a64 100644 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -24,6 +24,7 @@ use POSIX; use PandoraFMS::Sendmail; use HTML::Entities; use Encode; +use Socket qw(inet_ntoa inet_aton); # New in 3.2. Used to sendmail internally, without external scripts # use Module::Loaded; @@ -65,6 +66,7 @@ our @EXPORT = qw( md5_init pandora_ping pandora_ping_latency + resolve_hostname ticks_totime safe_input safe_output @@ -1163,6 +1165,15 @@ sub cron_get_closest_in_range ($$) { return $target; } +############################################################################### +# Attempt to resolve the given hostname. +############################################################################### +sub resolve_hostname ($) { + my ($hostname) = @_; + + return inet_ntoa(inet_aton($hostname)); +} + # End of function declaration # End of defined Code