I'm trying to ping from within the _View.php file. I have 2 columns (IP1 , IP2) I want to be able to ping IP1 and IP2 and show CONNECTED or DISCONNECTED based on the results. I'm attempting the following code:
global $data;
if ($data["IP"])
$value = $data["IP"];
print_r ($data["IP"]);
function ping($host) {
exec(sprintf('ping -n 1 %s', escapeshellarg($host)), $res, $rval);
return $rval === 0;
}
$hosts_to_ping = array($data["IP"]);
foreach ($hosts_to_ping as $host);
$up = ping($host);
$value = $data["IP"].", ". $up ? 'Connected' : 'Disconnected';
Note currently I am just testing and trying to ping one of the IPs right now. I'm trying to set this up so that when I check inventory I'll know which items are online and which are offline quickly. This is setup as a "Custom View as:" where I think it belongs. No matter what IP I put into the database it will always report Connected. Which makes me assume somehow it's not passing the variable of the IP on the _view page. Any help would be greatly apprecaited, I've been slamming my head into a wall over this.
Thanks
EDIT: The Print_r is obvioustly useless I was just testing to see if the variable was getting passed at all, which it seems to be.