File: //ibin/chads
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html><head><title>TITLE HERE</titel></head>\n";
print "<body bgcolor=ffffff text=000000>\n";
$good = "http://to.good.gif"; $bad = "http://to.bad.gif";
open(IPS,"./ips.txt"); @ips = <IPS>; close(IPS);
foreach (@ips) {
chomp; ($ip, $domain) = split(/\|/,$_);
$status = &check($ip); print "$domain - $status<br>\n";
}
sub check {
print "$_[0]"; $ok = '';
open(PING,"ping -c 1 $_[0] |");
@result = <PING>; close(PING);
foreach (@result) { if($_ =~ /0\% packet loss/) { $ok = '1'; } }
if($ok == 1) { return("<img $good>"); } else { return("<img $bad>"); }
}