Advertisement
ajcorrea

mrtg/ping.pl

Aug 4th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.41 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Net::Ping;
  5. use Time::HiRes;
  6.  
  7. my $host = shift;
  8.  
  9. my $p = Net::Ping->new("icmp");
  10. $p->hires();
  11. my ($ret, $duration, $ip) = $p->ping($host, 5.5);
  12. if ( $ret ) {
  13.         printf "%.0f\n", 1000 * $duration;
  14. } else {
  15.         print "0\n";
  16. }
  17.  
  18. # Value "in" for mrtg
  19. print "0\n";
  20. # Value "out" for mrtg
  21. print "\n";
  22. # A comment for mrt
  23. print "$host\n";
  24. $p->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement