Merge lp:~paulgear/charm-helpers/nrpe-service-immediate-check into lp:charm-helpers
| Status: | Merged |
|---|---|
| Merged at revision: | 700 |
| Proposed branch: | lp:~paulgear/charm-helpers/nrpe-service-immediate-check |
| Merge into: | lp:charm-helpers |
| Diff against target: |
71 lines (+21/-10) 2 files modified
charmhelpers/contrib/charmsupport/nrpe.py (+19/-10) tests/contrib/charmsupport/test_nrpe.py (+2/-0) |
| To merge this branch: | bzr merge lp:~paulgear/charm-helpers/nrpe-service-immediate-check |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Stuart Bishop | 2016-07-21 | Approve on 2017-03-02 | |
| charmers | 2016-07-21 | Pending | |
|
Review via email:
|
|||
Description of the Change
Add an option for immediate execution of nrpe service checks. This is necessary because (for sysvinit-based services) the cron file installed only runs the check every 5 minutes.
If a nagios service check is created but the check does not fire before the end of a CI run which does nagios checks at the end, the nagios check will return an error and the CI run will fail.
This change works around that by allowing a charm to specify that a check should be run immediately, to ensure the check file is created.
| Paul Gear (paulgear) wrote : | # |
Updated with Stuart's recommendations.
| Stuart Bishop (stub) wrote : | # |
=======
ERROR: tests.contrib.
-------
_StringException: Traceback (most recent call last):
File "/home/
nrpe.
File "/home/
os.
OSError: [Errno 2] No such file or directory: '/var/lib/
| Stuart Bishop (stub) wrote : | # |
I've fixed the test
| Ryan Beisner (1chb1n) wrote : | # |
After syncing this into the Glance charm, we see failure:
2017-03-03 22:22:19 INFO worker.uniter.jujuc server.go:172 running hook tool "juju-log" ["Check command not found: check_status_
2017-03-03 22:22:19 DEBUG worker.uniter.jujuc server.go:173 hook context id "glance/
2017-03-03 22:22:19 INFO juju-log Check command not found: check_status_
2017-03-03 22:22:19 INFO config-changed Traceback (most recent call last):
2017-03-03 22:22:19 INFO config-changed File "/var/lib/
2017-03-03 22:22:19 INFO config-changed hooks.execute(
2017-03-03 22:22:19 INFO config-changed File "/var/lib/
2017-03-03 22:22:19 INFO config-changed self._hooks[
2017-03-03 22:22:19 INFO config-changed File "/var/lib/
2017-03-03 22:22:19 INFO config-changed restart_functions)
2017-03-03 22:22:19 INFO config-changed File "/var/lib/
2017-03-03 22:22:19 INFO config-changed r = lambda_f()
2017-03-03 22:22:19 INFO config-changed File "/var/lib/
2017-03-03 22:22:19 INFO config-changed (lambda: f(*args, **kwargs)), restart_map, stopstart,
2017-03-03 22:22:19 INFO config-changed File "/var/lib/
2017-03-03 22:22:19 INFO config-changed return f(*args, **kwargs)
2017-03-03 22:22:19 INFO config-changed File "/var/lib/
2017-03-03 22:22:19 INFO config-changed update_
2017-03-03 22:22:19 INFO config-changed File "/var/lib/
2017-03-03 22:22:19 INFO config-changed nrpe.add_
2017-03-03 22:22:19 INFO config-changed File "/var/lib/
2017-03-03 22:22:19 INFO config-changed f = open(checkpath, 'w')
2017-03-03 22:22:19 INFO config-changed IOError: [Errno 2] No such file or directory: '/var/lib/


Minor inline comments.
I think the default should be immediate_ check=True. Charms need to explicitly call add_init_ service_ checks( ), and any charm doing that for a bogus service that hangs on the status check is already broken. It is better to discover that now rather than later when there are a zillion hung /usr/local/ lib/nagios/ plugins/ check_exit_ status. pl processes. Or just add timeout(1) to the command line.