crusader |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/bin/bash
name=crusader$1
timediff=$2
suffix=$3
popis=$4
width=$5
PATH=$PATH:/opt/rrdtool/bin
datadir=/var/statistiky/crusader
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:rss_min=${name}.rrd:rss:MIN \
DEF:rss_max=${name}.rrd:rss:MAX \
DEF:rss_avg=${name}.rrd:rss:AVERAGE \
LINE1:rss_max#FF0000:"max" \
AREA:rss_avg#a0a0a0:"avg" \
LINE1:rss_min#0000FF:"min" \
--vertical-label "RSS" \
--height 200 \
--width ${width} \
--title "${name} ${popis}"
}
# 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:rss_avg=${name}.rrd:rss_avg:AVERAGE \
DEF:rss_min=${name}.rrd:rss_min:MIN \
DEF:rss_max=${name}.rrd:rss_max:MAX \
CDEF:avg1=PREV\(rss_avg\) \
CDEF:avg2=PREV\(avg1\) \
CDEF:min1=PREV\(rss_min\) \
CDEF:max1=PREV\(rss_max\) \
CDEF:prumer_avg=rss_avg,avg1,avg2,+,+,3,/ \
CDEF:maxmin=max1,min1,- \
HRULE:400#FF0000 \
HRULE:450#00BB00 \
AREA:min1#FFFFFF \
STACK:maxmin#e0e0e0 \
LINE1:max1#FFa1a1:"max" \
LINE1:min1#a8a8FF:"min" \
LINE2:prumer_avg#202020:"avg" \
--vertical-label "RSS" \
--height 200 \
--width ${width} \
${xgridstr} \
--title "Sila signalu ${name} ${popis}"
}
#if [ $timediff -lt 86400 ]
if [ $timediff -eq 9000 ]
then
rrdtool graph ${target_img_dir}/${name}_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
DEF:rss_avg=${name}.rrd:rss_avg:AVERAGE \
DEF:rss_min=${name}.rrd:rss_min:MIN \
DEF:rss_max=${name}.rrd:rss_max:MAX \
CDEF:maxmin=rss_max,rss_min,- \
HRULE:0#000000 \
AREA:rss_min#FFFFFF \
STACK:maxmin#e0e0e0 \
LINE1:rss_min#a8a8FF:"min" \
LINE1:rss_max#FFa1a1:"max" \
LINE1:rss_avg#202020:"avg" \
--vertical-label "RSS" \
--height 800 \
--width ${width} \
${xgridstr} \
--title "Sila signalu ${name} ${popis}"
else
flow_graph
fi