ansible-check_mk/roles/loadbalancers/files/check_ha.sh
Marius Pana 0a123abbcb initial commit
playbooks, scripts, etc. from the 2nd check_mk conference in munich,
germany.
2015-10-28 16:37:02 +02:00

25 lines
586 B
Bash

#!/bin/bash
CONN=`echo "show info" | socat /var/lib/haproxy/stats stdio |grep CurrConns | cut -d' ' -f2`
SRVS=`cat /etc/haproxy/haproxy.cfg |grep check | grep server |wc -l`
if [ $CONN = 0 ]; then
CONN=4
fi
if [ $SRVS = 0 ]; then
echo "<<<up_scale>>>"
echo "up_scale 1000"
echo "<<<down_scale>>>"
echo "down_scale 1000"
else
let "CONNPERSRV=$CONN/$SRVS"
echo "<<<up_scale>>>"
echo "up_scale $CONNPERSRV"
if [ $SRVS -le 2 ]; then
echo "<<<down_scale>>>"
echo "down_scale 16"
else
echo "<<<down_scale>>>"
echo "down_scale $CONNPERSRV"
fi
fi