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