jablonka.czprosek.czf

crusader

Subversion Repositories:
[/] [trunk/] [statistiky/] [opt/] [statistiky/] [makeobr_arp.sh] - Rev 3 Go to most recent revision

Compare with Previous - Blame - Download


#!/bin/bash

#name=$1    it is always 'arp'
name=arp
timediff=$1
suffix=$2
popis=$3
width=$4

PATH=$PATH:/opt/rrdtool/bin

datadir=/var/statistiky/arp
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`

function simple_graph()
{
rrdtool graph ${target_img_dir}/${name}_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
     DEF:arp_min=${name}.rrd:count:MIN \
     DEF:arp_max=${name}.rrd:count:MAX \
     DEF:arp_avg=${name}.rrd:count:AVERAGE \
     LINE1:arp_max#FF0000:"max" \
     AREA:arp_avg#a0a0a0:"avg" \
     LINE1:arp_min#0000FF:"min" \
     --vertical-label "ARP table size" \
     --height 200 \
     --width  ${width} \
     --title "${name} ${popis}"
}


#        CDEF:prumer_avg=avg1,avg2,avg3,avg4,avg5,+,+,+,+,5,/ \
#        CDEF:prumer_min=min1,min2,min3,min4,min5,+,+,+,+,5,/ \
#        CDEF:prumer_max=max1,max2,max3,max4,max5,+,+,+,+,5,/ \

# detekce UNKNOWN
#        CDEF:offline=prumer_avg,UN,INF,0,IF \
#        AREA:offline#f3ff73 \


function flow_graph()
{
    rrdtool graph ${target_img_dir}/${name}_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
        DEF:arp_avg=${name}.rrd:count:AVERAGE \
        DEF:arp_min=${name}.rrd:count:MIN \
        DEF:arp_max=${name}.rrd:count:MAX \
        CDEF:avg1=PREV\(arp_avg\) \
        CDEF:avg2=PREV\(avg1\) \
        CDEF:avg3=PREV\(avg2\) \
        CDEF:avg4=PREV\(avg3\) \
        CDEF:min1=PREV\(arp_min\) \
        CDEF:min2=PREV\(min1\) \
        CDEF:max1=PREV\(arp_max\) \
        CDEF:max2=PREV\(max1\) \
        CDEF:prumer_avg=arp_avg,avg1,avg2,avg3,+,+,+,4,/ \
        CDEF:prumer_min=arp_min,min1,min2,+,+,3,/ \
        CDEF:prumer_max=arp_max,max1,max2,+,+,3,/ \
        CDEF:maxmin=max2,min2,- \
        AREA:min2#FFFFFF \
        STACK:maxmin#e0e0e0 \
        LINE1:max2#FFa1a1:"max" \
        LINE1:min2#a8a8FF:"min" \
        LINE2:prumer_avg#202020:"avg" \
        --vertical-label "ARP table size" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${name} ${popis}"
}

if [ $timediff -lt 86400 ]
then
    rrdtool graph ${target_img_dir}/${name}_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
        DEF:arp_avg=${name}.rrd:count:AVERAGE \
        LINE2:arp_avg#0000FF:"ARP" \
        --vertical-label "ARP table size" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${name} ${popis}"
else
    flow_graph
fi

Powered by WebSVN 2.2.1