Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Ping script gone wrong

$
0
0

Hi guys,

 

wacking together a ping script with alert however, i cant seem to get it to work :( no matter what the IP is it says UP!

<?
$hosts = array( 
array ( "hostdescription" => "B01","hostaddress" => "REALIPHIDDEN" ), 
array ( "hostdescription" => "B02", "hostaddress" => "REALIPHIDDEN" ) );  
$toemail = "email@mail.com"; 
$fromemail = "ALERTER@mail.com";  
$pingcount = 1;  
foreach ($hosts as $host){  
$hostdescription = $host["hostdescription"];  
$hostaddress = $host["hostaddress"];  
exec("ping -c $pingcount -w $pingcount $hostaddress", $pingoutput, $Spingstatuscode);  
if($pingstatuscode == 0){ 
echo("$hostdescription ($hostaddress) is Up <BR>"); }else{ 
echo("$hostdescription ($hostaddress) is Down <BR>"); 
 
mail($toemail,"Host Down","$hostdescription ($hostaddress) is Down!","From: $fromemail"); 
} }
?>

Can a second set of eyes see where im going wrong?

 

Thanks,

B-Man


Viewing all articles
Browse latest Browse all 13200

Trending Articles