| 1 | 1 | simandl | #!/bin/bash |
| 2 | | | |
| 3 | | | timediff=$1 |
| 4 | | | suffix=$2 |
| 5 | | | popis=$3 |
| 6 | | | |
| 7 | | | if [ $# -ge 4 ] |
| 8 | | | then |
| 9 | | | width=$4 |
| 10 | | | else |
| 11 | | | width=400 |
| 12 | | | fi |
| 13 | | | |
| 14 | | | PATH=$PATH:/opt/rrdtool/bin |
| 15 | | | |
| 16 | | | datadir=/var/statistiky/rates |
| 17 | | | target_img_dir="/var/www/heaven/stat/img" |
| 18 | | | |
| 19 | | | cd $datadir |
| 20 | | | |
| 21 | | | now=`date +%s` |
| 22 | | | |
| 23 | | | xgridstr="" |
| 24 | | | linesize="2" |
| 25 | | | if [ $timediff -gt 108000 ]; then xgridstr="--x-grid HOUR:6:DAY:1:DAY:1:86400:%d.%m."; fi |
| 26 | | | if [ $timediff -gt 777600 ]; then xgridstr="--x-grid DAY:1:WEEK:1:WEEK:1:86400:%d.%m."; fi |
| 27 | | | if [ $timediff -gt 6912000 ]; then xgridstr=""; linesize="1"; fi # pro >80 dni opet default |
| 28 | | | |
| 29 | | | rrdtool graph ${target_img_dir}/allinone_${suffix}.png --imgformat PNG --start `expr $now - $timediff` --end $now \ |
| 30 | | | DEF:eth1_in=eth1.rrd:input:AVERAGE \ |
| 31 | | | DEF:eth1_out=eth1.rrd:output:AVERAGE \ |
| 32 | | | DEF:eth2_in=eth2.rrd:input:AVERAGE \ |
| 33 | | | DEF:eth2_out=eth2.rrd:output:AVERAGE \ |
| 34 | | | DEF:eth0_in=eth0.rrd:input:AVERAGE \ |
| 35 | | | DEF:eth0_out=eth0.rrd:output:AVERAGE \ |
| 36 | | | DEF:eth4_in=eth4.rrd:input:AVERAGE \ |
| 37 | | | DEF:eth4_out=eth4.rrd:output:AVERAGE \ |
| 38 | | | DEF:eth5_in=eth5.rrd:input:AVERAGE \ |
| 39 | | | DEF:eth5_out=eth5.rrd:output:AVERAGE \ |
| 40 | | | DEF:eth6_in=eth6.rrd:input:AVERAGE \ |
| 41 | | | DEF:eth6_out=eth6.rrd:output:AVERAGE \ |
| 42 | | | DEF:eth8_in=eth8.rrd:input:AVERAGE \ |
| 43 | | | DEF:eth8_out=eth8.rrd:output:AVERAGE \ |
| 44 | | | DEF:eth9_in=eth9.rrd:input:AVERAGE \ |
| 45 | | | DEF:eth9_out=eth9.rrd:output:AVERAGE \ |
| 46 | | | CDEF:eth1_in_final=eth1_in,8,* \ |
| 47 | | | CDEF:eth2_in_final=eth2_in,8,* \ |
| 48 | | | CDEF:eth0_in_final=eth0_in,8,* \ |
| 49 | | | CDEF:eth4_in_final=eth4_in,8,* \ |
| 50 | | | CDEF:eth5_in_final=eth5_in,8,* \ |
| 51 | | | CDEF:eth6_in_final=eth6_in,8,* \ |
| 52 | | | CDEF:eth8_in_final=eth8_in,8,* \ |
| 53 | | | CDEF:eth9_in_final=eth9_in,8,* \ |
| 54 | | | CDEF:eth1_out_final=eth1_out,-8,* \ |
| 55 | | | CDEF:eth2_out_final=eth2_out,-8,* \ |
| 56 | | | CDEF:eth0_out_final=eth0_out,-8,* \ |
| 57 | | | CDEF:eth4_out_final=eth4_out,-8,* \ |
| 58 | | | CDEF:eth5_out_final=eth5_out,-8,* \ |
| 59 | | | CDEF:eth6_out_final=eth6_out,-8,* \ |
| 60 | | | CDEF:eth8_out_final=eth8_out,-8,* \ |
| 61 | | | CDEF:eth9_out_final=eth9_out,-8,* \ |
| 62 | | | LINE2:eth1_in_final#fcff00:"eth1 IN" \ |
| 63 | | | LINE2:eth1_out_final#feff8f:"eth1 OUT" \ |
| 64 | | | LINE2:eth2_in_final#0000FF:"eth2 IN" \ |
| 65 | | | LINE2:eth2_out_final#6464ec:"eth2 OUT" \ |
| 66 | | | LINE2:eth0_in_final#ea00ff:"eth0 IN" \ |
| 67 | | | LINE2:eth0_out_final#f583ff:"eth0 OUT" \ |
| 68 | | | LINE2:eth4_in_final#FF0000:"eth4 IN" \ |
| 69 | | | LINE2:eth4_out_final#ffa1a5:"eth4 OUT" \ |
| 70 | | | LINE1:eth5_in_final#000000:"eth5 IN" \ |
| 71 | | | LINE1:eth5_out_final#888888:"eth5 OUT" \ |
| 72 | | | LINE2:eth8_in_final#00ffff:"eth8 IN" \ |
| 73 | | | LINE2:eth8_out_final#7dfdff:"eth8 OUT" \ |
| 74 | | | LINE2:eth9_in_final#00FF00:"eth9 IN" \ |
| 75 | | | LINE2:eth9_out_final#99ffa6:"eth9 OUT" \ |
| 76 | | | --vertical-label bits/s \ |
| 77 | | | --height 200 \ |
| 78 | | | --width $width \ |
| 79 | | | ${xgridstr} \ |
| 80 | | | --title "${popis}" |
| 81 | | | |
| 82 | | | |
| 83 | | | width=900 |
| 84 | | | rrdtool graph ${target_img_dir}/rate_celkem_${suffix}.png --imgformat PNG --start `expr $now - $timediff` --end $now \ |
| 85 | | | DEF:eth0_in=eth0.rrd:input:AVERAGE \ |
| 86 | | | DEF:eth0_out=eth0.rrd:output:AVERAGE \ |
| 87 | | | DEF:eth1_in=eth1.rrd:input:AVERAGE \ |
| 88 | | | DEF:eth1_out=eth1.rrd:output:AVERAGE \ |
| 89 | | | DEF:eth2_in=eth2.rrd:input:AVERAGE \ |
| 90 | | | DEF:eth2_out=eth2.rrd:output:AVERAGE \ |
| 91 | | | DEF:eth3_in=eth3.rrd:input:AVERAGE \ |
| 92 | | | DEF:eth3_out=eth3.rrd:output:AVERAGE \ |
| 93 | | | DEF:eth4_in=eth4.rrd:input:AVERAGE \ |
| 94 | | | DEF:eth4_out=eth4.rrd:output:AVERAGE \ |
| 95 | | | DEF:eth5_in=eth5.rrd:input:AVERAGE \ |
| 96 | | | DEF:eth5_out=eth5.rrd:output:AVERAGE \ |
| 97 | | | DEF:eth6_in=eth6.rrd:input:AVERAGE \ |
| 98 | | | DEF:eth6_out=eth6.rrd:output:AVERAGE \ |
| 99 | | | DEF:eth7_in=eth7.rrd:input:AVERAGE \ |
| 100 | | | DEF:eth7_out=eth7.rrd:output:AVERAGE \ |
| 101 | | | DEF:eth8_in=eth8.rrd:input:AVERAGE \ |
| 102 | | | DEF:eth8_out=eth8.rrd:output:AVERAGE \ |
| 103 | | | DEF:eth9_in=eth9.rrd:input:AVERAGE \ |
| 104 | | | DEF:eth9_out=eth9.rrd:output:AVERAGE \ |
| 105 | | | CDEF:celkem_in=eth0_in,eth1_in,eth2_in,eth3_in,eth4_in,eth5_in,eth6_in,eth7_in,eth8_in,eth9_in,+,+,+,+,+,+,+,+,+,8,* \ |
| 106 | | | CDEF:celkem_out=eth0_out,eth1_out,eth2_out,eth3_out,eth4_out,eth5_out,eth6_out,eth7_out,eth8_out,eth9_out,+,+,+,+,+,+,+,+,+,8,* \ |
| 107 | | | AREA:celkem_in#ffa1a5:"IN" \ |
| 108 | | | LINE${linesize}:celkem_out#6464ec:"OUT" \ |
| 109 | | | --vertical-label bit/s \ |
| 110 | | | --height 200 \ |
| 111 | | | --width $width \ |
| 112 | | | --lower-limit 0 \ |
| 113 | | | ${xgridstr} \ |
| 114 | | | --title "Celkovy prutok (${popis})" |