nagios-charmers team mailing list archive
-
nagios-charmers team
-
Mailing list archive
-
Message #00875
[Merge] ~szeestraten/charm-nagios:bug/1864968 into charm-nagios:master
Sandor Zeestraten has proposed merging ~szeestraten/charm-nagios:bug/1864968 into charm-nagios:master.
Requested reviews:
Nagios Charm developers (nagios-charmers)
Related bugs:
Bug #1864968 in Nagios Charm: "Add support for modifying default contact configuration"
https://bugs.launchpad.net/charm-nagios/+bug/1864968
For more details, see:
https://code.launchpad.net/~szeestraten/charm-nagios/+git/nagios-charm/+merge/379943
--
Your team Nagios Charm developers is requested to review the proposed merge of ~szeestraten/charm-nagios:bug/1864968 into charm-nagios:master.
diff --git a/config.yaml b/config.yaml
index a5dd578..5920142 100644
--- a/config.yaml
+++ b/config.yaml
@@ -222,3 +222,67 @@ options:
u - Unknown
w - Warning
o - OK
+ service_notification_period:
+ default: "24x7"
+ type: string
+ description: |
+ This directive is used to specify the short name of the time period during
+ which the contact can be notified about service problems or recoveries.
+ You can think of this as an "on call" time for service notifications
+ for the contact. Read the documentation on time periods for more information
+ on how this works and potential problems that may result from improper use.
+ host_notification_period:
+ default: "24x7"
+ type: string
+ description: |
+ This directive is used to specify the short name of the time period during
+ which the contact can be notified about host problems or recoveries.
+ You can think of this as an "on call" time for host notifications
+ for the contact. Read the documentation on time periods for more information
+ on how this works and potential problems that may result from improper use.
+ service_notification_options:
+ default: "w,u,c,r"
+ type: string
+ description: |
+ This directive is used to define the service states for which notifications
+ can be sent out to this contact. Valid options are a combination of one
+ or more of the following:
+ w = notify on WARNING service states,
+ u = notify on UNKNOWN service states,
+ c = notify on CRITICAL service states,
+ r = notify on service recoveries (OK states),
+ f = notify when the service starts and stops flapping.
+ If you specify n (none) as an option, the contact will not receive any type of service notifications.
+ host_notification_options:
+ default: "d,r"
+ type: string
+ description: |
+ This directive is used to define the host states for which notifications
+ can be sent out to this contact. Valid options are a combination of one
+ or more of the following:
+ d = notify on DOWN host states,
+ u = notify on UNREACHABLE host states,
+ r = notify on host recoveries (UP states),
+ f = notify when the host starts and stops flapping,
+ s = send notifications when host or service scheduled downtime starts and ends.
+ If you specify n (none) as an option, the contact will not receive any type of host notifications.
+ service_notification_commands:
+ default: "notify-service-by-email"
+ type: string
+ description: |
+ This directive is used to define a list of the short names of the commands
+ used to notify the contact of a service problem or recovery.
+ Multiple notification commands should be separated by commas.
+ All notification commands are executed when the contact needs to be notified.
+ The maximum amount of time that a notification command can run is controlled
+ by the notification_timeout option.
+ host_notification_commands:
+ default: "notify-host-by-email"
+ type: string
+ description: |
+ This directive is used to define a list of the short names of the commands
+ used to notify the contact of a host problem or recovery.
+ Multiple notification commands should be separated by commas.
+ All notification commands are executed when the contact needs to be notified.
+ The maximum amount of time that a notification command can run is controlled
+ by the notification_timeout option.
diff --git a/hooks/templates/contacts-cfg.tmpl b/hooks/templates/contacts-cfg.tmpl
index 34cf6ff..d536918 100644
--- a/hooks/templates/contacts-cfg.tmpl
+++ b/hooks/templates/contacts-cfg.tmpl
@@ -21,12 +21,12 @@
define contact{
contact_name root
alias Root
- service_notification_period 24x7
- host_notification_period 24x7
- service_notification_options w,u,c,r
- host_notification_options d,r
- service_notification_commands notify-service-by-email
- host_notification_commands notify-host-by-email
+ service_notification_period {{ service_notification_period }}
+ host_notification_period {{ host_notification_period }}
+ service_notification_options {{ service_notification_options }}
+ host_notification_options {{ host_notification_options }}
+ service_notification_commands {{ service_notification_commands }}
+ host_notification_commands {{ host_notification_commands }}
email {{ admin_email }}
}
diff --git a/hooks/upgrade-charm b/hooks/upgrade-charm
index 4f42b3e..dd41c1a 100755
--- a/hooks/upgrade-charm
+++ b/hooks/upgrade-charm
@@ -165,9 +165,15 @@ def enable_pagerduty_config():
if enable_pagerduty:
# avoid duplicates
if "pagerduty" not in contactgroup_members:
- contactgroup_members += ", pagerduty"
-
- template_values = {'admin_email': hookenv.config('admin_email'),
+ contactgroup_members += ", pagerduty"
+
+ template_values = {'service_notification_period': hookenv.config('service_notification_period'),
+ 'host_notification_period': hookenv.config('host_notification_period'),
+ 'service_notification_options': hookenv.config('service_notification_options'),
+ 'host_notification_options': hookenv.config('host_notification_options'),
+ 'service_notification_commands': hookenv.config('service_notification_commands'),
+ 'host_notification_commands': hookenv.config('host_notification_commands'),
+ 'admin_email': hookenv.config('admin_email'),
'contactgroup_members': contactgroup_members}
with open('hooks/templates/contacts-cfg.tmpl', 'r') as f:
Follow ups