2019-11-27 07:17:44 -05:00
|
|
|
<?php
|
|
|
|
|
|
2020-03-13 03:38:01 -04:00
|
|
|
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
|
|
|
|
|
|
2019-11-27 07:17:44 -05:00
|
|
|
namespace Icinga\Module\Icingadb\Web\Navigation\Renderer;
|
|
|
|
|
|
2021-01-28 06:56:45 -05:00
|
|
|
use Icinga\Module\Icingadb\Common\Auth;
|
2019-11-27 07:17:44 -05:00
|
|
|
use Icinga\Module\Icingadb\Common\Links;
|
|
|
|
|
use Icinga\Module\Icingadb\Model\HoststateSummary;
|
2021-09-22 04:21:15 -04:00
|
|
|
use ipl\Web\Url;
|
2019-11-27 07:17:44 -05:00
|
|
|
|
|
|
|
|
class HostProblemsBadge extends ProblemsBadge
|
|
|
|
|
{
|
2021-01-28 06:56:45 -05:00
|
|
|
use Auth;
|
|
|
|
|
|
2019-11-27 07:17:44 -05:00
|
|
|
protected function fetchProblemsCount()
|
|
|
|
|
{
|
2022-05-19 05:24:20 -04:00
|
|
|
$summary = HoststateSummary::on($this->getDb());
|
2021-01-28 06:56:45 -05:00
|
|
|
$this->applyRestrictions($summary);
|
2022-02-25 11:54:52 -05:00
|
|
|
$count = (int) $summary->first()->hosts_down_unhandled;
|
|
|
|
|
if ($count) {
|
|
|
|
|
$this->setTitle(sprintf(
|
|
|
|
|
tp('One unhandled host down', '%d unhandled hosts down', $count),
|
|
|
|
|
$count
|
|
|
|
|
));
|
|
|
|
|
}
|
2021-01-28 06:56:45 -05:00
|
|
|
|
2022-02-25 11:54:52 -05:00
|
|
|
return $count;
|
2019-11-27 07:17:44 -05:00
|
|
|
}
|
|
|
|
|
|
2021-09-22 04:21:15 -04:00
|
|
|
protected function getUrl(): Url
|
2019-11-27 07:17:44 -05:00
|
|
|
{
|
|
|
|
|
return Links::hosts()->setParams(['host.state.is_problem' => 'y', 'sort' => 'host.state.severity desc']);
|
|
|
|
|
}
|
|
|
|
|
}
|