mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
This was easy because only README.md and doc/01-About.md were redacted manually, everything else via: git ls-files -z |xargs -0 perl -pi -e 's/Icinga GmbH \| GPLv2/Icinga GmbH | GPLv2+/' This is legal because we have only merged PRs with label:cla/signed or made by Icinga staff: https://github.com/Icinga/icingadb-web/pulls?page=1&q=is%3Apr+is%3Aclosed+-label%3Acla%2Fsigned+-author%3Anilmerg This has no risk for us in people distributing their own version under GPLv3 only. After all, we won't take their patches anyway, unless they sign our CLA. This is the cleanest solution for having e.g. these in one address space: * Icinga Web, GPLv2+ * K8s Web, AGPLv3 * Thirdparty, some LGPLv3 and Apache-2.0 Apropos, K8s Web is even v3-licensed on purpose, to have a stronger protection against cloud ops.
92 lines
3.2 KiB
PHP
92 lines
3.2 KiB
PHP
<?php
|
|
|
|
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2+ */
|
|
|
|
namespace Icinga\Module\Icingadb\Model;
|
|
|
|
use ipl\Sql\Connection;
|
|
use ipl\Sql\Expression;
|
|
|
|
/**
|
|
* @property int $hosts_acknowledged
|
|
* @property int $hosts_active_checks_enabled
|
|
* @property int $hosts_passive_checks_enabled
|
|
* @property int $hosts_down_handled
|
|
* @property int $hosts_down_unhandled
|
|
* @property int $hosts_event_handler_enabled
|
|
* @property int $hosts_flapping_enabled
|
|
* @property int $hosts_notifications_enabled
|
|
* @property int $hosts_pending
|
|
* @property int $hosts_problems_unacknowledged
|
|
* @property int $hosts_total
|
|
* @property int $hosts_up
|
|
*/
|
|
class HoststateSummary extends Host
|
|
{
|
|
public function getSummaryColumns()
|
|
{
|
|
return [
|
|
'hosts_acknowledged' => new Expression(
|
|
'SUM(CASE WHEN host_state.is_acknowledged = \'y\' THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_active_checks_enabled' => new Expression(
|
|
'SUM(CASE WHEN host.active_checks_enabled = \'y\' THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_passive_checks_enabled' => new Expression(
|
|
'SUM(CASE WHEN host.passive_checks_enabled = \'y\' THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_down_handled' => new Expression(
|
|
'SUM(CASE WHEN host_state.soft_state = 1'
|
|
. ' AND (host_state.is_handled = \'y\' OR host_state.is_reachable = \'n\') THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_down_unhandled' => new Expression(
|
|
'SUM(CASE WHEN host_state.soft_state = 1'
|
|
. ' AND host_state.is_handled = \'n\' AND host_state.is_reachable = \'y\' THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_event_handler_enabled' => new Expression(
|
|
'SUM(CASE WHEN host.event_handler_enabled = \'y\' THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_flapping_enabled' => new Expression(
|
|
'SUM(CASE WHEN host.flapping_enabled = \'y\' THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_notifications_enabled' => new Expression(
|
|
'SUM(CASE WHEN host.notifications_enabled = \'y\' THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_pending' => new Expression(
|
|
'SUM(CASE WHEN host_state.soft_state = 99 THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_problems_unacknowledged' => new Expression(
|
|
'SUM(CASE WHEN host_state.is_problem = \'y\''
|
|
. ' AND host_state.is_acknowledged = \'n\' THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_total' => new Expression(
|
|
'SUM(CASE WHEN host.id IS NOT NULL THEN 1 ELSE 0 END)'
|
|
),
|
|
'hosts_up' => new Expression(
|
|
'SUM(CASE WHEN host_state.soft_state = 0 THEN 1 ELSE 0 END)'
|
|
)
|
|
];
|
|
}
|
|
|
|
public static function on(Connection $db)
|
|
{
|
|
$q = parent::on($db);
|
|
$q->utilize('state');
|
|
|
|
/** @var static $m */
|
|
$m = $q->getModel();
|
|
$q->columns($m->getSummaryColumns());
|
|
|
|
return $q;
|
|
}
|
|
|
|
public function getColumns()
|
|
{
|
|
return array_merge(parent::getColumns(), $this->getSummaryColumns());
|
|
}
|
|
|
|
public function getDefaultSort()
|
|
{
|
|
return null;
|
|
}
|
|
}
|