-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
334aaf8
commit df2832d
Showing
7 changed files
with
740 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
library/Icingadb/ProvidedHook/Reporting/HostSlaChartReport.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/* Icinga DB Web | (c) 2024 Icinga GmbH | GPLv2 */ | ||
|
||
namespace Icinga\Module\Icingadb\ProvidedHook\Reporting; | ||
|
||
use Icinga\Application\Icinga; | ||
use Icinga\Module\Icingadb\Model\Host; | ||
use Icinga\Module\Reporting\Timerange; | ||
use ipl\Sql\Expression; | ||
use ipl\Stdlib\Filter\Rule; | ||
|
||
use function ipl\I18n\t; | ||
|
||
class HostSlaChartReport extends SlaChartReport | ||
{ | ||
public function getName() | ||
{ | ||
$name = t('Host SLA Chart'); | ||
if (Icinga::app()->getModuleManager()->hasEnabled('idoreports')) { | ||
$name .= ' (Icinga DB)'; | ||
} | ||
|
||
return $name; | ||
} | ||
|
||
protected function fetchSla(Timerange $timerange, Rule $filter = null) | ||
{ | ||
$sla = Host::on($this->getDb()) | ||
->columns([ | ||
'id', | ||
'display_name', | ||
'sla' => new Expression(sprintf( | ||
"get_sla_ok_percent(%s, NULL, '%s', '%s')", | ||
'host.id', | ||
$timerange->getStart()->format('Uv'), | ||
$timerange->getEnd()->format('Uv') | ||
)), | ||
]); | ||
|
||
$this->applyRestrictions($sla); | ||
|
||
if ($filter !== null) { | ||
$sla->filter($filter); | ||
} | ||
|
||
return $sla; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
library/Icingadb/ProvidedHook/Reporting/ServiceSlaChartReport.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* Icinga DB Web | (c) 2024 Icinga GmbH | GPLv2 */ | ||
|
||
namespace Icinga\Module\Icingadb\ProvidedHook\Reporting; | ||
|
||
use Icinga\Application\Icinga; | ||
use Icinga\Module\Icingadb\Model\Service; | ||
use Icinga\Module\Reporting\Timerange; | ||
use ipl\Sql\Expression; | ||
use ipl\Stdlib\Filter\Rule; | ||
|
||
use function ipl\I18n\t; | ||
|
||
class ServiceSlaChartReport extends SlaChartReport | ||
{ | ||
public function getName() | ||
{ | ||
$name = t('Service SLA Chart'); | ||
if (Icinga::app()->getModuleManager()->hasEnabled('idoreports')) { | ||
$name .= ' (Icinga DB)'; | ||
} | ||
|
||
return $name; | ||
} | ||
|
||
protected function fetchSla(Timerange $timerange, Rule $filter = null) | ||
{ | ||
$sla = Service::on($this->getDb()) | ||
->columns([ | ||
'id', | ||
'host.display_name', | ||
'display_name', | ||
'sla' => new Expression(sprintf( | ||
"get_sla_ok_percent(%s, %s, '%s', '%s')", | ||
'service.host_id', | ||
'service.id', | ||
$timerange->getStart()->format('Uv'), | ||
$timerange->getEnd()->format('Uv') | ||
)) | ||
]); | ||
|
||
$sla->resetOrderBy()->orderBy('host.display_name')->orderBy('display_name'); | ||
|
||
$this->applyRestrictions($sla); | ||
|
||
if ($filter !== null) { | ||
$sla->filter($filter); | ||
} | ||
|
||
return $sla; | ||
} | ||
} |
Oops, something went wrong.