setTitle($this->translate('Health')); $db = $this->getDb(); $instance = Instance::on($db)->with(['endpoint']); $hoststateSummary = HoststateSummary::on($db)->with('state'); $servicestateSummary = ServicestateSummary::on($db)->with('state'); $this->applyMonitoringRestriction($hoststateSummary); $this->applyMonitoringRestriction($servicestateSummary); yield $this->export($instance, $hoststateSummary, $servicestateSummary); $instance = $instance->first(); if ($instance === null) { $this->addContent(Html::tag( 'p', 'It seems that Icinga DB is not running.' . ' Make sure Icinga DB is running and writing into the database.' )); return; } $hoststateSummary = $hoststateSummary->first(); $servicestateSummary = $servicestateSummary->first(); $this->content->addAttributes(['class' => 'monitoring-health']); $this->addContent(new Health($instance)); $this->addContent(Html::tag('section', ['class' => 'check-summary'], [ Html::tag('div', ['class' => 'col'], [ Html::tag('h3', 'Host Checks'), Html::tag('div', ['class' => 'col-content'], [ new VerticalKeyValue( 'Active', $hoststateSummary->hosts_active_checks_enabled ), new VerticalKeyValue( 'Passive', $hoststateSummary->hosts_passive_checks_enabled ) ]) ]), Html::tag('div', ['class' => 'col'], [ Html::tag('h3', 'Service Checks'), Html::tag('div', ['class' => 'col-content'], [ new VerticalKeyValue( 'Active', $servicestateSummary->services_active_checks_enabled ), new VerticalKeyValue( 'Passive', $servicestateSummary->services_passive_checks_enabled ) ]) ]) ])); $featureCommands = Html::tag( 'section', ['class' => 'instance-commands'], Html::tag('h2', 'Feature Commands') ); $programStatus = (object) [ 'active_host_checks_enabled' => $instance->icinga2_active_host_checks_enabled, 'active_service_checks_enabled' => $instance->icinga2_active_service_checks_enabled, 'event_handlers_enabled' => $instance->icinga2_event_handlers_enabled, 'flap_detection_enabled' => $instance->icinga2_flap_detection_enabled, 'notifications_enabled' => $instance->icinga2_notifications_enabled, 'process_performance_data' => $instance->icinga2_performance_data_enabled, 'program_version' => $instance->icinga2_version ]; $toggleInstanceFeaturesCommandForm = new ToggleInstanceFeaturesCommandForm(); $toggleInstanceFeaturesCommandForm ->setBackend(new CompatBackend()) ->setStatus($programStatus) ->load($programStatus) ->handleRequest(); $featureCommands->add(HtmlString::create($toggleInstanceFeaturesCommandForm->render())); $this->addContent($featureCommands); $this->setAutorefreshInterval(30); } }