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
Prerequisite: lp:~ursinha/uci-engine/cron-chdir-support
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+228039@code.launchpad.net

This proposal supersedes a proposal from 2014-07-24.

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.
Revision history for this message
Evan (ev) wrote :

Minor nit that I keep seeing pop up as people copy around the nagios check_http parameters.

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
=== added directory 'branch-source-builder/bin'
=== added file 'branch-source-builder/bin/check_bsbuilder.py'
--- branch-source-builder/bin/check_bsbuilder.py 1970-01-01 00:00:00 +0000
+++ branch-source-builder/bin/check_bsbuilder.py 2014-07-24 04:51:27 +0000
@@ -0,0 +1,35 @@
1#!/usr/bin/env python
2# Ubuntu CI Engine
3# Copyright 2014 Canonical Ltd.
4
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3, as
7# published by the Free Software Foundation.
8
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU Affero General Public License for more details.
13
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
18from ci_utils.health_check import HealthCheck
19
20
21def check_bsbuilder():
22 return True, None
23
24
25def main():
26 with HealthCheck('bsbuilder') as check:
27 result, output = check_bsbuilder()
28 if result:
29 check.write_result_ok()
30 else:
31 check.write_result_failed(output)
32
33
34if __name__ == "__main__":
35 main()
036
=== modified file 'charms/precise/rabbitmq-worker/config.yaml'
--- charms/precise/rabbitmq-worker/config.yaml 2014-07-19 03:06:33 +0000
+++ charms/precise/rabbitmq-worker/config.yaml 2014-07-24 04:51:27 +0000
@@ -76,6 +76,28 @@
76 install_keys: |76 install_keys: |
77 - ""77 - ""
78 - ""78 - ""
79
80 # Required by 'nrpe-external-master' interface.
81 nagios_context:
82 default: "rabbitmq-worker"
83 type: string
84 description: >
85 Used by the nrpe-external-master subordinate charm.
86 A string that will be prepended to instance name to set the host
87 name in nagios. So for instance the hostname would be something
88 like:
89 juju-postgresql-0
90 If you\'re running multiple environments with the same services in them
91 this allows you to differentiate between them.
92 nagios_check_http_params:
93 default: ""
94 type: string
95 description: The parameters to pass to the nrpe plugin check_http.
96 nagios_check_health_params:
97 default: ""
98 type: string
99 description: The parameters to pass to the nrpe plugin check_health.
100
79 cron_cmd:101 cron_cmd:
80 type: string102 type: string
81 default: ""103 default: ""
82104
=== modified file 'charms/precise/rabbitmq-worker/hooks/hooks.py'
--- charms/precise/rabbitmq-worker/hooks/hooks.py 2014-07-23 12:09:59 +0000
+++ charms/precise/rabbitmq-worker/hooks/hooks.py 2014-07-24 04:51:27 +0000
@@ -23,6 +23,8 @@
23import tempfile23import tempfile
24import textwrap24import textwrap
2525
26from charmhelpers.contrib.charmsupport.nrpe import NRPE
27
26import charmhelpers.core.hookenv28import charmhelpers.core.hookenv
27import charmhelpers.core.host29import charmhelpers.core.host
28import charmhelpers.fetch30import charmhelpers.fetch
@@ -207,8 +209,8 @@
207 'schedule': config['cron_schedule'],209 'schedule': config['cron_schedule'],
208 'user': config['cron_user'],210 'user': config['cron_user'],
209 'logs_dir': _log_dir(),211 'logs_dir': _log_dir(),
210 'command': os.path.abspath(212 'code_dir': _code_dir(),
211 os.path.join(_code_dir(), config['cron_cmd'])),213 'command': config['cron_cmd'],
212 }214 }
213 template = _get_template('cron.tmpl')215 template = _get_template('cron.tmpl')
214 with open(cron_path, 'w') as fp:216 with open(cron_path, 'w') as fp:
@@ -220,6 +222,29 @@
220 juju_info('Cron configuration updated ({}).'.format(cron_path))222 juju_info('Cron configuration updated ({}).'.format(cron_path))
221223
222224
225def _update_nrpe_config():
226 nrpe_compat = NRPE()
227 config = charmhelpers.core.hookenv.config()
228 health_script_path = os.path.join(
229 _code_dir(config), 'bin', 'engine_health.py')
230 conf = nrpe_compat.config
231 check_http_params = conf.get('nagios_check_http_params')
232 if check_http_params:
233 nrpe_compat.add_check(
234 shortname='rabbitmq-worker',
235 description='Check RabbitMQ Service',
236 check_cmd='check_http %s' % check_http_params
237 )
238 check_health_params = conf.get('nagios_check_health_params')
239 if check_health_params:
240 nrpe_compat.add_check(
241 shortname='engine_health',
242 description='Check Engine Health',
243 check_cmd='%s %s' % (health_script_path, check_health_params)
244 )
245 nrpe_compat.write()
246
247
223@hooks.hook()248@hooks.hook()
224def config_changed():249def config_changed():
225 charmhelpers.core.host.mkdir(_code_dir(''))250 charmhelpers.core.host.mkdir(_code_dir(''))
@@ -228,6 +253,7 @@
228 _create_upstart()253 _create_upstart()
229 todelete = handle_code()254 todelete = handle_code()
230 _update_cron_config()255 _update_cron_config()
256 _update_nrpe_config()
231257
232 _restart_upstart()258 _restart_upstart()
233259
@@ -345,5 +371,11 @@
345 charmhelpers.core.hookenv.relation_set(None, {'status-url': url})371 charmhelpers.core.hookenv.relation_set(None, {'status-url': url})
346372
347373
374@hooks.hook('nrpe-external-master-relation-changed')
375@hooks.hook()
376def nrpe_external_master_relation_joined():
377 _update_nrpe_config()
378
379
348if __name__ == '__main__':380if __name__ == '__main__':
349 hooks.execute(sys.argv)381 hooks.execute(sys.argv)
350382
=== modified file 'juju-deployer/branch-source-builder.yaml.tmpl'
--- juju-deployer/branch-source-builder.yaml.tmpl 2014-07-23 13:49:58 +0000
+++ juju-deployer/branch-source-builder.yaml.tmpl 2014-07-24 04:51:27 +0000
@@ -14,9 +14,13 @@
14 - ${CI_PPA}14 - ${CI_PPA}
15 install_keys: |15 install_keys: |
16 - ""16 - ""
17 cron_cmd:17 cron_cmd: ./run-python ./branch-source-builder/bin/check_bsbuilder.py
18 cron_schedule: "0 * * * *"18 cron_schedule: "* * * * *"
19 cron_user: root19 cron_user: root
20 nagios_context: ci-airline-staging
21 nagios_check_health_params: -t 120 /var/cache/bsbuilder.health
22 nagios_check_http_params: -H gatekeeper -I 127.0.0.1 -e '
23 200 OK' --url='/api/v1/' -p 8080
20 ci-airline-bsb-keys:24 ci-airline-bsb-keys:
21 charm: key-secret-subordinate25 charm: key-secret-subordinate
22 options:26 options:

Subscribers

People subscribed via source and target branches