Merge lp:~facundo/charms/trusty/tanuki-result-enum-worker/add-nagios-support into lp:~tanuki/charms/trusty/tanuki-result-enum-worker/trunk

Proposed by Facundo Batista
Status: Merged
Approved by: Thomi Richards
Approved revision: 30
Merged at revision: 30
Proposed branch: lp:~facundo/charms/trusty/tanuki-result-enum-worker/add-nagios-support
Merge into: lp:~tanuki/charms/trusty/tanuki-result-enum-worker/trunk
Diff against target: 97 lines (+28/-6)
4 files modified
config.yaml (+5/-0)
hooks/actions.py (+18/-5)
hooks/services.py (+1/-0)
metadata.yaml (+4/-1)
To merge this branch: bzr merge lp:~facundo/charms/trusty/tanuki-result-enum-worker/add-nagios-support
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Review via email: mp+267703@code.launchpad.net

Commit message

Added nagios support.

Description of the change

Added nagios support.

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) wrote :

Facundo,

Thanks for working on this, can you try to address my inline comment for proper check_file_age configuration and description.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

The spec change landed already, which means that I've spent about half a day trying to figure out why I can't get the spec to work... turns out it's because the charm doesn't support 'nagios_context' yet.

I could rollback the spec, or land this. I'm choosing to land this, since Celso's comment isn't serious, and can be done in a separate branch. I'll create a trello card, assign it to Facundo, and point to this comment.

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-07-20 15:03:35 +0000
3+++ config.yaml 2015-08-11 19:33:08 +0000
4@@ -11,3 +11,8 @@
5 type: boolean
6 default: true
7 description: "Whether the service is active or not."
8+ nagios_context:
9+ type: string
10+ default: ""
11+ description: |
12+ Used by the nrpe subordinate charms.
13
14=== modified file 'hooks/actions.py'
15--- hooks/actions.py 2015-07-23 17:04:16 +0000
16+++ hooks/actions.py 2015-08-11 19:33:08 +0000
17@@ -4,11 +4,8 @@
18 import subprocess
19
20 from charmhelpers import fetch
21-from charmhelpers.core import (
22- hookenv,
23- host,
24-)
25-
26+from charmhelpers.contrib.charmsupport import nrpe
27+from charmhelpers.core import hookenv, host
28 from charmhelpers.payload import archive, execd
29
30
31@@ -21,6 +18,8 @@
32 BASE_DIR = '/srv/result-enum-worker/{}'.format(config['environment'])
33 SERVICE_DIR = os.path.join(BASE_DIR, 'result-enum-worker')
34 LOG_DIR = os.path.join(BASE_DIR, 'logs')
35+VARS_DIR = os.path.join(BASE_DIR, 'var')
36+NAGIOS_CONTROL_FILEPATH = os.path.join(VARS_DIR, 'nagios.txt')
37
38
39 def log_start(service_name):
40@@ -29,6 +28,7 @@
41
42 def ensure_directories(service_name):
43 host.mkdir(BASE_DIR, owner='root', group='ubuntu')
44+ host.mkdir(VARS_DIR, owner='root', group='ubuntu')
45
46
47 def basenode(service_name):
48@@ -68,6 +68,7 @@
49 mongo_addresses.append(mongo_address)
50 assert mongo_addresses != []
51 parser['mongodb']['server'] = ','.join(mongo_addresses)
52+ parser['nagios_check']['filename'] = NAGIOS_CONTROL_FILEPATH
53 with open(config_path, 'w') as f:
54 parser.write(f)
55
56@@ -106,3 +107,15 @@
57
58 subprocess.check_call(['%s/bin/pip' % env_dir,
59 'install', '--no-deps', '-e', SERVICE_DIR])
60+
61+
62+def nrpe_external_master_relation(service_name):
63+ """Configure the nrpe-external-master relation."""
64+ nrpe_compat = nrpe.NRPE()
65+
66+ nrpe_compat.add_check(
67+ shortname='fileage',
68+ description='Check file age',
69+ check_cmd='check_file_age %s' % NAGIOS_CONTROL_FILEPATH
70+ )
71+ nrpe_compat.write()
72
73=== modified file 'hooks/services.py'
74--- hooks/services.py 2015-08-10 15:47:08 +0000
75+++ hooks/services.py 2015-08-11 19:33:08 +0000
76@@ -29,6 +29,7 @@
77 source='upstart.conf',
78 target='/etc/init/result-enum-worker.conf'),
79 actions.log_start,
80+ actions.nrpe_external_master_relation,
81 ],
82 },
83 ])
84
85=== modified file 'metadata.yaml'
86--- metadata.yaml 2015-07-17 03:23:32 +0000
87+++ metadata.yaml 2015-08-11 19:33:08 +0000
88@@ -5,4 +5,7 @@
89 Runs result-enum-worker service.
90 requires:
91 mongodb:
92- interface: mongodb
93\ No newline at end of file
94+ interface: mongodb
95+ nrpe-external-master:
96+ interface: nrpe-external-master
97+ scope: container

Subscribers

People subscribed via source and target branches

to all changes: