~openstack-charmers-archive/charms/trusty/cinder/trunk

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/openstack/files/check_haproxy.sh

  • Committer: Liam Young
  • Date: 2015-02-26 10:57:06 UTC
  • mfrom: (71.3.5 cinder)
  • Revision ID: liam.young@canonical.com-20150226105706-n0mwh8tltzxn9ttb
[bradm, r=gnuoy] Add haproxy nrpe checks and setting of nagios_servicegroups

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
#--------------------------------------------
3
 
# This file is managed by Juju
4
 
#--------------------------------------------
5
 
#
6
 
# Copyright 2009,2012 Canonical Ltd.
7
 
# Author: Tom Haddon
8
 
 
9
 
CRITICAL=0
10
 
NOTACTIVE=''
11
 
LOGFILE=/var/log/nagios/check_haproxy.log
12
 
AUTH=$(grep -r "stats auth" /etc/haproxy | head -1 | awk '{print $4}')
13
 
 
14
 
for appserver in $(grep '    server' /etc/haproxy/haproxy.cfg | awk '{print $2'});
15
 
do
16
 
    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')
17
 
    if [ $? != 0 ]; then
18
 
        date >> $LOGFILE
19
 
        echo $output >> $LOGFILE
20
 
        /usr/lib/nagios/plugins/check_http -a ${AUTH} -I 127.0.0.1 -p 8888 -v | grep $appserver >> $LOGFILE 2>&1
21
 
        CRITICAL=1
22
 
        NOTACTIVE="${NOTACTIVE} $appserver"
23
 
    fi
24
 
done
25
 
 
26
 
if [ $CRITICAL = 1 ]; then
27
 
    echo "CRITICAL:${NOTACTIVE}"
28
 
    exit 2
29
 
fi
30
 
 
31
 
echo "OK: All haproxy instances looking good"
32
 
exit 0