Skip to content

Instantly share code, notes, and snippets.

# crontab -l
# m h dom mon dow command
*/5 * * * * DOWN=$(./proxyctl "show stat" |egrep -v '^#|no check|FRONTEND|UP'); if [ ${#DOWN} -gt 0 ]; then echo $DOWN |mail -s "oh snap" [email protected]; fi
*/30 * * * * ERRORS=$(./proxyctl "show errors"); if [ ${#ERRORS } -gt 0 ]; then echo $ERRORS |mail -s "clients received the following errors in the last half-hour" [email protected]; fi
### re HAProxy 1.4.9, mailing list
###
### On Thu, Oct 28, 2010 at 3:40 PM, Willy Tarreau <[email protected]> wrote:
### The new feature of halog is a per-URL statistics (req & error counts, avg
### response time, total response time, and that for all or valid only requests).
### The output is sorted by a field specified from the command line flag, among
### which URL (-u), req count (-uc), err count (-ue), total time (-ut), average
### time (-ua), total time on OK reqs (-uto) and avg time on OK reqs (-uao).
l:~# /usr/local/sbin/haproxy -f /etc/haproxy/haproxy.cfg -D -p /var/run/haproxy.pid -u -uc -ue -ut -ua -uto -uao
lo@padlet:~$ perl tubemp3.pl
This shit takes a YouTube link and makes an mp3.
usage: tubemp3.pl http://youtubedownloadlink "Name to save .mp3"
If you use spaces for the resulting mp3, you'll need to enclose that filename in quotes.
lo@padlet:~$ cat !$
cat tubemp3.pl
#!/usr/bin/perl
unless ( $#ARGV == 3 ) {
die "This shit takes a YouTube link and makes an mp3.
l:~/haproxyctl# # from https://github.com/flores/haproxyctl
l:~/haproxyctl# ./haproxyctl
usage: ./haproxyctl <argument>
where argument can be:
start : start haproxy unless it is already running
stop : stop an existing haproxy
restart : restart the process
status : is haproxy running? on what ports per lsof?
configcheck : check /etc/haproxy/haproxy.cfg
cloudkick : cloudkick.com-friendly status and metric for connected users
#
# quick and dirty documentation for https://github.com/cloudkick/agent-plugins/pull/6
#
l:~/agent-plugins# ./http_connections.sh help
CloudKick check to return established, connected, and idle users, and ensure there is a listener (critical if there is not)
usage: ./http_connections.sh <threshold|help>
where
help prints this message
threshold is the number of minimum users. Below this number is a critical alert.
if no argument, threshold is 1.
@flores
flores / thin init script
Created February 23, 2011 00:26
(Too?) simple Thin server init script
#!/usr/bin/env ruby
# quick and dirty thin init script
#
# path for thin
thin = "/home/someuser/.rvm/gems/ruby-1.8.7-p72@global/bin/thin"
config = "config/config.ru"
# which dir to run from
path = "/srv/thisapp"
@flores
flores / rvm path weirdness
Created February 23, 2011 00:36
Ran into bogus rake 2.3.4 errors, turned out the real culprit was stubborn and old rack. Paths changed for public gist.
@someserver:somedir$ thin --environment production --port 666 --pid somedir/tmp/pids/thin.666.pid start
>> Using rails adapter
Missing the Rails 2.3.4 gem. Please `gem install -v=2.3.4 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
@someserver:somedir$ gem list |grep -i rail
rails (2.3.4)
rspec-rails (1.2.9)
@someserver:somedir$ echo $PATH
/home//.rvm/gems/ruby-1.8.7-p72@someapplication/bin:/home//.rvm/gems/ruby-1.8.7-p72@global/bin:.rvmpathruby-1.8.7-p72/bin:/home//.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
@someserver:somedir$ which rails
/home//.rvm/gems/ruby-1.8.7-p72@someapplication/bin/rails
@flores
flores / haproxyctl "show health"
Created February 24, 2011 20:31
Just getting the relevant bits from "show stat" and nicer formatting
l:~/haproxyctl# ./haproxyctl "show health"
# pxname svname status weight
http FRONTEND OPEN
sinatra sinatra_downoi DOWN 1
sinatra sinatra_rindica DOWN 1
sinatra sinatra_guinea UP 1
sinatra BACKEND UP 1
ei guinea UP 1
ei belem UP 1
ei BACKEND UP 1
@flores
flores / ssh-agent-mgr.sh
Created March 2, 2011 00:19
Easy key management with ssh-agent with multiple logins, screen, etc.
# cat ssh-agent.sh
#!/usr/bin/env bash
SSH_AUTH_SOCK=`find /tmp -name 'agent*'`
export SSH_AUTH_SOCK
SSH_AGENT_PID=`ps -ef |awk '$8 ~ /^ssh-agent/ {print $2}'`
export SSH_AGENT_PID
for i in `ls ~/.ssh/*pem`; do
ssh-add $i
done
@flores
flores / MariaDB from MySQL slaving over ssh tunnels
Created March 3, 2011 22:58
AWS EU-West MariaDB slave over ssh tunnel to US-East MySQL/Percona-Sever 5.1 master
# Just quickly showing how monitors won't break and failures still happen as expected.
# Will need a monitor for the ssh tunnel, of course.
#
MariaDB [(none)]> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: localhost
Master_User: replication
Master_Port: 4306