public function getState() { $hostname = $this->hostname; $port = $this->port; $protocol = $this->protocol; $url = $this->url; $ret = NagdashHelpers::fetch_json($hostname, $port, $protocol, $url . "/hosts?" . "Columns=name,state,acknowledged,last_state_change,downtimes,notifications_enabled,current_attempt,max_check_attempts,plugin_output"); if ($ret["errors"] == true) { return $ret["details"]; } $state = $ret["details"]["content"]; $curl_stats = $ret["curl_stats"]; $curl_stats["{$hostname}:{$port}"]['objects'] = count($state); $munge = []; foreach ($state as $host) { $host['services'] = []; $munge[$host['name']] = $host; } $state = $munge; $ret = NagdashHelpers::fetch_json($hostname, $port, $protocol, $url . "/services?" . "Columns=description,host_name,plugin_output,notifications_enabled," . "downtimes,scheduled_downtime_depth,state,last_state_change," . "current_attempt,max_check_attempts,acknowledged"); $services = $ret["details"]["content"]; foreach ($services as $service) { $hostname = $service['host_name']; if ($state[$hostname]) { $state[$hostname]['services'][$service['description']] = $service; } } return ["errors" => false, "details" => $state, "curl_stats" => $curl_stats]; }
public function getState() { $response = NagdashHelpers::fetch_json($this->hostname, $this->port, $this->protocol, $this->url); return $response; }