#!/bin/bash[ $1 = ' Http_server ' ] && webgroup=$1,frontend | | WEBGROUP=$1,BACKENDcase "$" 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, ' $~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
This article is from "Maple Night" blog, please be sure to keep this source http://fengwan.blog.51cto.com/508652/1713806
Zabbix Monitoring Haproxy Solution