~junaidali/charms/trusty/plumgrid-director/pg-restart

« back to all changes in this revision

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

  • Committer: bbaqar at plumgrid
  • Date: 2015-07-29 18:07:31 UTC
  • Revision ID: bbaqar@plumgrid.com-20150729180731-ioynar8x3u5pxytc
Addressed reviews by Charmers

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
 
# These should be config options at some stage
10
 
CURRQthrsh=0
11
 
MAXQthrsh=100
12
 
 
13
 
AUTH=$(grep -r "stats auth" /etc/haproxy | head -1 | awk '{print $4}')
14
 
 
15
 
HAPROXYSTATS=$(/usr/lib/nagios/plugins/check_http -a ${AUTH} -I 127.0.0.1 -p 8888 -u '/;csv' -v)
16
 
 
17
 
for BACKEND in $(echo $HAPROXYSTATS| xargs -n1 | grep BACKEND | awk -F , '{print $1}')
18
 
do
19
 
    CURRQ=$(echo "$HAPROXYSTATS" | grep $BACKEND | grep BACKEND | cut -d , -f 3)
20
 
    MAXQ=$(echo "$HAPROXYSTATS"  | grep $BACKEND | grep BACKEND | cut -d , -f 4)
21
 
 
22
 
    if [[ $CURRQ -gt $CURRQthrsh || $MAXQ -gt $MAXQthrsh ]] ; then
23
 
        echo "CRITICAL: queue depth for $BACKEND - CURRENT:$CURRQ MAX:$MAXQ"
24
 
        exit 2
25
 
    fi
26
 
done
27
 
 
28
 
echo "OK: All haproxy queue depths looking good"
29
 
exit 0
30