crusader |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/bin/bash
timediff=$1
suffix=$2
popis=$3
if [ $# -ge 4 ]
then
width=$4
else
width=400
fi
PATH=$PATH:/opt/rrdtool/bin
datadir=/var/statistiky/rates
target_img_dir="/var/www/heaven/stat/img"
cd $datadir
now=`date +%s`
xgridstr=""
linesize="2"
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
if [ $timediff -gt 6912000 ]; then xgridstr=""; linesize="1"; fi # pro >80 dni opet default
rrdtool graph ${target_img_dir}/allinone_${suffix}.png --imgformat PNG --start `expr $now - $timediff` --end $now \
DEF:eth1_in=eth1.rrd:input:AVERAGE \
DEF:eth1_out=eth1.rrd:output:AVERAGE \
DEF:eth2_in=eth2.rrd:input:AVERAGE \
DEF:eth2_out=eth2.rrd:output:AVERAGE \
DEF:eth0_in=eth0.rrd:input:AVERAGE \
DEF:eth0_out=eth0.rrd:output:AVERAGE \
DEF:eth4_in=eth4.rrd:input:AVERAGE \
DEF:eth4_out=eth4.rrd:output:AVERAGE \
DEF:eth5_in=eth5.rrd:input:AVERAGE \
DEF:eth5_out=eth5.rrd:output:AVERAGE \
DEF:eth6_in=eth6.rrd:input:AVERAGE \
DEF:eth6_out=eth6.rrd:output:AVERAGE \
DEF:eth8_in=eth8.rrd:input:AVERAGE \
DEF:eth8_out=eth8.rrd:output:AVERAGE \
DEF:eth9_in=eth9.rrd:input:AVERAGE \
DEF:eth9_out=eth9.rrd:output:AVERAGE \
CDEF:eth1_in_final=eth1_in,8,* \
CDEF:eth2_in_final=eth2_in,8,* \
CDEF:eth0_in_final=eth0_in,8,* \
CDEF:eth4_in_final=eth4_in,8,* \
CDEF:eth5_in_final=eth5_in,8,* \
CDEF:eth6_in_final=eth6_in,8,* \
CDEF:eth8_in_final=eth8_in,8,* \
CDEF:eth9_in_final=eth9_in,8,* \
CDEF:eth1_out_final=eth1_out,-8,* \
CDEF:eth2_out_final=eth2_out,-8,* \
CDEF:eth0_out_final=eth0_out,-8,* \
CDEF:eth4_out_final=eth4_out,-8,* \
CDEF:eth5_out_final=eth5_out,-8,* \
CDEF:eth6_out_final=eth6_out,-8,* \
CDEF:eth8_out_final=eth8_out,-8,* \
CDEF:eth9_out_final=eth9_out,-8,* \
LINE2:eth1_in_final#fcff00:"eth1 IN" \
LINE2:eth1_out_final#feff8f:"eth1 OUT" \
LINE2:eth2_in_final#0000FF:"eth2 IN" \
LINE2:eth2_out_final#6464ec:"eth2 OUT" \
LINE2:eth0_in_final#ea00ff:"eth0 IN" \
LINE2:eth0_out_final#f583ff:"eth0 OUT" \
LINE2:eth4_in_final#FF0000:"eth4 IN" \
LINE2:eth4_out_final#ffa1a5:"eth4 OUT" \
LINE1:eth5_in_final#000000:"eth5 IN" \
LINE1:eth5_out_final#888888:"eth5 OUT" \
LINE2:eth8_in_final#00ffff:"eth8 IN" \
LINE2:eth8_out_final#7dfdff:"eth8 OUT" \
LINE2:eth9_in_final#00FF00:"eth9 IN" \
LINE2:eth9_out_final#99ffa6:"eth9 OUT" \
--vertical-label bits/s \
--height 200 \
--width $width \
${xgridstr} \
--title "${popis}"
width=900
rrdtool graph ${target_img_dir}/rate_celkem_${suffix}.png --imgformat PNG --start `expr $now - $timediff` --end $now \
DEF:eth0_in=eth0.rrd:input:AVERAGE \
DEF:eth0_out=eth0.rrd:output:AVERAGE \
DEF:eth1_in=eth1.rrd:input:AVERAGE \
DEF:eth1_out=eth1.rrd:output:AVERAGE \
DEF:eth2_in=eth2.rrd:input:AVERAGE \
DEF:eth2_out=eth2.rrd:output:AVERAGE \
DEF:eth3_in=eth3.rrd:input:AVERAGE \
DEF:eth3_out=eth3.rrd:output:AVERAGE \
DEF:eth4_in=eth4.rrd:input:AVERAGE \
DEF:eth4_out=eth4.rrd:output:AVERAGE \
DEF:eth5_in=eth5.rrd:input:AVERAGE \
DEF:eth5_out=eth5.rrd:output:AVERAGE \
DEF:eth6_in=eth6.rrd:input:AVERAGE \
DEF:eth6_out=eth6.rrd:output:AVERAGE \
DEF:eth7_in=eth7.rrd:input:AVERAGE \
DEF:eth7_out=eth7.rrd:output:AVERAGE \
DEF:eth8_in=eth8.rrd:input:AVERAGE \
DEF:eth8_out=eth8.rrd:output:AVERAGE \
DEF:eth9_in=eth9.rrd:input:AVERAGE \
DEF:eth9_out=eth9.rrd:output:AVERAGE \
CDEF:celkem_in=eth0_in,eth1_in,eth2_in,eth3_in,eth4_in,eth5_in,eth6_in,eth7_in,eth8_in,eth9_in,+,+,+,+,+,+,+,+,+,8,* \
CDEF:celkem_out=eth0_out,eth1_out,eth2_out,eth3_out,eth4_out,eth5_out,eth6_out,eth7_out,eth8_out,eth9_out,+,+,+,+,+,+,+,+,+,8,* \
AREA:celkem_in#ffa1a5:"IN" \
LINE${linesize}:celkem_out#6464ec:"OUT" \
--vertical-label bit/s \
--height 200 \
--width $width \
--lower-limit 0 \
${xgridstr} \
--title "Celkovy prutok (${popis})"