Added a bit more logic into the script so systems with no IP or MAC can still be inserted into influx
This commit is contained in:
parent
ff885cb4d0
commit
2863f95ece
@ -19,17 +19,28 @@ foreach ($iflist as $ifname => $friendly) {
|
|||||||
$realif = get_real_interface($ifname);
|
$realif = get_real_interface($ifname);
|
||||||
$mac = get_interface_mac($realif);
|
$mac = get_interface_mac($realif);
|
||||||
|
|
||||||
|
if (!isset($ipaddr)){
|
||||||
|
$ipaddr = 'Unassigned'
|
||||||
|
}
|
||||||
|
if (!isset($mac)){
|
||||||
|
$mac = 'Unavailable'
|
||||||
|
}
|
||||||
if (strtolower($ifstatus) == "up"){
|
if (strtolower($ifstatus) == "up"){
|
||||||
$ifstatus = 1;
|
$ifstatus = 1;
|
||||||
}
|
}
|
||||||
|
if (strtolower($ifstatus) == "active"){
|
||||||
|
$ifstatus = 1;
|
||||||
|
}
|
||||||
if (strtolower($ifstatus) == "no carrier"){
|
if (strtolower($ifstatus) == "no carrier"){
|
||||||
$ifstatus = 0;
|
$ifstatus = 0;
|
||||||
}
|
}
|
||||||
|
if (strtolower($ifstatus) == "down"){
|
||||||
|
$ifstatus = 0;
|
||||||
|
}
|
||||||
if (!isset($ifstatus)){
|
if (!isset($ifstatus)){
|
||||||
$ifstatus = "Unknown";
|
$ifstatus = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($ipaddr)) {
|
|
||||||
printf("interface,host=%s,name=%s,ip_address=%s,mac_address=%s,friendlyname=%s,source=%s status=%s\n",
|
printf("interface,host=%s,name=%s,ip_address=%s,mac_address=%s,friendlyname=%s,source=%s status=%s\n",
|
||||||
$host,
|
$host,
|
||||||
$realif,
|
$realif,
|
||||||
@ -39,6 +50,5 @@ foreach ($iflist as $ifname => $friendly) {
|
|||||||
$source,
|
$source,
|
||||||
$ifstatus
|
$ifstatus
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
x
Reference in New Issue
Block a user