Merge lp:~macgreagoir/charms/precise/nrpe-external-master/load into lp:charms/nrpe-external-master

Proposed by Mick Gregg
Status: Merged
Merged at revision: 41
Proposed branch: lp:~macgreagoir/charms/precise/nrpe-external-master/load
Merge into: lp:charms/nrpe-external-master
Diff against target: 50 lines (+18/-3)
2 files modified
config.yaml (+6/-2)
hooks/config-changed (+12/-1)
To merge this branch: bzr merge lp:~macgreagoir/charms/precise/nrpe-external-master/load
Reviewer Review Type Date Requested Status
Matt Bruzek (community) Approve
Charles Butler (community) Needs Information
Alvaro Uria (community) Approve
Review via email: mp+258034@code.launchpad.net

Commit message

[macgreagoir] Make it possible to autogenerate check_load parameters.

To post a comment you must log in.
Revision history for this message
Alvaro Uria (aluria) wrote :

lgtm

review: Approve
Revision history for this message
Charles Butler (lazypower) wrote :

Greetings Mick Gregg

I took some time to review this MP, and I really like the thought of the NRPE master generating the proper config for checks. While this looks great, there appears to be a slight issue with the code.

When testing, I got some errors on the config-changed hook that surface around line:

 56 let "LOAD_WARN = $PROC_COUNT / 2"

When the unit only has a single processor. I've proposed a branch for merging into yours. If you feel this is a good patch to resolve the issue, feel free to merge it and ping me for a follow up express review/merge.

If you have any questions/comments/concerns about the review contact us in #juju on irc.freenode.net or email the mailing list <email address hidden>, or ask a question tagged with "juju" on http://askubuntu.com.

review: Needs Information
Revision history for this message
Charles Butler (lazypower) wrote :

Ah, and I realized I didn't link to that branch, which is here: lp:~lazypower/charms/precise/nrpe-external-master/patch-auto-config

Revision history for this message
Mick Gregg (macgreagoir) wrote :

Charles, thanks for the review. I could only see an empty diff in your MP, sorry. I've committed a new change that I hope does something similar to what you meant to propose.

Revision history for this message
Matt Bruzek (mbruzek) wrote :

Hello Mick,

Thanks for submitting this fix to the nrpe-external-master charm. The LOAD_WARN now evalutes to 1 when PROC_COUNT = 1.

I ran your branch on our CI system, and the tests pass. The CI system runs instances with 2 processors. The tests for the nrpe-external-master charm are very basic stand up charm test. As a user of NRPE it would be much appreciated if you could add better tests to the amulet test on your next commit. I would suggest writing tests that at least test the value of the load were set correctly

This change looks good to me, so I am going to merge it with the recommended version of the charm in the charm store. Thanks for the contribution!

review: Approve
Revision history for this message
Mick Gregg (macgreagoir) wrote :

Mark,

Thanks for the review. It didn't appear to merge, so I've set the status back to 'Needs review'. Do you mind taking a look at the merge again, please.

Cheers,

Mick

Revision history for this message
Matt Bruzek (mbruzek) wrote :

Mick,

Sorry about the mistake, I thought the code was merged. The code is merged now. Thanks for the follow up. Many apologies for my mistake.

Revision history for this message
Mick Gregg (macgreagoir) wrote :

Matt, no worries at all. Thanks again.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2014-05-27 10:36:57 +0000
3+++ config.yaml 2015-05-21 15:57:10 +0000
4@@ -49,9 +49,13 @@
5 description: Number of processes check or 'auto' for the charm to generate
6 thresholds based on processor count
7 load:
8- default: "-w 8,8,8 -c 15,15,15"
9+ default: "auto"
10 type: string
11- description: Load check
12+ description: |
13+ Load check. Parameters for the check_load script or 'auto' to allow the
14+ charm to generate parameters based on the processor count.
15+ For example, '-w 8,8,8 -c 15,15,15' sets the WARNING threshold to 8 and
16+ CRITICAL to 15.
17 users:
18 default: "-w 20 -c 25"
19 type: string
20
21=== modified file 'hooks/config-changed'
22--- hooks/config-changed 2014-11-20 04:35:17 +0000
23+++ hooks/config-changed 2015-05-21 15:57:10 +0000
24@@ -51,6 +51,17 @@
25 PROC_THRESHOLDS=$PROCS
26 fi
27
28+if [[ "$LOAD" == "auto" ]]; then
29+ PROC_COUNT=$(nproc)
30+ let "LOAD_WARN = $PROC_COUNT / 2 + $PROC_COUNT % 2"
31+ let "LOAD_CRIT = $PROC_COUNT"
32+ LOAD_W="-w ${LOAD_WARN},${LOAD_WARN},${LOAD_WARN}"
33+ LOAD_C="-c ${LOAD_CRIT},${LOAD_CRIT},${LOAD_CRIT}"
34+ LOAD_THRESHOLDS="$LOAD_W $LOAD_C"
35+else
36+ LOAD_THRESHOLDS=$LOAD
37+fi
38+
39 echo "# Root disk" > /etc/nagios/nrpe.d/check_disk_root.cfg
40 echo "command[check_disk_root]=/usr/lib/nagios/plugins/check_disk ${DISK_ROOT} -p /" >> /etc/nagios/nrpe.d/check_disk_root.cfg
41
42@@ -61,7 +72,7 @@
43 echo "command[check_total_procs]=/usr/lib/nagios/plugins/check_procs ${PROC_THRESHOLDS}" >> /etc/nagios/nrpe.d/check_total_procs.cfg
44
45 echo "# System Load" > /etc/nagios/nrpe.d/check_load.cfg
46-echo "command[check_load]=/usr/lib/nagios/plugins/check_load ${LOAD}" >> /etc/nagios/nrpe.d/check_load.cfg
47+echo "command[check_load]=/usr/lib/nagios/plugins/check_load ${LOAD_THRESHOLDS}" >> /etc/nagios/nrpe.d/check_load.cfg
48
49 echo "# Number of Users" > /etc/nagios/nrpe.d/check_users.cfg
50 echo "command[check_users]=/usr/lib/nagios/plugins/check_users ${USERS}" >> /etc/nagios/nrpe.d/check_users.cfg

Subscribers

People subscribed via source and target branches

to all changes: