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"];
|
||||
$loss = $gw_statuses[$gw]["loss"];
|
||||
$status = $gw_statuses[$gw]["status"];
|
||||
$status_code;
|
||||
$substatus;
|
||||
|
||||
$interface = $gateway["interface"];
|
||||
@ -122,6 +123,11 @@ foreach ($gw_array as $gw => $gateway) {
|
||||
}
|
||||
if (!isset($status)) {
|
||||
$status = "Unavailable";
|
||||
$status_code = "2";
|
||||
} elseif ($status == "online") {
|
||||
$status_code = "0";
|
||||
} elseif ($status == "down") {
|
||||
$status_code = "1";
|
||||
}
|
||||
if (!isset($interface)) {
|
||||
$interface = "Unassigned";
|
||||
@ -154,7 +160,7 @@ foreach ($gw_array as $gw => $gateway) {
|
||||
}
|
||||
|
||||
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,
|
||||
$interface,
|
||||
$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($loss),
|
||||
$status,
|
||||
$status_code,
|
||||
$substatus
|
||||
);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user