Merge ~hloeung/mailman3-core-charm:master into mailman3-core-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: David Lawson
Approved revision: b40dbe20e86da40b293cabad4c40db2802860f99
Merged at revision: 4cdf4d03108d83a546f5c9289d59e5faf3f3c55b
Proposed branch: ~hloeung/mailman3-core-charm:master
Merge into: mailman3-core-charm:master
Diff against target: 91 lines (+31/-15)
3 files modified
config.yaml (+16/-0)
layer.yaml (+0/-1)
reactive/mailman3_core.py (+15/-14)
Reviewer Review Type Date Requested Status
Mailman3 charm maintainers Pending
Review via email: mp+345804@code.launchpad.net

Commit message

Fix code to set up NRPE checks.

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
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 4cdf4d03108d83a546f5c9289d59e5faf3f3c55b

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 9a493a2..e5db6d3 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -3,3 +3,19 @@ options:
6 type: string
7 default: ""
8 description: "Additional packages to install on the unit."
9+ nagios_context:
10+ default: "juju"
11+ type: string
12+ description: |
13+ Used by the nrpe subordinate charms.
14+ A string that will be prepended to instance name to set the host name
15+ in nagios. So for instance the hostname would be something like:
16+ juju-myservice-0
17+ If you're running multiple environments with the same services in them
18+ this allows you to differentiate between them.
19+ nagios_servicegroups:
20+ default: ""
21+ type: string
22+ description: |
23+ A comma-separated list of nagios servicegroups.
24+ If left empty, the nagios_context will be used as the servicegroup
25diff --git a/layer.yaml b/layer.yaml
26index 8c96637..52b8b6f 100644
27--- a/layer.yaml
28+++ b/layer.yaml
29@@ -1,7 +1,6 @@
30 repo: lp:mailman3-core-charm
31 includes:
32 - 'interface:generic-ip-port-user-pass'
33- - 'interface:nrpe-external-master'
34 - 'interface:pgsql'
35 - 'layer:apt'
36 - 'layer:basic'
37diff --git a/reactive/mailman3_core.py b/reactive/mailman3_core.py
38index 7b7b3a4..45a07f0 100644
39--- a/reactive/mailman3_core.py
40+++ b/reactive/mailman3_core.py
41@@ -5,6 +5,7 @@ from charms.reactive import clear_flag, endpoint_from_flag, set_flag, when, when
42 from charmhelpers.core import hookenv, unitdata
43 from charmhelpers.core.host import service
44 from charmhelpers.core.templating import render
45+from charmhelpers.contrib.charmsupport import nrpe
46
47
48 # We actually have two configs for this, though realistically the hyperkitty
49@@ -152,28 +153,28 @@ def changed_archiver_data():
50
51 @when('nrpe-external-master.available')
52 def setup_nagios(nagios):
53- config = hookenv.config()
54+ if hookenv.hook_name() == 'update-status':
55+ return
56+
57+ # Ask charmhelpers.contrib.charmsupport's nrpe to work out our hostname
58+ hostname = nrpe.get_nagios_hostname()
59+ nrpe_setup = nrpe.NRPE(hostname=hostname, primary=False)
60+
61 db = unitdata.kv()
62- unit_name = hookenv.local_unit()
63+
64 check_base = '/usr/lib/nagios/plugins/'
65 process_check = check_base + 'check_procs'
66
67 mailman_master_process = [process_check, '-c', '1:1', '-C', 'python3', '-a', 'master']
68- nagios.add_check(mailman_master_process, name="mailman_master_process",
69- description="Check for Mailman3 master process",
70- context=config['nagios_context'], unit=unit_name)
71+ nrpe_setup.add_check('mailman_master_process', 'Check for Mailman3 master process', mailman_master_process)
72
73 mailman_runner_process = [process_check, '-c', '12:12', '-C', 'python3', '-a', 'runner']
74- nagios.add_check(mailman_runner_process, name="mailman_runner_process",
75- description="Check for Mailman3 runner processes",
76- context=config['nagios_context'], unit=unit_name)
77+ nrpe_setup.add_check('mailman_runner_process', 'Check for Mailman3 runner processes', mailman_runner_process)
78
79 mailman_rest_port = [check_base + 'check_tcp', '-H', '127.0.0.1', '-p', db.get('admin_port')]
80- nagios.add_check(mailman_rest_port, name="mailman_rest_port",
81- description="Check Mailman3 REST API port",
82- context=config['nagios_context'], unit=unit_name)
83+ nrpe_setup.add_check('mailman_rest_port', 'Check Mailman3 REST API port', mailman_rest_port)
84
85 postfix_check = [check_base + 'check_tcp', '-H', '127.0.0.1', '-p', '25']
86- nagios.add_check(postfix_check, name="postfix_port",
87- description="Check postfix port",
88- context=config['nagios_context'], unit=unit_name)
89+ nrpe_setup.add_check('postfix_port', 'Check postfix port', postfix_check)
90+
91+ nrpe_setup.write()

Subscribers

People subscribed via source and target branches