Skip to content

Commit

Permalink
Merge pull request #36 from Icinga/bugfix/service-notification-periods
Browse files Browse the repository at this point in the history
Implement Notification Period ignoring for TLVServiceNode
  • Loading branch information
lazyfrosch committed Mar 6, 2019
2 parents 76f1998 + 1faeb75 commit f275942
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions library/Toplevelview/Monitoring/Servicestatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class Servicestatus extends IcingaServiceStatus
* @param array|null $columns
* @noinspection PhpMissingParentConstructorInspection
*/
public function __construct(ConnectionInterface $connection, array $columns = null)
public function __construct(ConnectionInterface $connection, array $columns = null, $options = null)
{
/** @var MonitoringBackend $connection */
$this->connection = $connection;
$this->query = new ServicestatusQuery($connection->getResource(), $columns);
$this->query = new ServicestatusQuery($connection->getResource(), $columns, $options);
}

/**
Expand Down
22 changes: 13 additions & 9 deletions library/Toplevelview/Monitoring/ServicestatusQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@
*/
class ServicestatusQuery extends IcingaServicestatusQuery
{
// TODO: not used in this query
//use IgnoredNotificationPeriods;
//use Options;
use IgnoredNotificationPeriods;
use Options;

public function __construct($ds, $columns = null, $options = null)
{
$this->setOptions($options);
parent::__construct($ds, $columns);
}

public function init()
{
/* TODO: not used in this query
if (($periods = $this->getOption('ignored_notification_periods')) !== null) {
$this->ignoreNotificationPeriods($periods);
}
*/

$patchedColumnMap = array(
'servicestatus' => array(
Expand Down Expand Up @@ -52,11 +55,12 @@ protected function joinServicenotificationperiod()
{
$extraJoinCond = '';

/* TODO: not used in this query
if (! empty ($this->ignoredNotificationPeriods)) {
$extraJoinCond .= $this->db->quoteInto(' AND ntpo.name1 NOT IN (?)', $this->ignoredNotificationPeriods);
if ($this->hasIgnoredNotifications()) {
$extraJoinCond .= $this->db->quoteInto(
' AND ntpo.name1 NOT IN (?)',
$this->getIgnoredNotificationPeriods()
);
}
*/

$this->select->joinLeft(
["ntp" => $this->prefix . 'timeperiods'],
Expand Down
7 changes: 6 additions & 1 deletion library/Toplevelview/Tree/TLVServiceNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ public static function fetch(TLVTree $root)
'service_in_downtime',
);

$options = [];
foreach (['notification_periods', 'host_never_unhandled', 'ignored_notification_periods'] as $opt) {
$options[$opt] = $root->get($opt);
}

if ($root->get('notification_periods') === true) {
$columns[] = 'service_in_notification_period';
}

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

foreach ($services as $service) {
Expand Down

0 comments on commit f275942

Please sign in to comment.