Reputation: 153
I have multiple php scripts to ping each of our locations, and I'm trying to list all results on one page.
Here's the ping script:
<?php
$host = "10.10.10.10"; //IP adress to ping
$loc = ("HQ"); //Name of location
$output = array();
echo("<b>$loc</b> <i>(IP: $host)</i> is ");
exec("ping -n 1 $host 2>&1", $output);
//print_r($output);
//you can use print_r($output) to view the output result
if (count($output) > 7) {
$output = null;
die ("<font color='green'><b>up</b></font>");
}
else {
$output = null;
die ("<font color='red'><b>down</b></font>");
}
?>
So, I have many php files with this script, where the only difference is host
and loc
.
I've tried to include each file in a new php file using include
like this:
<?php
include "file1.php";
include "file2.php";
include "file3.php";
...and so on...
?>
But this only outputs the result of the first file.
How can I do this in any other way?
Thanks!
Upvotes: 1
Views: 85