diff options
author | Ermal <eri@pfsense.org> | 2010-09-09 21:25:49 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2010-09-09 21:25:49 +0000 |
commit | 68f291ffe2e8e6e5d9470076365fd1127e7f3655 (patch) | |
tree | 307627a01569bddb17905ee3b9aced0a372fccc9 /usr | |
parent | 3d471a14d42f9a17b06eeac2708c29f959ca98d8 (diff) | |
download | pfsense-68f291ffe2e8e6e5d9470076365fd1127e7f3655.zip pfsense-68f291ffe2e8e6e5d9470076365fd1127e7f3655.tar.gz |
Ticket #876. Show all gateways even though apinger is not monitoring them, for various reasons, this removes user confusion in the status pages.
Diffstat (limited to 'usr')
-rw-r--r-- | usr/local/www/includes/functions.inc.php | 22 | ||||
-rwxr-xr-x | usr/local/www/status_gateways.php | 48 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/gateways.widget.php | 60 |
3 files changed, 78 insertions, 52 deletions
diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index 677c2fd..8eff06a 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -24,19 +24,22 @@ function get_stats() { } function get_gatewaystats() { + $a_gateways = return_gateways_array(); $gateways_status = array(); - $gateways_status = return_gateways_status(); + $gateways_status = return_gateways_status(true); $data = ""; $isfirst = true; - foreach($gateways_status as $gw) { + foreach($a_gateways as $gname => $gw) { if(!$isfirst) $data .= ","; $isfirst = false; $data .= $gw['name'] . ","; - $data .= lookup_gateway_ip_by_name($gw['name']) . ","; - $data .= $gw['delay'] . ","; - $data .= $gw['loss'] . ","; - switch(strtolower($gw['status'])) { + $data .= lookup_gateway_ip_by_name($gname) . ","; + if ($gateways_status[$gname]) { + $gws = $gateways_status[$gname]; + $data .= $gws['delay'] . ","; + $data .= $gws['loss'] . ","; + switch(strtolower($gws['status'])) { case "none": $online = "Online"; $bgcolor = "lightgreen"; @@ -55,6 +58,11 @@ function get_gatewaystats() { break; default: $online = "Gathering data"; + break; + } + } else { + $online = "Unknown"; + $bgcolor = "lightgray"; } $data .= "<table><tr><td bgcolor=\"$bgcolor\" > $online </td></td></tr></table>"; } @@ -257,4 +265,4 @@ function get_interfacestatus() { return $data; } -?>
\ No newline at end of file +?> diff --git a/usr/local/www/status_gateways.php b/usr/local/www/status_gateways.php index eac1b2f..4faef8f 100755 --- a/usr/local/www/status_gateways.php +++ b/usr/local/www/status_gateways.php @@ -43,7 +43,7 @@ require("guiconfig.inc"); $a_gateways = return_gateways_array(); $gateways_status = array(); -$gateways_status = return_gateways_status(); +$gateways_status = return_gateways_status(true); $now = time(); $year = date("Y"); @@ -74,34 +74,44 @@ include("head.inc"); <td width="10%" class="listhdrr"><?=gettext("Monitor"); ?></td> <td width="30%" class="listhdrr"><?=gettext("Status"); ?></td> <td width="30%" class="listhdr"><?=gettext("Description"); ?></td> - </tr> - <?php foreach ($gateways_status as $target => $gateway) { + </tr> + <?php foreach ($a_gateways as $gname => $gateway) { ?> <tr> <td class="listlr"> <?=$gateway['name'];?> </td> <td class="listr" align="center" > - <?php echo lookup_gateway_ip_by_name($gateway['name']);?> + <?php echo lookup_gateway_ip_by_name($gname);?> </td> <td class="listr" align="center" > - <?=$target;?> + <?php if ($gateways_status[$gname]) + echo $gateways_status[$gname]['monitorip']; + else + echo $gateway['monitorip']; + ?> </td> <td class="listr" > <table border="0" cellpadding="0" cellspacing="2"> <?php - if (stristr($gateway['status'], "down")) { - $online = gettext("Offline"); - $bgcolor = "lightcoral"; - } elseif (stristr($gateway['status'], "loss")) { - $online = gettext("Warning, Packetloss"); - $bgcolor = "khaki"; - } elseif (stristr($gateway['status'], "delay")) { - $online = gettext("Warning, Latency"); - $bgcolor = "khaki"; - } elseif ($gateway['status'] == "none") { - $online = gettext("Online"); - $bgcolor = "lightgreen"; + if ($gateways_status[$gname]) { + $status = $gateways_status[$gname]; + if (stristr($status['status'], "down")) { + $online = gettext("Offline"); + $bgcolor = "lightcoral"; + } elseif (stristr($status['status'], "loss")) { + $online = gettext("Warning, Packetloss"); + $bgcolor = "khaki"; + } elseif (stristr($status['status'], "delay")) { + $online = gettext("Warning, Latency"); + $bgcolor = "khaki"; + } elseif ($status['status'] == "none") { + $online = gettext("Online"); + $bgcolor = "lightgreen"; + } + } else { + $online = gettext("Unknown"); + $bgcolor = "lightgray"; } echo "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>"; $lastchange = $gateway['lastcheck']; @@ -111,14 +121,12 @@ include("head.inc"); array_shift($lastchange); $lastchange = implode(" ", $lastchange); printf(gettext("Last check %s"), $lastchange); - } else { - echo gettext("Gathering data"); } echo "</td></tr>"; ?> </table> </td> - <td class="listbg"> <?=$a_gateways[$gateway['name']]['descr']; ?></td> + <td class="listbg"> <?=$gateway['descr']; ?></td> </tr> <?php } ?> </table> diff --git a/usr/local/www/widgets/widgets/gateways.widget.php b/usr/local/www/widgets/widgets/gateways.widget.php index 07b2397..bd643fb 100644 --- a/usr/local/www/widgets/widgets/gateways.widget.php +++ b/usr/local/www/widgets/widgets/gateways.widget.php @@ -30,8 +30,9 @@ require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("functions.inc"); +$a_gateways = return_gateways_array(); $gateways_status = array(); -$gateways_status = return_gateways_status(); +$gateways_status = return_gateways_status(true); $counter = 1; @@ -44,50 +45,59 @@ $counter = 1; <td width="10%" class="listhdrr">Loss</td> <td width="30%" class="listhdrr">Status</td> </tr> - <?php foreach ($gateways_status as $target => $gateway) { ?> - <?php - $monitor = $target; - if(empty($monitor)) { - $monitor = $gateway['gateway']; - } - ?> + <?php foreach ($a_gateways as $gname => $gateway) { ?> <tr> <td class="listlr" id="gateway<?= $counter; ?>"> <?=$gateway['name'];?> <?php $counter++; ?> </td> <td class="listr" align="center" id="gateway<?= $counter; ?>"> - <?php echo lookup_gateway_ip_by_name($gateway['name']);?> + <?php if (is_ipaddr($gateway['gateway'])) + echo $gateway['gateway']; + else + echo get_interface_gateway($gateway['friendlyiface']); + ?> <?php $counter++; ?> </td> <td class="listr" align="center" id="gateway<?= $counter; ?>"> - <?=$gateway['delay'];?> - <?php $counter++; ?> - </td> + <?php if ($gateways_status[$gname]) + echo $gateways_status[$gname]['delay']; + else + echo "Unknown"; + ?> + <?php $counter++; ?> + </td> <td class="listr" align="center" id="gateway<?= $counter; ?>"> - <?=$gateway['loss'];?> - <?php $counter++; ?> - </td> + <?php if ($gateways_status[$gname]) + echo $gateways_status[$gname]['loss']; + else + echo "Unknown"; + ?> + <?php $counter++; ?> + </td> <td class="listr" id="gateway<?=$counter?>" > <table border="0" cellpadding="0" cellspacing="2"> - <?php - if (stristr($gateway['status'], "down")) { + <?php if ($gateways_status[$gname]) { + if (stristr($gateways_status[$gname]['status'], "down")) { $online = "Offline"; $bgcolor = "lightcoral"; - } elseif (stristr($gateway['status'], "loss")) { + } elseif (stristr($gateways_status[$gname]['status'], "loss")) { $online = "Warning, Packetloss"; $bgcolor = "khaki"; - } elseif (stristr($gateway['status'], "delay")) { + } elseif (stristr($gateways_status[$gname]['status'], "delay")) { $online = "Warning, Latency"; $bgcolor = "khaki"; - } elseif ($gateway['status'] == "none") { + } elseif ($gateways_status[$gname]['status'] == "none") { $online = "Online"; $bgcolor = "lightgreen"; - } else - $online = "Gathering data"; - echo "<tr><td bgcolor=\"$bgcolor\" > $online </td>"; - $counter++; - ?> + } + } else { + $online = "Unknown"; + $bgcolor = "lightgray"; + } + echo "<tr><td bgcolor=\"$bgcolor\" > $online </td>"; + $counter++; + ?> </table> </td> </tr> |