#!/bin/bash # test for loadavg frequencies : ${width:=720} case "$1" in m*) # make # three load gauges for: # avg load in interval (checked every msec), # 12 probes avg load as computed with given frequency # 12 probes avg load as of /proc/loadavg or sysinfo() (about 1 min) rrdtool create loadavg.rrd -b 946684800 -s 5 \ DS:intv:GAUGE:60:0:U \ DS:freq:GAUGE:60:0:U \ DS:kern:GAUGE:60:0:U \ RRA:AVERAGE:0.5:1:$width exit ;; l*) # load, e.g. l -l30 shift gcc -lm loadavg.c ./a.out "$@" -i$width | rrdtool - ;; g*) # graph rrdtool graph "${2:-loadavg}.png" -w $width -h 200 -t "${3:-loadavg}" \ -s 946684800 -e $[946684800 + 5*$width] \ DEF:intv=loadavg.rrd:intv:AVERAGE \ DEF:freq=loadavg.rrd:freq:AVERAGE \ DEF:kern=loadavg.rrd:kern:AVERAGE \ LINE1:intv#00CC0088:"interval load" \ LINE1:freq#0000CC88:"avg at test load_freq" \ LINE1:kern#CC000088:"kernel 1-min avg" ;; w*) # width 1440 export width=$2 shift 2 exec $0 "$@" ;; *) # do it all w/ params for loadavg.c $0 make $0 load "$@" $0 graph ;; esac