Some earlier versions of pfSense do not return substatus
This commit is contained in:
parent
697ae5f277
commit
c8103f175d
@ -2,65 +2,65 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once("config.inc");
|
require_once("config.inc");
|
||||||
require_once("gwlb.inc");
|
require_once("gwlb.inc");
|
||||||
require_once("interfaces.inc");
|
|
||||||
|
|
||||||
$host = gethostname();
|
$host = gethostname();
|
||||||
$source = "pfconfig";
|
$source = "pfconfig";
|
||||||
|
|
||||||
$iflist = get_configured_interface_with_descr(true);
|
$gw_array = return_gateways_array();
|
||||||
foreach ($iflist as $ifname => $friendly) {
|
$gw_statuses = return_gateways_status(true);
|
||||||
$ifinfo = get_interface_info($ifname);
|
|
||||||
$ifstatus = $ifinfo['status'];
|
|
||||||
$ifconf = $config['interfaces'][$ifname];
|
|
||||||
$ip4addr = get_interface_ip($ifname);
|
|
||||||
$ip4subnet = get_interface_subnet($ifname);
|
|
||||||
$ip6addr = get_interface_ipv6($ifname);
|
|
||||||
$ip6subnet = get_interface_subnetv6($ifname);
|
|
||||||
$realif = get_real_interface($ifname);
|
|
||||||
$mac = get_interface_mac($realif);
|
|
||||||
|
|
||||||
if (!isset($ip4addr)){
|
foreach ($gw_array as $gw => $gateway) {
|
||||||
$ip4addr = "Unassigned";
|
|
||||||
}
|
$name = $gw_statuses[$gw]["name"];
|
||||||
if (!isset($ip4subnet)){
|
$monitor = $gw_statuses[$gw]["monitorip"];
|
||||||
$ip4subnet = "Unassigned";
|
$source = $gw_statuses[$gw]["srcip"];
|
||||||
}
|
$delay = $gw_statuses[$gw]["delay"];
|
||||||
if (!isset($ip6addr)){
|
$stddev = $gw_statuses[$gw]["stddev"];
|
||||||
$ip6addr = "Unassigned";
|
$loss = $gw_statuses[$gw]["loss"];
|
||||||
}
|
$status = $gw_statuses[$gw]["status"];
|
||||||
if (!isset($ip6subnet)){
|
$substatus = $gw_statuses[$gw]["substatus"];
|
||||||
$ip6subnet = "Unassigned";
|
|
||||||
}
|
$interface = $gateway["interface"];
|
||||||
if (!isset($mac)){
|
$friendlyname = $gateway["friendlyiface"]; # This is not the friendly interface name so I'm not using it
|
||||||
$mac = "Unavailable";
|
$friendlyifdescr = $gateway["friendlyifdescr"];
|
||||||
}
|
$gwdescr = $gateway["descr"];
|
||||||
if (strtolower($ifstatus) == "up"){
|
$defaultgw = $gateway['isdefaultgw'];
|
||||||
$ifstatus = 1;
|
|
||||||
}
|
if (isset($gateway['isdefaultgw'])) {
|
||||||
if (strtolower($ifstatus) == "active"){
|
$defaultgw = "1";
|
||||||
$ifstatus = 1;
|
} else {
|
||||||
}
|
$defaultgw = "0";
|
||||||
if (strtolower($ifstatus) == "no carrier"){
|
|
||||||
$ifstatus = 0;
|
|
||||||
}
|
|
||||||
if (strtolower($ifstatus) == "down"){
|
|
||||||
$ifstatus = 0;
|
|
||||||
}
|
|
||||||
if (!isset($ifstatus)){
|
|
||||||
$ifstatus = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("interface,host=%s,name=%s,ip4_address=%s,ip4_subnet=%s,ip6_address=%s,ip6_subnet=%s,mac_address=%s,friendlyname=%s,source=%s status=%s\n",
|
if ($gw_statuses[$gw]) {
|
||||||
|
if (isset($gateway['monitor_disable'])) {
|
||||||
|
$monitor = "Unmonitored";
|
||||||
|
$delay = "Pending";
|
||||||
|
$stdev = "Pending";
|
||||||
|
$loss = "Pending";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Some earlier versions of pfSense do not return substatus
|
||||||
|
if (isset($gw_statuses[$gw]["substatus"])) {
|
||||||
|
$substatus = $gw_statuses[$gw]["substatus"];
|
||||||
|
} else {
|
||||||
|
$substatus = "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("gateways,host=%s,interface=%s monitor=\"%s\",source=\"%s\",defaultgw=%s,gwdescr=\"%s\",delay=%s,stddev=%s,loss=%s,status=\"%s\",substatus=\"%s\"\n",
|
||||||
$host,
|
$host,
|
||||||
$realif,
|
$interface,
|
||||||
$ip4addr,
|
$monitor,
|
||||||
$ip4subnet,
|
|
||||||
$ip6addr,
|
|
||||||
$ip6subnet,
|
|
||||||
$mac,
|
|
||||||
$friendly,
|
|
||||||
$source,
|
$source,
|
||||||
$ifstatus
|
$defaultgw,
|
||||||
|
$gwdescr,
|
||||||
|
floatval($delay),
|
||||||
|
floatval($stddev),
|
||||||
|
floatval($loss),
|
||||||
|
$status,
|
||||||
|
$substatus
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user