#!/bin/bash # # Create images for the collectd web site from the raw collectd data # This is necessary because the web site does not have the # software installed to create the images on the fly. # me=`basename $0` h=`hostname` time='day' e=`date +%s` s=`expr $e - 86400` o=$time tint=$time datadir='/data/collectd' pngdir='/data/phpimages' clusterload='/data/tpg/etc/clusterload.pl' # Figure out groups based on host we run on groups='MACC DATA' if [ "$h" = "frodo" ]; then groups='DC' fi types='load memory swap processes traffic-eth0 traffic-eth1 traffic-eth2 traffic-eth3 df-home df-home0 df-home2 df-tmp' #----------------------------------------------------------------- # Sort out options and parameters #----------------------------------------------------------------- outfile='' while [ -n "$(echo $1 | grep '-')" ]; do case $1 in -h ) echo "Usage: $me [-options]" echo "Create images for the collectd web site." echo "" echo "Options:" echo " -day - create daily files" echo " -week - create weekly files" echo " -month - create monthly files" echo " -year - create yearly files" echo " -create name - set name of output file (specify before -range)" echo " -range yyyymmdd yyyymmdd - create files from date to date" exit 1 ;; -day ) time='day' e=`date +%s` s=`expr $e - 86400` o=$time tint=$time ;; -week ) time='week' e=`date +%s` s=`expr $e - 604800` o=$time tint=$time ;; -month ) time='month' e=`date +%s` s=`expr $e - 2592000` o=$time tint=$time ;; -year ) time='year' e=`date +%s` s=`expr $e - 31536000` o=$time tint=$time ;; -create ) outfile=$2 shift o=$outfile ;; -range ) time="$2-$3$outfile" e=$3 s=$2 epre=`perl -e 'print substr($ARGV[0],0,6);' $e` spre=`perl -e 'print substr($ARGV[0],0,6);' $s` if [ "$epre" = "$spre" ]; then tint='month' else tint='year' fi shift shift ;; * ) print "$me Invalid option '$1'" exit 1 esac shift done for g in $groups; do for t in $types; do php makeimages.php quiet=1 htmlmsg=0 group=$g time=$time type=$t done tint="-interval $tint" $clusterload -start $s -end $e -outfileave $pngdir/$g.ave.$o.png -outfiletotal $pngdir/$g.total.$o.png $tint $datadir/*/load.rrd done exit