Skip to content

Commit

Permalink
IcingaConfig/IcingaObject(Legacy): Render dummy notification settings
Browse files Browse the repository at this point in the history
So we avoid warnings about nothing configured.

refs #13049
  • Loading branch information
lazyfrosch committed Nov 16, 2016
1 parent 2725ef5 commit 480e13b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
40 changes: 40 additions & 0 deletions library/Director/IcingaConfig/IcingaConfig.php
Expand Up @@ -500,6 +500,15 @@ protected function generateFromDb()
protected function prepareGlobalBasics()
{
if ($this->isLegacy()) {
$this->configFile(
sprintf(
'director/%s/001-director-basics',
$this->connection->getDefaultGlobalZoneName()
), '.cfg'
)->prepend(
$this->renderLegacyDefaultNotification()
);

return $this;
}

Expand Down Expand Up @@ -781,4 +790,35 @@ public function getLastActivityChecksum()

return $this->lastActivityChecksum;
}

protected function renderLegacyDefaultNotification()
{
return preg_replace('~\s{12}~', '', '
define contact {
contact_name icingaadmin
alias Icinga Admin
host_notifications_enabled 0
host_notification_commands notify-never-default
host_notification_period notification_none
service_notifications_enabled 0
service_notification_commands notify-never-default
service_notification_period notification_none
}
define contactgroup {
contactgroup_name icingaadmins
members icingaadmin
}
define timeperiod {
timeperiod_name notification_none
alias No Notifications
}
define command {
command_name notify-never-default
command_line /bin/echo "NOOP"
}
');
}
}
10 changes: 10 additions & 0 deletions library/Director/Objects/IcingaObject.php
Expand Up @@ -2054,6 +2054,16 @@ protected function renderLegacyCustomExtensions()
{
$str = '';

// Set notification settings for the object to suppress warnings
if (
array_key_exists('enable_notifications', $this->defaultProperties)
&& $this->isTemplate()
) {
$str .= c1::renderKeyValue('notification_period', 'notification_none');
$str .= c1::renderKeyValue('notification_interval', '0');
$str .= c1::renderKeyValue('contact_groups', 'icingaadmins');
}

// force rendering of check_command when ARG1 is set
if ($this->supportsCustomVars() && array_key_exists('check_command_id', $this->defaultProperties)) {
if (
Expand Down

0 comments on commit 480e13b

Please sign in to comment.