Skip to content
Permalink
Browse files

Clear service checks before appending to array

  • Loading branch information...
NEMS Linux
NEMS Linux committed Aug 23, 2019
1 parent 15d7122 commit 3732ec3723f407604ba044e0918f2daff51547ae
Showing with 24 additions and 19 deletions.
  1. +24 −19 stats-livestatus-all.sh
@@ -142,34 +142,39 @@ EOQ;
while ( list(, $row) = each($hosts) ) {
// services with info
$services = array();
if (is_array($row[9])) foreach ($row[9] as $service) {
$services[] = array(
'service'=>$service[0],
'state'=>$service[1],
'output'=>$service[3]
);
}
} else {
$services[] = array(); // for hosts that don't have any service checks
}
$nems->hosts[] = array(
'host_name'=>$row[0],
'alias'=>$row[1],
'address'=>$row[2],
'check_command'=>$row[3],
'display_name'=>$row[4],
'hard_state'=>$row[5],
'is_flapping'=>$row[6],
'last_check'=>$row[7],
'state'=>$row[8],
'services'=>$services,
);
'host_name'=>$row[0],
'alias'=>$row[1],
'address'=>$row[2],
'check_command'=>$row[3],
'display_name'=>$row[4],
'hard_state'=>$row[5],
'is_flapping'=>$row[6],
'last_check'=>$row[7],
'state'=>$row[8],
'services'=>$services,
);
}
if (!isset($nems->hosts)) {
$nems->hosts = array();
}
}
// quickstate is used by NCS Dashboard to display a very fast overview of how many hosts/services are in each state
$nems->quickstate = json_decode(trim(shell_exec('/usr/local/bin/nems-info state')));
echo json_encode($nems);
if (!isset($nems->hosts)) {
$nems->hosts = array();
}
// quickstate is used by NCS Dashboard to display a very fast overview of how many hosts/services are in each state
$nems->quickstate = json_decode(trim(shell_exec('/usr/local/bin/nems-info state')));
echo json_encode($nems);
?>

0 comments on commit 3732ec3

Please sign in to comment.
You can’t perform that action at this time.