Jump to content

Ping script gone wrong


Boxerman

Recommended Posts

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 protected]"; 
$fromemail = "[email protected]";  
$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

Link to comment
https://forums.phpfreaks.com/topic/280835-ping-script-gone-wrong/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.