<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># 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, "&gt;&gt; C:/temp/$host.log") || file "C:\temp\$host.log could'nt be created\n";


######## Loop for ping

#### 


for  ($i=0; $i&lt;$count;$i++) 

{

#	$exit=system("ping $host &gt; nul");


$p = Net::Ping-&gt;new("icmp");

if ($p-&gt; ping($host,$timeout)) {


		$sum+=100;
		$sum_red+=0;
		}

	else {

		$sum+=0;
		$sum_red+=100;
        	}



	sleep $duration;

$p-&gt;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;


</pre></body></html>