jablonka.czprosek.czf

crusader

Subversion Repositories:
[/] [trunk/] [statistiky/] [opt/] [statistiky/] [makeobr_system_info.sh] - Rev 1

Compare with Previous - Blame - Download


#!/bin/bash

name=mpstat
timediff=$1
suffix=$2
popis=$3
width=$4

PATH=$PATH:/opt/rrdtool/bin

datadir=/var/statistiky/system
target_img_dir="/var/www/heaven/stat/img"

cd $datadir

xgridstr=""

if [ $timediff -ge 604800 ]
then
    xgridstr="--x-grid HOUR:12:DAY:1:DAY:1:86400:%d.%m."
fi
if [ $timediff -ge 2678400 ]
then
    xgridstr="--x-grid DAY:1:DAY:7:DAY:2:86400:%d.%m."
fi

now=`date +%s`

if [ $timediff -gt 7200 ]
then

  for stat in user nice system iowait irq softirq idle intrs
  do
    rrdtool graph ${target_img_dir}/${name}_${stat}_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
        DEF:avg_value=${name}.rrd:${stat}:AVERAGE \
        DEF:min_value=${name}.rrd:${stat}:MIN \
        DEF:max_value=${name}.rrd:${stat}:MAX \
        CDEF:avg1=PREV\(avg_value\) \
        CDEF:avg2=PREV\(avg1\) \
        CDEF:min1=PREV\(min_value\) \
        CDEF:max1=PREV\(max_value\) \
        CDEF:prumer_avg=avg_value,avg1,avg2,+,+,3,/ \
        CDEF:maxmin=max1,min1,- \
        AREA:min1#FFFFFF \
        STACK:maxmin#e0e0e0 \
        LINE1:max1#FFa1a1:"max" \
        LINE1:min1#a8a8FF:"min" \
        LINE2:prumer_avg#202020:"avg" \
        --vertical-label "CPU time [%]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${stat} ${name} ${popis}"
  done

else

  for stat in user nice system iowait irq softirq idle intrs
  do
    rrdtool graph ${target_img_dir}/${name}_${stat}_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
        DEF:value=${name}.rrd:${stat}:MAX \
        LINE1:value#000000 \
        --vertical-label "CPU time [%]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${stat} ${name} ${popis}"
  done
  
fi


Powered by WebSVN 2.2.1