github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/acceptancetests/repository/trusty/haproxy/files/nrpe/check_haproxy_queue_depth.sh (about)

     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 10000 -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