Merge lp:~thomir-deactivatedaccount/charms/trusty/tanuki-spec-manager/trunk-fix-ng-alert into lp:~tanuki/charms/trusty/tanuki-spec-manager/trunk

Proposed by Thomi Richards
Status: Merged
Approved by: Celso Providelo
Approved revision: 29
Merged at revision: 29
Proposed branch: lp:~thomir-deactivatedaccount/charms/trusty/tanuki-spec-manager/trunk-fix-ng-alert
Merge into: lp:~tanuki/charms/trusty/tanuki-spec-manager/trunk
Diff against target: 31 lines (+7/-3)
1 file modified
hooks/actions.py (+7/-3)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/charms/trusty/tanuki-spec-manager/trunk-fix-ng-alert
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Review via email: mp+271908@code.launchpad.net

Commit message

Fix a race condition in the nagios check for the store poller.

Description of the change

Fix a race condition in the nagios check for the store poller.

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

Thomi, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/actions.py'
--- hooks/actions.py 2015-09-21 14:51:30 +0000
+++ hooks/actions.py 2015-09-22 04:33:53 +0000
@@ -325,7 +325,6 @@
325325
326 # Builds a nagios check command to verify `store-poller` log file age326 # Builds a nagios check command to verify `store-poller` log file age
327 # according the service configuration.327 # according the service configuration.
328 environment = hookenv.Config()['environment']
329 log_path = os.path.join(LOG_DIR, 'store-poller.log')328 log_path = os.path.join(LOG_DIR, 'store-poller.log')
330 max_age_seconds = int(config['store_poller_nagios_file_age_max_minutes']) * 60329 max_age_seconds = int(config['store_poller_nagios_file_age_max_minutes']) * 60
331 check_cmd = "/usr/lib/nagios/plugins/check_file_age -w {0} -c {0} -f {1}".format(330 check_cmd = "/usr/lib/nagios/plugins/check_file_age -w {0} -c {0} -f {1}".format(
@@ -334,12 +333,17 @@
334 )333 )
335334
336 # If `store-poller` cronscript is enabled in this unit, ensure the log file335 # If `store-poller` cronscript is enabled in this unit, ensure the log file
337 # exists. Otherwise 'negate' standard check (verifies cronscript is not running). 336 # exists. Otherwise 'negate' standard check (verifies cronscript is not running).
338 config_unit = config.get('store_poller_unit')337 config_unit = config.get('store_poller_unit')
339 local_unit = int(hookenv.local_unit().split('/')[-1])338 local_unit = int(hookenv.local_unit().split('/')[-1])
340 if local_unit == config_unit:339 if local_unit == config_unit:
341 host.write_file(log_path,"", "www-data", "www-data", perms=0o660)340 host.write_file(log_path, "", "www-data", "www-data", perms=0o660)
342 else:341 else:
342 # The poller might have been run on this unit before, possibly before
343 # the timeout period. To avoid spurious alerts, we rename the file if
344 # it exists.
345 if os.path.exists(log_path):
346 os.rename(log_path, log_path + ".old")
343 check_cmd = "negate {}".format(check_cmd)347 check_cmd = "negate {}".format(check_cmd)
344348
345 nrpe_compat.add_check(349 nrpe_compat.add_check(

Subscribers

People subscribed via source and target branches

to all changes: