Merge lp:~chris-gondolin/charms/precise/nrpe-external-master/trunk into lp:charms/nrpe-external-master

Proposed by Chris Stratford
Status: Work in progress
Proposed branch: lp:~chris-gondolin/charms/precise/nrpe-external-master/trunk
Merge into: lp:charms/nrpe-external-master
Diff against target: 136 lines (+82/-0)
5 files modified
config.yaml (+8/-0)
files/check_conntrack.sh (+48/-0)
hooks/config-changed (+11/-0)
hooks/install (+3/-0)
templates/service.cfg.tmpl (+12/-0)
To merge this branch: bzr merge lp:~chris-gondolin/charms/precise/nrpe-external-master/trunk
Reviewer Review Type Date Requested Status
Charles Butler (community) Needs Fixing
Review via email: mp+227530@code.launchpad.net

Description of the change

Added a conntrack usage check to warn when nf_conntrack gets too near its limits (always returns OK if conntrack isn't in use on the unit)

To post a comment you must log in.
Revision history for this message
Charles Butler (lazypower) wrote :

Thank you for the submission Chris,

I took some time to review your changes and I have the following notes:

The charm as it stands today does not pass charm proof. there is a a missing category in the metadata.yaml, and no icon.svg - while this is not related to your change, could you possibly add those to the update to assist in future reviews?

I see that you added 2 configuration options: conntrack, and conntrackservice group - however there were no documentation updates to cover these configuration options. We request that any updates to charm configuration be accompanied by documentation edits to cover new items being added to the charm, and if this effects deployment, a deployment example (or scenario) where these configuration options would be used. I'm going to superimpose a temporarly blocker pending the README update.

The code quality is good, and I appreciate the cheetah templates being used. This is a great feature merge for the nrpe-external-master charm.

Thanks again for the submission. I'm going to change status of this MP to "needs work" and when you're ready for another review please click the "Request another review" button in the upper right hand corner of the commit message.

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 Fixing

Unmerged revisions

32. By Chris Stratford

[chriss] Add conntrack usage check for RT#70035

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 2014-07-21 11:22:52 +0000
4@@ -60,6 +60,14 @@
5 default: "-w 90% -c 75%"
6 type: string
7 description: Swap check
8+ conntrack:
9+ default: "-w 80 -c 90"
10+ type: string
11+ description: Conntrack check
12+ conntrack_servicegroup:
13+ default: "prompt-critical"
14+ type: string
15+ description: Conntrack nagios servicegroup
16 hostgroups:
17 default: ""
18 type: string
19
20=== added file 'files/check_conntrack.sh'
21--- files/check_conntrack.sh 1970-01-01 00:00:00 +0000
22+++ files/check_conntrack.sh 2014-07-21 11:22:52 +0000
23@@ -0,0 +1,48 @@
24+#!/bin/bash
25+#
26+#-------------------------------------------------------#
27+# This file is Juju managed - do not make local changes #
28+#-------------------------------------------------------#
29+#
30+# Check we're not close to conntrack_max limit
31+
32+set -u
33+
34+if [ ! -e /proc/sys/net/netfilter/nf_conntrack_max ]; then
35+ echo "OK conntrack not in use"
36+ exit 0
37+fi
38+
39+max=$(cat /proc/sys/net/netfilter/nf_conntrack_max)
40+current=$(cat /proc/sys/net/netfilter/nf_conntrack_count)
41+warn=""
42+crit=""
43+
44+while getopts "w:c:" opts; do
45+ case "${opts}" in
46+ w)
47+ warn=${OPTARG}
48+ ;;
49+ c)
50+ crit=${OPTARG}
51+ ;;
52+ esac
53+done
54+
55+if [ -z "${warn}" -o -z "${crit}" ]; then
56+ echo "Usage: check_conntrack -w warn -c crit"
57+ exit 1
58+fi
59+
60+usage=$(((100 * ${current}) / ${max}))
61+
62+if [ ${usage} -gt ${crit} ]; then
63+ echo "CRITICAL conntrack at ${usage}%"
64+ exit 2
65+elif [ ${usage} -gt ${warn} ]; then
66+ echo "WARNING conntrack at ${usage}%"
67+ exit 1
68+fi
69+
70+echo "OK conntrack at ${usage}%"
71+exit 0
72
73=== modified file 'hooks/config-changed'
74--- hooks/config-changed 2014-05-27 10:36:57 +0000
75+++ hooks/config-changed 2014-07-21 11:22:52 +0000
76@@ -48,6 +48,7 @@
77 LOAD=$(config-get load)
78 USERS=$(config-get users)
79 SWAP=$(config-get swap)
80+CONNTRACK=$(config-get conntrack)
81
82 if [[ "$PROCS" == "auto" ]]; then
83 PROC_COUNT=$(nproc)
84@@ -76,6 +77,9 @@
85 echo "# Swap" > /etc/nagios/nrpe.d/check_swap.cfg
86 echo "command[check_swap]=/usr/lib/nagios/plugins/check_swap ${SWAP}" >> /etc/nagios/nrpe.d/check_swap.cfg
87
88+echo "# Conntrack usage" > /etc/nagios/nrpe.d/check_conntrack.cfg
89+echo "command[check_conntrack]=/usr/local/lib/nagios/plugins/check_conntrack.sh ${CONNTRACK}" >> /etc/nagios/nrpe.d/check_conntrack.cfg
90+
91 #------------------------------------------------------
92 # Host check
93 #------------------------------------------------------
94@@ -115,4 +119,11 @@
95 # Service specific checks
96 #------------------------------------------------------
97
98+export DESCRIPTION="Check conntrack usage"
99+export COMMAND="check_nrpe!check_conntrack"
100+export SERVICEGROUPS=$(config-get conntrack_servicegroup)
101+cheetah fill --env --oext compiled templates/service.cfg.tmpl
102+rm -f /var/lib/nagios/export/service__conntrack.cfg
103+cp templates/service.cfg.compiled /var/lib/nagios/export/service__${NAGIOS_HOSTNAME}_check_conntrack.cfg
104+
105 service nagios-nrpe-server reload
106
107=== modified file 'hooks/install'
108--- hooks/install 2014-03-11 13:57:58 +0000
109+++ hooks/install 2014-07-21 11:22:52 +0000
110@@ -14,6 +14,9 @@
111 cp files/nagios_plugin.py /usr/lib/nagios/plugins/nagios_plugin.py
112 ln -fs /usr/lib/nagios/plugins/nagios_plugin.py /usr/local/lib/nagios/plugins/nagios_plugin.py
113
114+cp files/check_conntrack.sh /usr/lib/nagios/plugins/check_conntrack.sh
115+ln -fs /usr/lib/nagios/plugins/check_conntrack.sh /usr/local/lib/nagios/plugins/check_conntrack.sh
116+
117 cp files/default_rsync /etc/default/rsync
118 if [[ -d /etc/rsyncd.d ]]; then
119 export RSYNC_MODULE_ONLY=1
120
121=== added file 'templates/service.cfg.tmpl'
122--- templates/service.cfg.tmpl 1970-01-01 00:00:00 +0000
123+++ templates/service.cfg.tmpl 2014-07-21 11:22:52 +0000
124@@ -0,0 +1,12 @@
125+#---------------------------------------------------
126+# This file is Juju managed
127+#--------------------------------------------------
128+
129+define service {
130+ use ${HOSTCHECK_INHERIT}
131+ host_name ${NAGIOS_HOSTNAME}
132+ service_description ${DESCRIPTION}
133+ check_command ${COMMAND}
134+ servicegroups ${SERVICEGROUPS}
135+}
136+

Subscribers

People subscribed via source and target branches

to all changes: