Skip to content

Instantly share code, notes, and snippets.

View cronnelly's full-sized avatar

Michael Cronnelly cronnelly

View GitHub Profile
@cronnelly
cronnelly / multi-tail-filter.sh
Created March 30, 2013 19:00
Tail and filter log files on multiple SSH hosts.
for i in $(seq 2); do ssh -A sl-shortlist-0$i "tail -f /var/log/apache2/other_vhosts_access.log | cut -f 4,5,6,7,8,13 | awk -F'=' '{if (\$NF > 500000) print \"$i:\", \$0; fflush()}'" & true; done | cat
@cronnelly
cronnelly / zram
Created November 25, 2012 14:42
A munin plugin to graph zram usage
#!/bin/bash
# -*- sh -*-
: << =cut
=head1 NAME
zram - Plugin to monitor zram usage
=head1 CONFIGURATION
@cronnelly
cronnelly / screen_serve.sh
Created October 25, 2012 13:32
Serve X display snapshot over HTTP
#!/bin/bash
# Call from inet with this config:
# www stream tcp nowait node /usr/local/bin/screen_serve.sh
export XAUTHORITY=/home/node/.Xauthority
export DISPLAY=:0
filename="/tmp/screen-"$(uuidgen)".jpg"
for i in `seq 100`; do
@cronnelly
cronnelly / image-analyse
Created October 23, 2012 19:30
Find PNGs which should be re-encoded to JPG
find . -type f -iname "*.png" -print0 | while read -d $'\0' fn; do os=$(stat -c%s "$fn"); js=$(gm convert -quality 80 "$fn" jpg:- | wc -c); ratio=$(echo "scale=3; ($js * 100) / $os" | bc); echo "$ratio% $js $os $fn"; done | sort -n