Merge ~nagios-charmers/charm-nagios:flap-detection into ~nagios-charmers/charm-nagios:master

Proposed by James Hebden
Status: Merged
Approved by: Joel Sing
Approved revision: 5792a7103af4b82a3e32b2940f9ba0a67a03c182
Merged at revision: 8a7c28264766f48bec31bbfc7d83b2f1fe635304
Proposed branch: ~nagios-charmers/charm-nagios:flap-detection
Merge into: ~nagios-charmers/charm-nagios:master
Diff against target: 53 lines (+12/-1)
3 files modified
config.yaml (+5/-0)
hooks/templates/nagios-cfg.tmpl (+1/-1)
hooks/upgrade-charm (+6/-0)
Reviewer Review Type Date Requested Status
Joel Sing (community) +1 Approve
Canonical IS Reviewers Pending
Review via email: mp+375524@code.launchpad.net

Commit message

Add flap detection configuration option.

This merge introduces a new configuration item "flap_detection".
It controls whether or not flap detection is enabled in Nagios. The default is true, which matches the present hard-coded default in the Nagios configuration template.

Additionally, I have added a function to the hooks library that will convert a python boolean type (which is returned by hookenv.config for a boolean type config item) into Nagios's preferred 0/1 integer representation for on/off states. This new setting uses the function, but I have not altered the behaviour of any existing settings and their rendering into the configuration file. It simply typecasts the boolean type as int, which achieves the desired result.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Joel Sing (jsing) wrote :

LGTM

review: Approve (+1)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 8a7c28264766f48bec31bbfc7d83b2f1fe635304

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index 4ce0f18..da83582 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -6,6 +6,11 @@ options:
6 Any additional nagios configuration you would like to
7 add can be set into this element. It will be placed in
8 /etc/nagios3/conf.d/extra.cfg
9+ flap_detection:
10+ type: boolean
11+ default: true
12+ description: |
13+ Enable flap detection on monitored hosts and services.
14 ssl:
15 type: string
16 default: "off"
17diff --git a/hooks/templates/nagios-cfg.tmpl b/hooks/templates/nagios-cfg.tmpl
18index c45ed31..2d202b2 100644
19--- a/hooks/templates/nagios-cfg.tmpl
20+++ b/hooks/templates/nagios-cfg.tmpl
21@@ -1097,7 +1097,7 @@ additional_freshness_latency=15
22 # Values: 1 = enable flap detection
23 # 0 = disable flap detection (default)
24
25-enable_flap_detection=1
26+enable_flap_detection={{ flap_detection }}
27
28
29
30diff --git a/hooks/upgrade-charm b/hooks/upgrade-charm
31index 19e736c..9edf436 100755
32--- a/hooks/upgrade-charm
33+++ b/hooks/upgrade-charm
34@@ -233,6 +233,11 @@ def enable_ssl():
35 hookenv.log("Decoded SSL files", "INFO")
36
37
38+def nagios_bool(value):
39+ """Convert a Python boolean into Nagios 0/1 integer representation."""
40+ return int(value)
41+
42+
43 def update_config():
44 host_context = hookenv.config('nagios_host_context')
45 local_host_name = 'nagios'
46@@ -254,6 +259,7 @@ def update_config():
47 'debug_verbosity': hookenv.config('debug_verbosity'),
48 'debug_level': hookenv.config('debug_level'),
49 'daemon_dumps_core': hookenv.config('daemon_dumps_core'),
50+ 'flap_detection': nagios_bool(hookenv.config('flap_detection')),
51 'admin_email': hookenv.config('admin_email'),
52 'admin_pager': hookenv.config('admin_pager'),
53 'log_rotation_method': hookenv.config('log_rotation_method'),

Subscribers

People subscribed via source and target branches

to all changes: