Code review comment for lp://staging/~mbruzek/charms/trusty/apache2/nagios_extra_check_https

Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

Hey Samuele, I get your point about multiple host checks becoming unwieldy in 1 string, but I'm still off-put by having 2 config opts for this. How do you feel about testing nagios_check_http_params for "yamlness", and looping over the yaml if true, or treating it as a string if false? Something like:

--- hooks/hooks.py 2015-04-15 20:23:01 +0000
+++ hooks/hooks.py 2015-10-29 18:27:20 +0000
@@ -432,11 +432,21 @@
     conf = nrpe_compat.config
     check_http_params = conf.get('nagios_check_http_params')
     if check_http_params:
- nrpe_compat.add_check(
- shortname='vhost',
- description='Check Virtual Host',
- check_cmd='check_http %s' % check_http_params
- )
+ for check_http in yaml.safe_load(check_http_params):
+ try:
+ name = check_http['name']
+ nrpe_compat.add_check(
+ shortname=name,
+ description=check_http.get('description', name),
+ check_cmd='check_http %s' % check_http['params']
+ )
+ except TypeError:
+ nrpe_compat.add_check(
+ shortname='vhost',
+ description='Check Virtual Host',
+ check_cmd='check_http %s' % check_http_params
+ )
+ break
     nrpe_compat.write()

« Back to merge proposal