Merge lp:~fginther/uci-engine/rabbit-worker-nrpe-2 into lp:uci-engine

Proposed by Francis Ginther
Status: Superseded
Proposed branch: lp:~fginther/uci-engine/rabbit-worker-nrpe-2
Merge into: lp:uci-engine
Diff against target: 167 lines (+97/-4)
4 files modified
branch-source-builder/bin/check_bsbuilder.py (+35/-0)
charms/precise/rabbitmq-worker/config.yaml (+22/-0)
charms/precise/rabbitmq-worker/hooks/hooks.py (+34/-2)
juju-deployer/branch-source-builder.yaml.tmpl (+6/-2)
To merge this branch: bzr merge lp:~fginther/uci-engine/rabbit-worker-nrpe-2
Reviewer Review Type Date Requested Status
Canonical CI Engineering Pending
Review via email: mp+228036@code.launchpad.net

This proposal has been superseded by a proposal from 2014-07-24.

Commit message

Add support for rabbitmq-worker nagios checks and an example bsbuilder check.

Description of the change

Add support for rabbitmq-worker nagios checks and an example bsbuilder check.

To post a comment you must log in.

Unmerged revisions

707. By Francis Ginther

Add support for rabbitmq-worker nagios checks and an example bsbuilder check.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'branch-source-builder/bin'
2=== added file 'branch-source-builder/bin/check_bsbuilder.py'
3--- branch-source-builder/bin/check_bsbuilder.py 1970-01-01 00:00:00 +0000
4+++ branch-source-builder/bin/check_bsbuilder.py 2014-07-24 04:36:31 +0000
5@@ -0,0 +1,35 @@
6+#!/usr/bin/env python
7+# Ubuntu CI Engine
8+# Copyright 2014 Canonical Ltd.
9+
10+# This program is free software: you can redistribute it and/or modify it
11+# under the terms of the GNU Affero General Public License version 3, as
12+# published by the Free Software Foundation.
13+
14+# This program is distributed in the hope that it will be useful, but
15+# WITHOUT ANY WARRANTY; without even the implied warranties of
16+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17+# PURPOSE. See the GNU Affero General Public License for more details.
18+
19+# You should have received a copy of the GNU Affero General Public License
20+# along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
22+
23+from ci_utils.health_check import HealthCheck
24+
25+
26+def check_bsbuilder():
27+ return True, None
28+
29+
30+def main():
31+ with HealthCheck('bsbuilder') as check:
32+ result, output = check_bsbuilder()
33+ if result:
34+ check.write_result_ok()
35+ else:
36+ check.write_result_failed(output)
37+
38+
39+if __name__ == "__main__":
40+ main()
41
42=== modified file 'charms/precise/rabbitmq-worker/config.yaml'
43--- charms/precise/rabbitmq-worker/config.yaml 2014-07-19 03:06:33 +0000
44+++ charms/precise/rabbitmq-worker/config.yaml 2014-07-24 04:36:31 +0000
45@@ -76,6 +76,28 @@
46 install_keys: |
47 - ""
48 - ""
49+
50+ # Required by 'nrpe-external-master' interface.
51+ nagios_context:
52+ default: "rabbitmq-worker"
53+ type: string
54+ description: >
55+ Used by the nrpe-external-master subordinate charm.
56+ A string that will be prepended to instance name to set the host
57+ name in nagios. So for instance the hostname would be something
58+ like:
59+ juju-postgresql-0
60+ If you\'re running multiple environments with the same services in them
61+ this allows you to differentiate between them.
62+ nagios_check_http_params:
63+ default: ""
64+ type: string
65+ description: The parameters to pass to the nrpe plugin check_http.
66+ nagios_check_health_params:
67+ default: ""
68+ type: string
69+ description: The parameters to pass to the nrpe plugin check_health.
70+
71 cron_cmd:
72 type: string
73 default: ""
74
75=== modified file 'charms/precise/rabbitmq-worker/hooks/hooks.py'
76--- charms/precise/rabbitmq-worker/hooks/hooks.py 2014-07-23 12:09:59 +0000
77+++ charms/precise/rabbitmq-worker/hooks/hooks.py 2014-07-24 04:36:31 +0000
78@@ -23,6 +23,8 @@
79 import tempfile
80 import textwrap
81
82+from charmhelpers.contrib.charmsupport.nrpe import NRPE
83+
84 import charmhelpers.core.hookenv
85 import charmhelpers.core.host
86 import charmhelpers.fetch
87@@ -207,8 +209,8 @@
88 'schedule': config['cron_schedule'],
89 'user': config['cron_user'],
90 'logs_dir': _log_dir(),
91- 'command': os.path.abspath(
92- os.path.join(_code_dir(), config['cron_cmd'])),
93+ 'code_dir': _code_dir(),
94+ 'command': config['cron_cmd'],
95 }
96 template = _get_template('cron.tmpl')
97 with open(cron_path, 'w') as fp:
98@@ -220,6 +222,29 @@
99 juju_info('Cron configuration updated ({}).'.format(cron_path))
100
101
102+def _update_nrpe_config():
103+ nrpe_compat = NRPE()
104+ config = charmhelpers.core.hookenv.config()
105+ health_script_path = os.path.join(
106+ _code_dir(config), 'bin', 'engine_health.py')
107+ conf = nrpe_compat.config
108+ check_http_params = conf.get('nagios_check_http_params')
109+ if check_http_params:
110+ nrpe_compat.add_check(
111+ shortname='rabbitmq-worker',
112+ description='Check RabbitMQ Service',
113+ check_cmd='check_http %s' % check_http_params
114+ )
115+ check_health_params = conf.get('nagios_check_health_params')
116+ if check_health_params:
117+ nrpe_compat.add_check(
118+ shortname='engine_health',
119+ description='Check Engine Health',
120+ check_cmd='%s %s' % (health_script_path, check_health_params)
121+ )
122+ nrpe_compat.write()
123+
124+
125 @hooks.hook()
126 def config_changed():
127 charmhelpers.core.host.mkdir(_code_dir(''))
128@@ -228,6 +253,7 @@
129 _create_upstart()
130 todelete = handle_code()
131 _update_cron_config()
132+ _update_nrpe_config()
133
134 _restart_upstart()
135
136@@ -345,5 +371,11 @@
137 charmhelpers.core.hookenv.relation_set(None, {'status-url': url})
138
139
140+@hooks.hook('nrpe-external-master-relation-changed')
141+@hooks.hook()
142+def nrpe_external_master_relation_joined():
143+ _update_nrpe_config()
144+
145+
146 if __name__ == '__main__':
147 hooks.execute(sys.argv)
148
149=== modified file 'juju-deployer/branch-source-builder.yaml.tmpl'
150--- juju-deployer/branch-source-builder.yaml.tmpl 2014-07-23 13:49:58 +0000
151+++ juju-deployer/branch-source-builder.yaml.tmpl 2014-07-24 04:36:31 +0000
152@@ -14,9 +14,13 @@
153 - ${CI_PPA}
154 install_keys: |
155 - ""
156- cron_cmd:
157- cron_schedule: "0 * * * *"
158+ cron_cmd: ./run-python ./branch-source-builder/bin/check_bsbuilder.py
159+ cron_schedule: "* * * * *"
160 cron_user: root
161+ nagios_context: ci-airline-staging
162+ nagios_check_health_params: -t 120 /var/cache/bsbuilder.health
163+ nagios_check_http_params: -H gatekeeper -I 127.0.0.1 -e '
164+ 200 OK' --url='/api/v1/' -p 8080
165 ci-airline-bsb-keys:
166 charm: key-secret-subordinate
167 options:

Subscribers

People subscribed via source and target branches