jablonka.czprosek.czf

crusader

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

Compare with Previous - Blame - Download


#!/bin/bash

if [ $# -lt 4 ]
then
    echo "Usage: `basename $0` <target name> <time interval> <file suffix> <graph comment> [graph width]"
    exit 1;
fi

name="$1"
timediff="$2"
suffix="$3"
popis="$4"

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

#PATH=$PATH:/opt/rrdtool/bin

datadir="/var/statistiky/ping"
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

xgridstr=""
if [ $timediff -gt 108000 ]; then xgridstr="--x-grid HOUR:6:DAY:1:DAY:1:86400:%d.%m."; fi
if [ $timediff -gt 777600 ]; then xgridstr="--x-grid DAY:1:WEEK:1:WEEK:1:86400:%d.%m."; fi

function rtt_avg_peak()
{
    rrdtool graph ${target_img_dir}/ping_${name}_rtt_${suffix}.png --imgformat PNG --start $(($now-${timediff})) --end $now \
        DEF:rttavg=${name}.rrd:rttavg:MAX \
        DEF:rttmin=${name}.rrd:rttmin:MAX \
        AREA:rttmin#a8a8FF:"min" \
        LINE2:rttavg#202020:"avg" \
        --vertical-label "Round Trip Time Peak [ms]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "Spickove hodnoty: ${name} ${popis}" \
        --lower-limit 0 \
        --upper-limit 1
}

function flow_graph()
{
    rtt_avg_peak
    
    rrdtool graph ${target_img_dir}/ping_${name}_pktloss_${suffix}.png --imgformat PNG --start $(($now-${timediff})) --end $now \
        DEF:pl_avg=${name}.rrd:pktloss:AVERAGE \
        DEF:pl_min=${name}.rrd:pktloss:MIN \
        DEF:pl_max=${name}.rrd:pktloss:MAX \
        CDEF:avg1=PREV\(pl_avg\) \
        CDEF:avg2=PREV\(avg1\) \
        CDEF:min1=PREV\(pl_min\) \
        CDEF:min2=PREV\(min1\) \
        CDEF:max1=PREV\(pl_max\) \
        CDEF:max2=PREV\(max1\) \
        CDEF:prumer_pktloss=pl_avg,avg1,avg2,+,+,3,/ \
        CDEF:maxmin=pl_max,pl_min,- \
        HRULE:5#000000 \
        AREA:pl_min#FFFFFF \
        STACK:maxmin#e0e0e0 \
        LINE1:pl_max#FFa1a1:"max" \
        LINE1:pl_min#a8a8FF:"min" \
        LINE2:prumer_pktloss#202020:"avg" \
        --vertical-label "Packet loss [%]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${name} ${popis}" \
        --lower-limit 0 \
        --upper-limit 5 
}

function rtt_mean_deviation_avgavg()
{
    rrdtool graph ${target_img_dir}/ping_${name}_rtt_${suffix}.png --imgformat PNG --start $(($now-${timediff})) --end $now \
        DEF:rttmin=${name}.rrd:rttmin:AVERAGE \
        DEF:rttavg=${name}.rrd:rttavg:AVERAGE \
        DEF:rttmdev=${name}.rrd:rttmdev:AVERAGE \
        CDEF:avg1=PREV\(rttavg\) \
        CDEF:avg2=PREV\(avg1\) \
        CDEF:min1=PREV\(rttmin\) \
        CDEF:mdev1=PREV\(rttmdev\) \
        CDEF:prumer_rttavg=rttavg,avg1,avg2,+,+,3,/ \
        LINE2:min1#6750ff:"min" \
        LINE1:mdev1#ff5047:"mdev" \
        LINE2:prumer_rttavg#202020:"avg" \
        --vertical-label "Round Trip Time [ms]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${name} ${popis}" \
        --lower-limit 0 \
        --upper-limit 1
}
function rtt_mean_deviation_maxavg()
{
    rrdtool graph ${target_img_dir}/ping_${name}_rtt_${suffix}.png --imgformat PNG --start $(($now-${timediff})) --end $now \
        DEF:rttmin=${name}.rrd:rttmin:MAX \
        DEF:rttavg=${name}.rrd:rttavg:MAX \
        DEF:rttmdev=${name}.rrd:rttmdev:MAX \
        CDEF:avg1=PREV\(rttavg\) \
        CDEF:avg2=PREV\(avg1\) \
        CDEF:min1=PREV\(rttmin\) \
        CDEF:mdev1=PREV\(rttmdev\) \
        CDEF:prumer_rttavg=rttavg,avg1,avg2,+,+,3,/ \
        LINE2:min1#6750ff:"min" \
        LINE1:mdev1#ff5047:"mdev" \
        LINE2:prumer_rttavg#202020:"avg" \
        --vertical-label "Round Trip Time [ms]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${name} ${popis}" \
        --lower-limit 0 \
        --upper-limit 1
}

function rtt_min_max_avg_7200()
{
    rrdtool graph ${target_img_dir}/ping_${name}_rtt_${suffix}.png --imgformat PNG --start $(($now-${timediff})) --end $now \
        DEF:rttmin=${name}.rrd:rttmin:AVERAGE \
        DEF:rttmax=${name}.rrd:rttmax:AVERAGE \
        DEF:rttavg=${name}.rrd:rttavg:AVERAGE \
        DEF:rttmdev=${name}.rrd:rttmdev:AVERAGE \
        CDEF:avg1=PREV\(rttavg\) \
        CDEF:avg2=PREV\(avg1\) \
        CDEF:min1=PREV\(rttmin\) \
        CDEF:max1=PREV\(rttmax\) \
        CDEF:mdev1=PREV\(rttmdev\) \
        CDEF:prumer_rttavg=rttavg,avg1,avg2,+,+,3,/ \
        CDEF:maxmin=max1,min1,- \
        AREA:min1#FFFFFF \
        STACK:maxmin#e0e0e0 \
        LINE1:max1#FFa1a1:"max" \
        LINE1:min1#a8a8FF:"min" \
        LINE2:prumer_rttavg#202020:"avg" \
        --vertical-label "Round Trip Time [ms]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${name} ${popis}" \
        --lower-limit 0 \
        --upper-limit 1
}

function flow_graph_7200()
{

    rtt_mean_deviation_7200

    rrdtool graph ${target_img_dir}/ping_${name}_pktloss_${suffix}.png --imgformat PNG --start $(($now-${timediff})) --end $now \
        DEF:pl_avg=${name}.rrd:pktloss:AVERAGE \
        CDEF:avg1=PREV\(pl_avg\) \
        CDEF:avg2=PREV\(avg1\) \
        CDEF:min_agg=pl_avg,avg1,avg2,MIN,MIN \
        CDEF:max_agg=pl_avg,avg1,avg2,MAX,MAX \
        CDEF:prumer_pktloss=pl_avg,avg1,avg2,+,+,3,/ \
        CDEF:maxmin=max_agg,min_agg,- \
        HRULE:5#000000 \
        AREA:min_agg#FFFFFF \
        STACK:maxmin#e0e0e0 \
        LINE1:max_agg#FFa1a1:"max" \
        LINE1:min_agg#a8a8FF:"min" \
        LINE2:prumer_pktloss#202020:"avg" \
        --vertical-label "Packet loss [%]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${name} ${popis}" \
        --lower-limit 0 \
        --upper-limit 5 
}

function rtt_prime_nekonsolidovane_hodnoty()
{
    rrdtool graph ${target_img_dir}/ping_${name}_rtt_${suffix}.png --imgformat PNG --start $(($now-${timediff})) --end $now \
        DEF:rttmin=${name}.rrd:rttmin:AVERAGE \
        DEF:rttavg=${name}.rrd:rttavg:AVERAGE \
        DEF:rttmdev=${name}.rrd:rttmdev:AVERAGE \
        LINE2:rttmin#6750ff:"min" \
        LINE1:rttmdev#ff5047:"mdev" \
        LINE2:rttavg#202020:"avg" \
        --vertical-label "Round Trip Time [ms]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${name} ${popis}" \
        --lower-limit 0 \
        --upper-limit 1
}

function pktloss_prime_nekonsolidovane_hodnoty()
{
    rrdtool graph ${target_img_dir}/ping_${name}_pktloss_${suffix}.png --imgformat PNG --start $(($now-${timediff})) --end $now \
        DEF:pl_avg=${name}.rrd:pktloss:AVERAGE \
        HRULE:5#000000 \
        LINE2:pl_avg#202020:"avg" \
        --vertical-label "Packet loss [%]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${name} ${popis}" \
        --lower-limit 0 \
        --upper-limit 5 
}

function pktloss_avgavg()
{
    rrdtool graph ${target_img_dir}/ping_${name}_pktloss_${suffix}.png --imgformat PNG --start $(($now-${timediff})) --end $now \
        DEF:pl_avg=${name}.rrd:pktloss:AVERAGE \
        CDEF:avg1=PREV\(pl_avg\) \
        CDEF:avg2=PREV\(avg1\) \
        CDEF:prumer_pktloss=pl_avg,avg1,avg2,+,+,3,/ \
        HRULE:5#000000 \
        AREA:avg1#FFa1a1:"presne" \
        LINE2:prumer_pktloss#202020:"prumer" \
        --vertical-label "Packet loss [%]" \
        --height 200 \
        --width  ${width} \
        ${xgridstr} \
        --title "${name} ${popis}" \
        --lower-limit 0 \
        --upper-limit 5 
}

if [ $timediff -le 21600 ]
then
    rtt_prime_nekonsolidovane_hodnoty
    pktloss_prime_nekonsolidovane_hodnoty
else
    if [ $timediff -le 108000 ]
    then
#        rtt_mean_deviation_maxavg
        rtt_avg_peak
        pktloss_avgavg
    else
        flow_graph
    fi
fi

Powered by WebSVN 2.2.1