Merge lp:~cprov/charms/trusty/tanuki-spec-manager/negate-poller-check into lp:~tanuki/charms/trusty/tanuki-spec-manager/trunk

Proposed by Celso Providelo on 2015-09-21
Status: Merged
Approved by: Guillermo Gonzalez on 2015-09-21
Approved revision: 28
Merged at revision: 28
Proposed branch: lp:~cprov/charms/trusty/tanuki-spec-manager/negate-poller-check
Merge into: lp:~tanuki/charms/trusty/tanuki-spec-manager/trunk
Diff against target: 47 lines (+21/-14)
1 file modified
hooks/actions.py (+21/-14)
To merge this branch: bzr merge lp:~cprov/charms/trusty/tanuki-spec-manager/negate-poller-check
Reviewer Review Type Date Requested Status
Guillermo Gonzalez 2015-09-21 Approve on 2015-09-21
Review via email: mp+271823@code.launchpad.net

Commit message

Negate store-poller nagios check when it gets disabled.

Description of the change

Negate store-poller nagios check when it gets disabled.

To post a comment you must log in.
Guillermo Gonzalez (verterok) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/actions.py'
2--- hooks/actions.py 2015-09-17 05:20:25 +0000
3+++ hooks/actions.py 2015-09-21 14:53:31 +0000
4@@ -323,22 +323,29 @@
5 check_cmd="/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -p 8000 -e ' 200 OK' -u '/nagios/postgres'",
6 )
7
8+ # Builds a nagios check command to verify `store-poller` log file age
9+ # according the service configuration.
10+ environment = hookenv.Config()['environment']
11+ log_path = os.path.join(LOG_DIR, 'store-poller.log')
12+ max_age_seconds = int(config['store_poller_nagios_file_age_max_minutes']) * 60
13+ check_cmd = "/usr/lib/nagios/plugins/check_file_age -w {0} -c {0} -f {1}".format(
14+ max_age_seconds,
15+ log_path,
16+ )
17+
18+ # If `store-poller` cronscript is enabled in this unit, ensure the log file
19+ # exists. Otherwise 'negate' standard check (verifies cronscript is not running).
20 config_unit = config.get('store_poller_unit')
21 local_unit = int(hookenv.local_unit().split('/')[-1])
22-
23 if local_unit == config_unit:
24- environment = hookenv.Config()['environment']
25- log_path = os.path.join(LOG_DIR, 'store-poller.log')
26- # Create the file now, so the nagios check doesn't fail right after
27- # we've completed the deployment.
28 host.write_file(log_path,"", "www-data", "www-data", perms=0o660)
29- max_age_seconds = int(config['store_poller_nagios_file_age_max_minutes']) * 60
30- nrpe_compat.add_check(
31- shortname="store_poller_check",
32- description="Store poller check.",
33- check_cmd="/usr/lib/nagios/plugins/check_file_age -w {0} -c {0} -f {1}".format(
34- max_age_seconds,
35- log_path,
36- )
37- )
38+ else:
39+ check_cmd = "negate {}".format(check_cmd)
40+
41+ nrpe_compat.add_check(
42+ shortname="store_poller_check",
43+ description="Store poller check.",
44+ check_cmd=check_cmd
45+ )
46+
47 nrpe_compat.write()

Subscribers

People subscribed via source and target branches

to all changes: