#!/bin/sh # # vmstat -s poller # If you want to see what the url looks like, comment out the 'xargs' line and run # this script with 'start' as the only argument: # # ./statpoll.sh start # # Uses gawk, becuase awk on Solaris 9 complains of a syntax error. # gawk and freebsd awk do not complain. :( update() { while true; do # date +%s would be awesome, but Solaris 9's date doesn't support it :( time=`perl -le 'print time()'` (vmstat -s \ | tr -d '&;()[]{}' \ | gawk '$1 ~ /^[0-9][0-9]*$/ {a=$1; $1=""; gsub(" ","_",$0); print "C_"$0"="a}' \ | sed -e 's/__/_/;'\ | tr '\n' '&'; echo) \ | sed -e 's,^,http://collector_host/stats/updater.py?,' | xargs -n1 wget -q -O /dev/null duration=`perl -le "print 50 - (time() - $time)"` sleep $duration done } if [ "$1" = "start" ] ; then update else pkill -9 -f "$0 start" pkill -9 -f "$0 start" pkill -9 -f "$0 start" exec 0> /dev/null exec 1> /dev/null exec 2> /dev/null (nohup $0 start) & fi