Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A collection of web server debug utils
# A collection of web server debug utils
# Described in http://erikeldridge.com/blog/unix
# Inspired by the work of @Pufferfish
apache_access_log=/var/log/apache2/access_log
rails_root=/usr/local/project
rails_prod_log=$rails_root/log/production.log
function tail_apache_access_log() {
tail -f $apache_access_log
}
function tail_apache_403(){
tail_apache_access_log | grep 403
}
function tail_apache_404(){
tail_apache_access_log | grep 404
}
function tail_apache_500(){
tail_apache_access_log | grep 500
}
function tail_rails_prod_log() {
tail -f $rails_prod_log
}
function cat_apache_403(){
cat $apache_access_log | grep 403
}
function cat_apache_404(){
cat $apache_access_log | grep 404
}
function cat_apache_500(){
cat $apache_access_log | grep 500
}
function count_apache_403_ips(){
cat_apache_403 | awk '{ print $1 }' | sort | uniq -c | sort -r | head -50
}
function count_apache_404_ips(){
cat_apache_404 | awk '{ print $1 }' | sort | uniq -c | sort -r | head -50
}
function count_apache_500_ips(){
cat_apache_500 | awk '{ print $1 }' | sort | uniq -c | sort -r | head -50
}
function count_apache_403_paths(){
cat_apache_403 | awk '{ print $7 }' | sort | uniq -c | sort -r | head -50
}
function count_apache_404_paths(){
cat_apache_404 | awk '{ print $7 }' | sort | uniq -c | sort -r | head -50
}
function count_apache_500_paths(){
cat_apache_500 | awk '{ print $7 }' | sort | uniq -c | sort -r | head -50
}
function watch_ps(){
watch -d -n 1 "ps -ao 'pid ppid time start command' | sort"
}
function json_print(){
# Example: curl 'http://api.twitter.com/1/users/lookup.json?screen_name=TwitterMusic,HuffPostFood,NewYorker' | json_print | grep id_str
ruby -e 'require "rubygems"; require "json"; jj JSON.parse(ARGF.read)'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment