Some fixes for services status

This commit is contained in:
Daniel Berteaud 2023-12-08 13:44:27 +01:00
parent a99caf808d
commit 393a6a00ee
1 changed files with 5 additions and 6 deletions

View File

@ -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;