Merge lp:~chris-gondolin/charms/trusty/nrpe/fix-sub-postfix into lp:charms/trusty/nrpe

Proposed by Chris Stratford on 2016-02-11
Status: Merged
Merged at revision: 40
Proposed branch: lp:~chris-gondolin/charms/trusty/nrpe/fix-sub-postfix
Merge into: lp:charms/trusty/nrpe
Diff against target: 50 lines (+18/-1)
3 files modified
config.yaml (+6/-0)
hooks/nrpe_helpers.py (+2/-1)
tests/10-tests (+10/-0)
To merge this branch: bzr merge lp:~chris-gondolin/charms/trusty/nrpe/fix-sub-postfix
Reviewer Review Type Date Requested Status
Marco Ceppi 2016-02-11 Approve on 2016-03-02
David Ames Approve on 2016-02-17
Review via email: mp+285692@code.launchpad.net

Description of the Change

This adds a new "sub_postfix" option to allow the deployer to specify what (if any) extension they want used for the subordinate checks automatically added by the charm (check_disk_root, etc.)

By default it's set to "_sub", so we end up with /etc/nagios/nrpe.d/check_disk_root_sub (i.e. the same as the current version), but if set to "" it makes the checks compatible with the old nagios-external-master charm and should fix bug#1473205.

To post a comment you must log in.
David Ames (thedac) wrote :

Chris,

This looks good. Approved.

review: Approve
Marco Ceppi (marcoceppi) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-03-23 09:45:10 +0000
3+++ config.yaml 2016-02-11 10:31:07 +0000
4@@ -84,3 +84,9 @@
5 If True nagios check definitions are written to
6 '/var/lib/nagios/export' and rync is configured to allow nagios_master
7 to collect them. Useful when Nagios is outside of the juju environment
8+ sub_postfix:
9+ default: "_sub"
10+ type: string
11+ description: |
12+ A string to be appended onto all the nrpe checks created by this charm
13+ to avoid potential clashes with existing checks
14
15=== modified file 'hooks/nrpe_helpers.py'
16--- hooks/nrpe_helpers.py 2016-02-03 22:49:58 +0000
17+++ hooks/nrpe_helpers.py 2016-02-11 10:31:07 +0000
18@@ -274,9 +274,10 @@
19 },
20 ]
21 self['checks'] = []
22+ sub_postfix = str(hookenv.config("sub_postfix"))
23 for check in checks:
24 check['description'] += " (sub)"
25- check['cmd_name'] += "_sub"
26+ check['cmd_name'] += sub_postfix
27 self['checks'].append(check)
28
29 def proc_count(self):
30
31=== modified file 'tests/10-tests'
32--- tests/10-tests 2016-02-03 22:17:17 +0000
33+++ tests/10-tests 2016-02-11 10:31:07 +0000
34@@ -244,6 +244,16 @@
35 }
36 self.check_nrpe_setting(**test_config)
37
38+ def test_sub_postfix(self):
39+ sentry = self.deployment.sentry['nrpe'][0]
40+ test_config = {
41+ 'filename': '/etc/nagios/nrpe.d/check_disk_root_testing.cfg',
42+ 'expected_settings': {'command[check_disk_root]': '/usr/lib/nagios/plugins/check_disk -u GB -w 25% -c 20% -K 5% -p /'},
43+ 'juju_kv': { 'sub_postfix': '_testing'},
44+ 'filedelim': '=',
45+ }
46+ self.check_nrpe_setting(**test_config)
47+
48 def test_custom_disk_check_params(self):
49 chk_key = 'command[check_disk_root]=/usr/lib/nagios/plugins/check_disk'
50 test_config = {

Subscribers

People subscribed via source and target branches

to all changes: