From 393a6a00ee70b582308e9e9d18e993d45a5c8e1f Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 8 Dec 2023 13:44:27 +0100 Subject: [PATCH] Some fixes for services status --- pfsense_zbx.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pfsense_zbx.php b/pfsense_zbx.php index 0677567..01cfb3b 100644 --- a/pfsense_zbx.php +++ b/pfsense_zbx.php @@ -136,7 +136,7 @@ function pfz_interface_discovery($is_wan=false,$is_cron=false) { } $json_string = rtrim($json_string,","); - $json_string .= "]"; + $json_string .= "]}"; if ($is_cron) return $if_ret; @@ -410,13 +410,10 @@ function pfz_openvpn_clientvalue($client_id, $valuekey, $default="none"){ function pfz_services_discovery(){ $services = get_services(); - $json_string = '['; + $json_string = '{"data":['; foreach ($services as $service){ if (!empty($service['name'])) { - // IPerf is only started on demand - if ($service['name'] == "iperf") - continue; $status = get_service_status($service); if ($status="") $status = 0; @@ -433,7 +430,7 @@ function pfz_services_discovery(){ } } $json_string = rtrim($json_string,","); - $json_string .= "]"; + $json_string .= "]}"; echo $json_string; @@ -473,6 +470,8 @@ function pfz_service_value($name,$value){ case "status": $status = get_service_status($service); if ($status=="") $status = 0; + // Don't trigger for disabled services + if (is_service_enabled($service['name'])) $status = 1; echo $status; return;