Added status_code to output to allow for more flexible formatting inside grafana, since it can only set thresholds by numeric values. New status codes are 0=online, 1=down, 2=unavailable.
This commit is contained in:
parent
4b832342d9
commit
438ea5d860
@ -97,6 +97,7 @@ foreach ($gw_array as $gw => $gateway) {
|
|||||||
$stddev = $gw_statuses[$gw]["stddev"];
|
$stddev = $gw_statuses[$gw]["stddev"];
|
||||||
$loss = $gw_statuses[$gw]["loss"];
|
$loss = $gw_statuses[$gw]["loss"];
|
||||||
$status = $gw_statuses[$gw]["status"];
|
$status = $gw_statuses[$gw]["status"];
|
||||||
|
$status_code;
|
||||||
$substatus;
|
$substatus;
|
||||||
|
|
||||||
$interface = $gateway["interface"];
|
$interface = $gateway["interface"];
|
||||||
@ -122,6 +123,11 @@ foreach ($gw_array as $gw => $gateway) {
|
|||||||
}
|
}
|
||||||
if (!isset($status)) {
|
if (!isset($status)) {
|
||||||
$status = "Unavailable";
|
$status = "Unavailable";
|
||||||
|
$status_code = "2";
|
||||||
|
} elseif ($status == "online") {
|
||||||
|
$status_code = "0";
|
||||||
|
} elseif ($status == "down") {
|
||||||
|
$status_code = "1";
|
||||||
}
|
}
|
||||||
if (!isset($interface)) {
|
if (!isset($interface)) {
|
||||||
$interface = "Unassigned";
|
$interface = "Unassigned";
|
||||||
@ -154,7 +160,7 @@ foreach ($gw_array as $gw => $gateway) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf(
|
printf(
|
||||||
"gateways,host=%s,interface=%s,gateway_name=%s monitor=\"%s\",source=\"%s\",defaultgw=%s,gwdescr=\"%s\",delay=%s,stddev=%s,loss=%s,status=\"%s\",substatus=\"%s\"\n",
|
"gateways,host=%s,interface=%s,gateway_name=%s monitor=\"%s\",source=\"%s\",defaultgw=%s,gwdescr=\"%s\",delay=%s,stddev=%s,loss=%s,status=\"%s\",status_code=%d,substatus=\"%s\"\n",
|
||||||
$host,
|
$host,
|
||||||
$interface,
|
$interface,
|
||||||
$name, //name is required as it is possible to have 2 gateways on 1 interface. i.e. WAN_DHCP and WAN_DHCP6
|
$name, //name is required as it is possible to have 2 gateways on 1 interface. i.e. WAN_DHCP and WAN_DHCP6
|
||||||
@ -166,6 +172,7 @@ foreach ($gw_array as $gw => $gateway) {
|
|||||||
floatval($stddev),
|
floatval($stddev),
|
||||||
floatval($loss),
|
floatval($loss),
|
||||||
$status,
|
$status,
|
||||||
|
$status_code,
|
||||||
$substatus
|
$substatus
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user