This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -w | |
require 'socket' | |
ctl=UNIXSocket.new("/tmp/proxystats") | |
ctl.puts "#{ARGV}" | |
while (line = ctl.gets) do | |
puts line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wet:~# chmod +x proxyctl | |
wet:~# ./proxyctl help | |
Unknown command. Please enter one of the following commands only : | |
clear counters : clear max statistics counters (add 'all' for all counters) help : this message prompt : toggle interactive mode with prompt quit : disconnect show info : report information about the running process show stat : report counters for each proxy and server show errors : report last request and response errors for each proxy show sess [id] : report the list of current sessions or dump this session get weight : report a server's current weight set weight : change a server's weight set timeout : change a timeout setting disable server : set a server in maintenance mode enable server : re-enable a server that was previously in maintenance mode | |
wet:~# | |
wet:~# # who's connected | |
wet:~# ./proxyctl "show sess" | |
0x8111a70: proto=tcpv4 src=82.41.169.69:49837 fe=http be=static srv=nginx_stellatus ts=04 age=1m1s calls=6 rq[f=1901000h,l=0,an=800h,rx=,wx=,ax=] rp[f=110010h,l=8030,an=100000h,rx=,wx=5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wet:~# # remove a server from the rotation. takes the argument of backend/server | |
wet:~# ./proxyctl "disable server static/nginx_stellatus" | |
wet:~# | |
wet:~# # let's see the status of that server now. MAINT is, as you'd expect, maintenance mode | |
wet:~# ./proxyctl "show stat" |grep -i nginx_stellatus | |
static,nginx_stellatus,0,0,0,3,,966,368345,253599033,,0,,0,0,0,0,MAINT,1,1,0,1,0,297143,0,,1,4,3,,966,,2,0,,5,INI,,0,0,847,49,70,0,0,0,,,,124,1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wet:~# ./proxyctl "clear counters" | |
wet:~# ./proxyctl "show stat" | |
# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt, | |
http,FRONTEND,,,0,0,5000,60,39346,20559128,0,0,2,,,,,OPEN,,,,,,,,,1,1,0,,,,0,0,0,0,,,,0,73,22,4,0,0,,0,0,99,,, | |
apache,wet,0,0,0,0,,2,853,2348,,0,,0,0,0,0,UP,1,1,0,0,0,5748,0,,1,2,1,,2,,2,0,,0,L4OK,,0,0,2,0,0,0,0,0,,,,0,0, | |
apache,BACKEND,0,0,0,0,0,2,853,2348,0,0,,0,0,0,0,UP,1,1,0,,0,5748,0,,1,2,0,,2,,1,0,,0,,,,0,2,0,0,0,0,,,,,0,0, | |
sinatra,sinatra_downoi,0,0,0,0,,5,2640,15872,,0,,0,0,0,0,UP,1,1,0,0,0,5748,0,,1,3,1,,5,,2,0,,0,L4OK,,46,0,5,0,0,0,0,0,,,,0,0, | |
sinatra,sinatra_rindica,0,0,0,0,,4,2168,9054,,0,,0,0,0,0,UP,1,1,0,0,0,5748,0,,1,3,2,,4,,2,0,,0,L4OK,,46,0,3,0,1,0,0,0,,,,0,0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
backend static | |
balance leastconn | |
mode http | |
option http-server-close | |
#ensures / returns with a 200 OK | |
option httpchk | |
# these are small cheap nginx boxes listening on http | |
server ngnix_downoi downoi.mysite.com:80 check inter 60s rise 5 fall 2 | |
server ngnix_rindica r.indica.mysite.com:80 check inter 60s rise 5 fall 2 | |
server nginx_stellatus p.stellatus.mysite.com:80 check inter 60s rise 5 fall 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
backend sinatra | |
balance leastconn | |
mode http | |
option http-server-close | |
option httpchk | |
server sinatra_downoi downoi.mysite.com:4567 check inter 60s rise 5 fall 2 | |
server sinatra_rindica r.indica.mysite.com:4567 check inter 60s rise 5 fall 2 | |
server sinatra_wet wet.mysite.com:4567 check inter 60s rise 5 fall 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
backend apache | |
balance source | |
mode http | |
option http-server-close | |
server wet 127.0.0.1:8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frontend http | |
bind :80 | |
mode http | |
option http-server-close | |
retries 3 | |
option redispatch | |
maxconn 5000 | |
# 120,000 ms is 2 minutes | |
contimeout 120000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
log 127.0.0.1 local0 notice | |
maxconn 5000 | |
daemon | |
stats socket /tmp/proxystats level admin # we'll use this guy to do stuff. | |
defaults | |
log global | |
mode http | |
option httplog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# count DOWN servers by first excluding the key, frontends, and any servers that aren't "up" | |
# if DOWN servers exist, email the admin | |
wet:~# DOWN=$(./proxyctl "show stat" |egrep -v '^#|no check|FRONTEND|UP'); if [ ${#DOWN} -gt 0 ]; then echo $DOWN |mail -s "oh snap" [email protected]; fi | |
# add it to the cron for every 5 minutes | |
wet:~# crontab -e | |
no crontab for root - using an empty one | |
crontab: installing new crontab |
OlderNewer