Page 2 of 2

Posted: Mon May 01, 2006 11:36 am
by EricS
So you can ping IP's external to your local network but you can't ping local network addresses?

Sounds like a routing problem.

Posted: Mon May 01, 2006 1:07 pm
by Red Blaze
I'm trying a different approach now.

Code: Select all

$ip = $row_records['IP'];
		if($ip == "Not Available"){
		echo 'Offline';
		}else{   
 		$status = exec("ping -n 1 $ip", $output);
		$arr = explode(", ", $status);
			if($arr[1] == "Received = 0"){
			echo "Offline";
			}else{
			echo "Online";
			}
		}
when I echo out the exec command, I rather get this:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
or
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
So I did an array. If it "Recieved" nothing, it's Offline. However, it STILL displays 'Online'. My head is hurting. ~.~

There are two devices that we know are offline, but it still displays it as online.
We echoed out a local/internal IP that we know works only inside this building, and it works.

Posted: Mon May 01, 2006 1:19 pm
by EricS

Code: Select all

$ip = $row_records['IP']; 
if($ip == "Not Available"){ 
    echo 'Offline'; 
}else{    
    $status = exec("ping -n 1 $ip", $output); 
    if(strpos($status, "100% loss") === false) 
        echo "Online"; 
    else 
        echo "Offline"; 
}
Try this.

Posted: Mon May 01, 2006 2:30 pm
by Red Blaze
It works now :D
Thank you for your patience, Eric. I really appreciate it.

~RB

Posted: Tue May 02, 2006 1:43 am
by Ollie Saunders
So I did an array. If it "Recieved" nothing, it's Offline. However, it STILL displays 'Online'. My head is hurting
That was because you were making Received = 0 and it could well receive 1. Am I right?

Oh and you might want to call flush() after each ping so that the web server doesn't buffer the results up for ages.