jablonka.czprosek.czf

crusader

Subversion Repositories:
[/] [trunk/] [statistiky/] [opt/] [statistiky/] [archiv/] [makeobr_ping.sh.20060131] - Blame information for rev 2

 

Line No. Rev Author Line
11simandl#!/bin/bash
2 
3if [ $# -lt 4 ]
4then
5 echo "Usage: `basename $0` <target name> <time interval> <file suffix> <graph comment> [graph width]"
6 exit 1;
7fi
8 
9name=$1
10timediff=$2
11suffix=$3
12popis=$4
13 
14if [ $# -ge 5 ]
15then
16 width=$5
17else
18 width=400
19fi
20 
21PATH=$PATH:/opt/rrdtool/bin
22 
23datadir="/var/statistiky/ping"
24target_img_dir="/var/www/heaven/stat/img"
25 
26cd $datadir
27 
28now=`date +%s`
29 
30if [ $timediff -ge 604800 ]
31then
32 xgridstr="--x-grid HOUR:12:DAY:1:DAY:1:86400:%d.%m."
33else
34 xgridstr=""
35fi
36 
37function flow_graph()
38{
39 rrdtool graph ${target_img_dir}/ping_${name}_rtt_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
40 DEF:rttmin=${name}.rrd:rttmin:MIN \
41 DEF:rttmax=${name}.rrd:rttmax:MAX \
42 DEF:rttavg=${name}.rrd:rttavg:AVERAGE \
43 DEF:rttmdev=${name}.rrd:rttmdev:AVERAGE \
44 CDEF:avg1=PREV\(rttavg\) \
45 CDEF:avg2=PREV\(avg1\) \
46 CDEF:min1=PREV\(rttmin\) \
47 CDEF:min2=PREV\(min1\) \
48 CDEF:max1=PREV\(rttmax\) \
49 CDEF:max2=PREV\(max1\) \
50 CDEF:mdev1=PREV\(rttmdev\) \
51 CDEF:mdev2=PREV\(mdev1\) \
52 CDEF:prumer_rttavg=rttavg,avg1,avg2,+,+,3,/ \
53 CDEF:prumer_rttmdev=rttmdev,mdev1,mdev2,+,+,3,/ \
54 CDEF:maxmin=rttmax,rttmin,- \
55 AREA:rttmin#FFFFFF \
56 STACK:maxmin#e0e0e0 \
57 LINE1:rttmax#FFa1a1:"max" \
58 LINE1:rttmin#a8a8FF:"min" \
59 LINE2:prumer_rttavg#202020:"avg" \
60 --vertical-label "Round Trip Time [ms]" \
61 --height 200 \
62 --width ${width} \
63 ${xgridstr} \
64 --title "${name} ${popis}" \
65 --lower-limit 0 \
66 --upper-limit 1
67 
68 rrdtool graph ${target_img_dir}/ping_${name}_pktloss_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
69 DEF:pl_avg=${name}.rrd:pktloss:AVERAGE \
70 DEF:pl_min=${name}.rrd:pktloss:MIN \
71 DEF:pl_max=${name}.rrd:pktloss:MAX \
72 CDEF:avg1=PREV\(pl_avg\) \
73 CDEF:avg2=PREV\(avg1\) \
74 CDEF:min1=PREV\(pl_min\) \
75 CDEF:min2=PREV\(min1\) \
76 CDEF:max1=PREV\(pl_max\) \
77 CDEF:max2=PREV\(max1\) \
78 CDEF:prumer_pktloss=pl_avg,avg1,avg2,+,+,3,/ \
79 CDEF:maxmin=pl_max,pl_min,- \
80 HRULE:5#000000 \
81 AREA:pl_min#FFFFFF \
82 STACK:maxmin#e0e0e0 \
83 LINE1:pl_max#FFa1a1:"max" \
84 LINE1:pl_min#a8a8FF:"min" \
85 LINE2:prumer_pktloss#202020:"avg" \
86 --vertical-label "Packet loss [%]" \
87 --height 200 \
88 --width ${width} \
89 ${xgridstr} \
90 --title "${name} ${popis}" \
91 --lower-limit 0 \
92 --upper-limit 5
93}
94function flow_graph_7200()
95{
96 rrdtool graph ${target_img_dir}/ping_${name}_rtt_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
97 DEF:rttavg=${name}.rrd:rttavg:AVERAGE \
98 DEF:rttmdev=${name}.rrd:rttmdev:AVERAGE \
99 CDEF:avg1=PREV\(rttavg\) \
100 CDEF:avg2=PREV\(avg1\) \
101 CDEF:min_agg=rttavg,avg1,avg2,MIN,MIN \
102 CDEF:max_agg=rttavg,avg1,avg2,MAX,MAX \
103 CDEF:mdev1=PREV\(rttmdev\) \
104 CDEF:mdev2=PREV\(mdev1\) \
105 CDEF:prumer_rttavg=rttavg,avg1,avg2,+,+,3,/ \
106 CDEF:prumer_rttmdev=rttmdev,mdev1,mdev2,+,+,3,/ \
107 CDEF:maxmin=max_agg,min_agg,- \
108 AREA:min_agg#FFFFFF \
109 STACK:maxmin#e0e0e0 \
110 LINE1:max_agg#FFa1a1:"max" \
111 LINE1:min_agg#a8a8FF:"min" \
112 LINE2:prumer_rttavg#202020:"avg" \
113 --vertical-label "Round Trip Time [ms]" \
114 --height 200 \
115 --width ${width} \
116 ${xgridstr} \
117 --title "${name} ${popis}" \
118 --lower-limit 0 \
119 --upper-limit 1
120 
121 rrdtool graph ${target_img_dir}/ping_${name}_pktloss_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
122 DEF:pl_avg=${name}.rrd:pktloss:AVERAGE \
123 CDEF:avg1=PREV\(pl_avg\) \
124 CDEF:avg2=PREV\(avg1\) \
125 CDEF:min_agg=pl_avg,avg1,avg2,MIN,MIN \
126 CDEF:max_agg=pl_avg,avg1,avg2,MAX,MAX \
127 CDEF:prumer_pktloss=pl_avg,avg1,avg2,+,+,3,/ \
128 CDEF:maxmin=max_agg,min_agg,- \
129 HRULE:5#000000 \
130 AREA:min_agg#FFFFFF \
131 STACK:maxmin#e0e0e0 \
132 LINE1:max_agg#FFa1a1:"max" \
133 LINE1:min_agg#a8a8FF:"min" \
134 LINE2:prumer_pktloss#202020:"avg" \
135 --vertical-label "Packet loss [%]" \
136 --height 200 \
137 --width ${width} \
138 ${xgridstr} \
139 --title "${name} ${popis}" \
140 --lower-limit 0 \
141 --upper-limit 5
142}
143 
144if [ $timediff -lt 86400 ]
145then
146 flow_graph_7200
147else
148 flow_graph
149fi

Powered by WebSVN 2.2.1