Improved interface detection

master
Riccardo Bicelli 4 years ago
parent 39354be48e
commit 8eab63ee74
  1. 44
      pfsense_zbx.php

@ -56,50 +56,25 @@ function pfz_test(){
}
function pfz_get_if_name($hwif, $ifdescrs=""){
if !(is_array($if_descrs))
$ifdescrs = get_configured_interface_with_descr(true);
foreach ($ifdescrs as $ifdescr => $ifname){
$ifinfo = get_interface_info($ifdescr);
if($ifinfo["hwif"]==$hwif){
return $ifname;
}
}
return null;
}
// Interface Discovery
function pfz_interface_discovery_legacy() {
// Improved performance, but need testing
function pfz_interface_discovery() {
$ifdescrs = get_configured_interface_with_descr(true);
$ifaces = get_interface_arr();
$json_string = '{"data":[';
foreach ($ifaces as $iface) {
$json_string .= '{"{#IFNAME}":"' . $iface . '"';
$descr = pfz_get_if_name($iface);
if($descr === null){ $descr = $iface; }
$json_string .= ',"{#IFDESCR}":"' . $descr . '"';
$json_string .= '},';
}
$json_string = rtrim($json_string,",");
$json_string .= "]}";
echo $json_string;
foreach ($ifdescrs as $ifdescr => $ifname){
$ifinfo = get_interface_info($ifdescr);
$ifaces[$ifname] = $ifinfo;
}
function pfz_interface_discovery() {
foreach ($ifaces as $iface=>$ifdescr) {
$json_string .= '{"{#IFNAME}":"' . $iface . '"';
$ifdescrs = get_configured_interface_with_descr(true);
$descr = $ifdescr;
if($descr === null){ $descr = $iface; }
foreach ($ifdescr as $descr=>$iface) {
$json_string .= '{"{#IFNAME}":"' . $iface["hwif"] . '"';
$json_string .= ',"{#IFDESCR}":"' . $descr . '"';
$json_string .= '},';
}
@ -110,7 +85,6 @@ function pfz_interface_discovery() {
}
//OpenVPN Server Discovery
function pfz_openvpn_get_all_servers(){
$servers = openvpn_get_active_servers();

Loading…
Cancel
Save