Skip to content

Commit 1faeb75

Browse files
committed
Implement Notification Period ignoring for TLVServiceNode
1 parent ce5ac86 commit 1faeb75

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

library/Toplevelview/Monitoring/Servicestatus.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class Servicestatus extends IcingaServiceStatus
1515
* @param array|null $columns
1616
* @noinspection PhpMissingParentConstructorInspection
1717
*/
18-
public function __construct(ConnectionInterface $connection, array $columns = null)
18+
public function __construct(ConnectionInterface $connection, array $columns = null, $options = null)
1919
{
2020
/** @var MonitoringBackend $connection */
2121
$this->connection = $connection;
22-
$this->query = new ServicestatusQuery($connection->getResource(), $columns);
22+
$this->query = new ServicestatusQuery($connection->getResource(), $columns, $options);
2323
}
2424

2525
/**

library/Toplevelview/Monitoring/ServicestatusQuery.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@
1010
*/
1111
class ServicestatusQuery extends IcingaServicestatusQuery
1212
{
13-
// TODO: not used in this query
14-
//use IgnoredNotificationPeriods;
15-
//use Options;
13+
use IgnoredNotificationPeriods;
14+
use Options;
15+
16+
public function __construct($ds, $columns = null, $options = null)
17+
{
18+
$this->setOptions($options);
19+
parent::__construct($ds, $columns);
20+
}
1621

1722
public function init()
1823
{
19-
/* TODO: not used in this query
2024
if (($periods = $this->getOption('ignored_notification_periods')) !== null) {
2125
$this->ignoreNotificationPeriods($periods);
2226
}
23-
*/
2427

2528
$patchedColumnMap = array(
2629
'servicestatus' => array(
@@ -52,11 +55,12 @@ protected function joinServicenotificationperiod()
5255
{
5356
$extraJoinCond = '';
5457

55-
/* TODO: not used in this query
56-
if (! empty ($this->ignoredNotificationPeriods)) {
57-
$extraJoinCond .= $this->db->quoteInto(' AND ntpo.name1 NOT IN (?)', $this->ignoredNotificationPeriods);
58+
if ($this->hasIgnoredNotifications()) {
59+
$extraJoinCond .= $this->db->quoteInto(
60+
' AND ntpo.name1 NOT IN (?)',
61+
$this->getIgnoredNotificationPeriods()
62+
);
5863
}
59-
*/
6064

6165
$this->select->joinLeft(
6266
["ntp" => $this->prefix . 'timeperiods'],

library/Toplevelview/Tree/TLVServiceNode.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,17 @@ public static function fetch(TLVTree $root)
5959
'service_in_downtime',
6060
);
6161

62+
$options = [];
63+
foreach (['notification_periods', 'host_never_unhandled', 'ignored_notification_periods'] as $opt) {
64+
$options[$opt] = $root->get($opt);
65+
}
66+
6267
if ($root->get('notification_periods') === true) {
6368
$columns[] = 'service_in_notification_period';
6469
}
6570

6671
// Note: this uses a patched version of Servicestatus / ServicestatusQuery !
67-
$services = new Servicestatus($root->getBackend(), $columns);
72+
$services = new Servicestatus($root->getBackend(), $columns, $options);
6873
$services->where('host_name', $names);
6974

7075
foreach ($services as $service) {

0 commit comments

Comments
 (0)