#!/bin/bash [ $1 = ‘http_server‘ ] && WEBGROUP=$1,FRONTEND || WEBGROUP=$1,BACKEND case "$2" in "comp" ) IN=`/bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $52}‘` OUT=`/bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $53}‘` echo "scale=4;($IN-$OUT)/$IN*100" | bc ;; "qcur" ) /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $3}‘ ;; "qmax" ) /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $4}‘ ;; "scur") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $5}‘ ;; "smax") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $6}‘ ;; "slim") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $7}‘ ;; "stot") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $8}‘ ;; "bin") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $9}‘ ;; "bout") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $10}‘ ;; "dreq") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $11}‘ ;; "dresp") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $12}‘ ;; "ereq") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $13}‘ ;; "econ") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $14}‘ ;; "eresp") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $15}‘ ;; "eretr") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $16}‘ ;; "eredis") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $17}‘ ;; "status") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $18}‘ ;; "weight") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $19}‘ ;; "act") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $20}‘ ;; "bck") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $21}‘ ;; "chkfail") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $22}‘ ;; "chkdown") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $23}‘ ;; "lastchg") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $24}‘ ;; "downtime") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $24}‘ ;; "qlimit") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $26}‘ ;; "pid") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $27}‘ ;; "iid") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $28}‘ ;; "sid") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $29}‘ ;; "throttle") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $30}‘ ;; "lbtot") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $31}‘ ;; "tracked") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $32}‘ ;; "tpye") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $33}‘ ;; "rate") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $34}‘ ;; "rate_lim") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $35}‘ ;; "rate_max") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $36}‘ ;; "check_status") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $37}‘ ;; "check_code") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $38}‘ ;; "check_duration") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $39}‘ ;; "hrsp_1xx") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $40}‘ ;; "hrsp_2xx") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $41}‘ ;; "hrsp_3xx") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $42}‘ ;; "hrsp_4xx") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $43}‘ ;; "hrsp_5xx") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $44}‘ ;; "hrsp_other") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $45}‘ ;; "hanafail") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $46}‘ ;; "req_rate") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $47}‘ ;; "req_rate_max") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $48}‘ ;; "req_tot") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $49}‘ ;; "cli_abrt") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $50}‘ ;; "srv_abrt") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $51}‘ ;; "comp_in") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $52}‘ ;; "comp_out") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $53}‘ ;; "comp_byp") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $54}‘ ;; "comp_rsp") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $55}‘ ;; "lastsess") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $56}‘ ;; "last_chk") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $57}‘ ;; "last_agt") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $58}‘ ;; "qtime") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $59}‘ ;; "ctime") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $60}‘ ;; "rtime") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $61}‘ ;; "ttime") /bin/echo "show stat"|/usr/sbin/socat /var/run/haproxy.sock stdio|awk -v n=$WEBGROUP -F, ‘$0~n{print $62}‘ ;; *) /bin/echo ‘error‘ ;; esac
时间: 2024-10-08 10:17:38