Merge lp:~jjo/charm-helpers/fix-check_haproxy_sh-lp1521279 into lp:charm-helpers

Proposed by JuanJo Ciarlante
Status: Merged
Merged at revision: 511
Proposed branch: lp:~jjo/charm-helpers/fix-check_haproxy_sh-lp1521279
Merge into: lp:charm-helpers
Diff against target: 32 lines (+7/-5)
1 file modified
charmhelpers/contrib/openstack/files/check_haproxy.sh (+7/-5)
To merge this branch: bzr merge lp:~jjo/charm-helpers/fix-check_haproxy_sh-lp1521279
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Felipe Reyes (community) Approve
Review via email: mp+279020@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Felipe Reyes (freyes) wrote :

This patch looks good to me, I tested it using trusty-icehouse and trusty-liberty, there are no visible regressions and it fixes liberty.

[0] trusty-icehouse:
root@juju-freyes-machine-4:~# /usr/local/lib/nagios/plugins/check_haproxy.sh
OK: All haproxy instances (6) looking good
root@juju-freyes-machine-4:~# service haproxy stop
 * Stopping haproxy haproxy
   ...done.
root@juju-freyes-machine-4:~# /usr/local/lib/nagios/plugins/check_haproxy.sh
CRITICAL: keystone-1 keystone-0 keystone-2 keystone-1 keystone-0 keystone-2
root@juju-freyes-machine-4:~# service haproxy start
 * Starting haproxy haproxy
   ...done.
root@juju-freyes-machine-4:~# /usr/local/lib/nagios/plugins/check_haproxy.sh
OK: All haproxy instances (6) looking good

[1] trusty-liberty:
root@juju-freyes-machine-4:~# /usr/local/lib/nagios/plugins/check_haproxy.sh
CRITICAL: keystone-1 keystone-0 keystone-2 keystone-1 keystone-0 keystone-2
root@juju-freyes-machine-4:~# service haproxy status
haproxy is running.
root@juju-freyes-machine-4:~# dpkg -l haproxy
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===============================================-============================-============================-===================================================================================================
ii haproxy 1.5.14-1ubuntu0.15.10.1~clou amd64 fast and reliable load balancing reverse proxy
root@juju-freyes-machine-4:~# /usr/local/lib/nagios/plugins/check_haproxy.sh #<-patched
OK: All haproxy instances (6) looking good

review: Approve
Revision history for this message
Liam Young (gnuoy) wrote :

Thanks for the fix jjo and thanks for the testing freyes. It LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/files/check_haproxy.sh'
2--- charmhelpers/contrib/openstack/files/check_haproxy.sh 2015-02-17 07:11:43 +0000
3+++ charmhelpers/contrib/openstack/files/check_haproxy.sh 2015-11-30 19:10:36 +0000
4@@ -9,15 +9,17 @@
5 CRITICAL=0
6 NOTACTIVE=''
7 LOGFILE=/var/log/nagios/check_haproxy.log
8-AUTH=$(grep -r "stats auth" /etc/haproxy | head -1 | awk '{print $4}')
9+AUTH=$(grep -r "stats auth" /etc/haproxy | awk 'NR=1{print $4}')
10
11-for appserver in $(grep ' server' /etc/haproxy/haproxy.cfg | awk '{print $2'});
12+typeset -i N_INSTANCES=0
13+for appserver in $(awk '/^\s+server/{print $2}' /etc/haproxy/haproxy.cfg)
14 do
15- output=$(/usr/lib/nagios/plugins/check_http -a ${AUTH} -I 127.0.0.1 -p 8888 --regex="class=\"(active|backup)(2|3).*${appserver}" -e ' 200 OK')
16+ N_INSTANCES=N_INSTANCES+1
17+ output=$(/usr/lib/nagios/plugins/check_http -a ${AUTH} -I 127.0.0.1 -p 8888 -u '/;csv' --regex=",${appserver},.*,UP.*" -e ' 200 OK')
18 if [ $? != 0 ]; then
19 date >> $LOGFILE
20 echo $output >> $LOGFILE
21- /usr/lib/nagios/plugins/check_http -a ${AUTH} -I 127.0.0.1 -p 8888 -v | grep $appserver >> $LOGFILE 2>&1
22+ /usr/lib/nagios/plugins/check_http -a ${AUTH} -I 127.0.0.1 -p 8888 -u '/;csv' -v | grep ",${appserver}," >> $LOGFILE 2>&1
23 CRITICAL=1
24 NOTACTIVE="${NOTACTIVE} $appserver"
25 fi
26@@ -28,5 +30,5 @@
27 exit 2
28 fi
29
30-echo "OK: All haproxy instances looking good"
31+echo "OK: All haproxy instances ($N_INSTANCES) looking good"
32 exit 0

Subscribers

People subscribed via source and target branches