#!/bin/ksh # # $FedEx: 1.1 2002/02/15 01:26:53 ksb Exp $ # $Id: stats.SCO,v 1.1 2008/08/13 18:56:26 ksb Exp $ # we are junk, we can wait along time #sleep $((49+RANDOM%8)) # get 1-minute load average sysload=`/usr/bin/uptime | sed -e 's/.*average:[ ]*\([0-9.]*\),.*/\1/'` # CONFIG change to your domain name, not "sac.fedex.com" and "fedex.com" host=`hostname | sed -e 's/\.sac\.fedex\.com$//' -e 's/\.fedex\.com$//'` FIND_LIST="sysload pageout pagein cpu_sys cpu_wait cpu_idle cpu_nice cpu_user fork cswitch scall intr cpu_user cpu_sys cpu_idle" eval `vmstat | awk '$0 ~ /^[ 0-9][0-9 ]*$/ {print "cpu_user="$18"; cpu_sys="$19"; cpu_idle="$20; }'` ( /usr/bin/vmstat -f 2>/dev/null /usr/bin/vmstat -s )| sed -n -e ' s/^[ ]*\([0-9]*\)[ ]*demand.*fill pages*.*/pagein=\1/p s/^[ ]*\([0-9]*\)[ ]*pages paged out/pageout=\1/p s/^[ ]*\([0-9]*\)[ ]*user[ ]*cpu/cpu_user=\1/p s/^[ ]*\([0-9]*\)[ ]*system[ ]*cpu/cpu_sys=\1/p s/^[ ]*\([0-9]*\)[ ]*idle[ ]*cpu/cpu_idle=\1/p s/^[ ]*\([0-9]*\)[ ]*wait[ ]*cpu/cpu_wait=\1/p s/^[ ]*\([0-9]*\)[ ]*system[ ]*cpu/cpu_sys=\1/p s/^[ ]*\([0-9]*\)[ ]*nice[ ]*cpu/cpu_nice=\1/p s/^[ ]*\([0-9]*\)[ ]*device[ ]*interrupts/intr=\1/p s/^[ ]*\([0-9]*\)[ ]*system[ ]*calls/scall=\1/p s/^[ ]*\([0-9]*\)[ ]*cpu[ ]*context[ ]*switches/cswitch=\1/p s/^[ ]*\([0-9]*\)[ ]*forks,.*/fork=\1/p s/^[ ]*\([0-9]*\)[ ]*forks/fork=\1/p' | while read line do eval $line done for Name in $FIND_LIST do eval This=\$$Name [ -z "$This" ] && continue LABELS="$LABELS:$Name" VALUES="$VALUES:$This" done echo "update host/$host/unix.rrd -t ${LABELS#:} N${VALUES}" | /usr/local/bin/rrdup peg.sac.fedex.com:31415 exit 0