# Availability Report-Script fuer MRTG # Developer: Dieter.Heupke@dhs-gmbh.de # For comments and questions please contact Stefan.Heins@seb.de # Version 0.3 (05/09/02) # ATTENTION: This program is still in draft state! ######## Loading of some modules #### use Net::SNMP; use Net::Ping; ######## Definition of variables #### $host=$ARGV[0]; # 1. Call Parameter $count=2; # Loops ($count * $duration ~ 5min) $community="public"; # default! $duration=0; # in Seconds $timeout=2; # in Seconds open ( LOGFILE, ">> C:/temp/$host.log") || file "C:\temp\$host.log could'nt be created\n"; ######## Loop for ping #### for ($i=0; $i<$count;$i++) { # $exit=system("ping $host > nul"); $p = Net::Ping->new("icmp"); if ($p-> ping($host,$timeout)) { $sum+=100; $sum_red+=0; } else { $sum+=0; $sum_red+=100; } sleep $duration; $p->close(); } ######## Values for MRTG ######## $zeit=localtime(); print LOGFILE "$zeit@"; ######## (1) Availability with ICMP in % #### $percent=$sum/$count; print "$percent\n"; print LOGFILE "$percent@"; ######## (2) Availability with ICMP in % #### $percent_red=$sum_red/$count; print "$percent_red\n"; print LOGFILE "$percent_red@"; print LOGFILE "\n"; exit 0;