~paulgear/charms/trusty/ntpmaster/fix-python3-on-trusty

« back to all changes in this revision

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

  • Committer: Adam Israel
  • Date: 2016-03-30 17:02:08 UTC
  • mfrom: (12.1.1 trunk)
  • Revision ID: adam.israel@gmail.com-20160330170208-hlkrwz32rw4jcfl4
[paulgear] Sync charm-helpers

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 | awk 'NR=1{print $4}')
 
13
 
 
14
typeset -i N_INSTANCES=0
 
15
for appserver in $(awk '/^\s+server/{print $2}' /etc/haproxy/haproxy.cfg)
 
16
do
 
17
    N_INSTANCES=N_INSTANCES+1
 
18
    output=$(/usr/lib/nagios/plugins/check_http -a ${AUTH} -I 127.0.0.1 -p 8888 -u '/;csv' --regex=",${appserver},.*,UP.*" -e ' 200 OK')
 
19
    if [ $? != 0 ]; then
 
20
        date >> $LOGFILE
 
21
        echo $output >> $LOGFILE
 
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
done
 
27
 
 
28
if [ $CRITICAL = 1 ]; then
 
29
    echo "CRITICAL:${NOTACTIVE}"
 
30
    exit 2
 
31
fi
 
32
 
 
33
echo "OK: All haproxy instances ($N_INSTANCES) looking good"
 
34
exit 0