jablonka.czprosek.czf

crusader

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

Compare with Previous - Blame - Download


#!/bin/bash

device=$1
timediff=$2
suffix=$3
popis=$4

if [ $# -ge 5 ]
then
    width=$5
else
    width=400
fi

hrule_in=""
hrule_out=""
if [ $# -ge 6 ] && [ $6 -gt 0 ]
then
    hrule_in="HRULE:$6#00a000"
    hrule_out="HRULE:-$6#00a000"
fi

PATH=$PATH:/opt/rrdtool/bin

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

cd $datadir

now=`date +%s`

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

rrdtool graph ${target_img_dir}/${device}_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
    DEF:inbps=${device}.rrd:input:AVERAGE \
    DEF:inbps_max=${device}.rrd:input:MAX \
    DEF:outbps=${device}.rrd:output:AVERAGE \
    DEF:outbps_max=${device}.rrd:output:MAX \
    CDEF:in1=PREV\(inbps\) \
    CDEF:in2=PREV\(in1\) \
    CDEF:out1=PREV\(outbps\) \
    CDEF:out2=PREV\(out1\) \
    CDEF:inbps_max1=PREV\(inbps_max\),8,* \
    CDEF:inbps_max2=PREV\(inbps_max1\) \
    CDEF:outbps_max1=PREV\(outbps_max\),8,* \
    CDEF:outbps_max2=PREV\(outbps_max1\) \
    CDEF:inbps_out=inbps,in1,in2,+,+,3,/,8,* \
    CDEF:inbps_max_out=inbps_max,inbps_max1,inbps_max2,MAX,MAX,inbps_out,- \
    CDEF:in_max_diff=inbps_max1,inbps_out,- \
    CDEF:outbps_out=outbps,out1,out2,+,+,3,/,-1,*,8,* \
    CDEF:out_max_diff=outbps_max1,-1,*,outbps_out,- \
    $hrule_in $hrule_out \
    CDEF:outbps_max_out=outbps_max,outbps_max1,outbps_max2,MAX,MAX,-1,*,outbps_out,- \
    AREA:inbps_out#ffa1a1 \
    STACK:in_max_diff#ffd8d8 \
    LINE2:inbps_out#FF0000:"In traffic" \
    AREA:outbps_out#a8a8ff \
    STACK:out_max_diff#d8d8ff \
    LINE2:outbps_out#0000FF:"Out traffic" \
    --vertical-label bit/s \
    --height 250 \
    --width $width \
    ${xgridstr} \
    --title "${device} ${popis}"

Powered by WebSVN 2.2.1