jablonka.czprosek.czf

crusader

Subversion Repositories:
[/] [trunk/] [statistiky/] [opt/] [statistiky/] [makeobr_arp.sh] - Blame information for rev 3

 

Line No. Rev Author Line
11simandl#!/bin/bash
2 
3#name=$1 it is always 'arp'
4name=arp
5timediff=$1
6suffix=$2
7popis=$3
8width=$4
9 
10PATH=$PATH:/opt/rrdtool/bin
11 
12datadir=/var/statistiky/arp
13target_img_dir="/var/www/heaven/stat/img"
14 
15cd $datadir
16 
17xgridstr=""
18 
19if [ $timediff -ge 604800 ]
20then
21 xgridstr="--x-grid HOUR:12:DAY:1:DAY:1:86400:%d.%m."
22fi
23if [ $timediff -ge 2678400 ]
24then
25 xgridstr="--x-grid DAY:1:DAY:7:DAY:2:86400:%d.%m."
26fi
27 
28now=`date +%s`
29 
30function simple_graph()
31{
32rrdtool graph ${target_img_dir}/${name}_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
33 DEF:arp_min=${name}.rrd:count:MIN \
34 DEF:arp_max=${name}.rrd:count:MAX \
35 DEF:arp_avg=${name}.rrd:count:AVERAGE \
36 LINE1:arp_max#FF0000:"max" \
37 AREA:arp_avg#a0a0a0:"avg" \
38 LINE1:arp_min#0000FF:"min" \
39 --vertical-label "ARP table size" \
40 --height 200 \
41 --width ${width} \
42 --title "${name} ${popis}"
43}
44 
45 
46# CDEF:prumer_avg=avg1,avg2,avg3,avg4,avg5,+,+,+,+,5,/ \
47# CDEF:prumer_min=min1,min2,min3,min4,min5,+,+,+,+,5,/ \
48# CDEF:prumer_max=max1,max2,max3,max4,max5,+,+,+,+,5,/ \
49 
50# detekce UNKNOWN
51# CDEF:offline=prumer_avg,UN,INF,0,IF \
52# AREA:offline#f3ff73 \
53 
54 
55function flow_graph()
56{
57 rrdtool graph ${target_img_dir}/${name}_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
58 DEF:arp_avg=${name}.rrd:count:AVERAGE \
59 DEF:arp_min=${name}.rrd:count:MIN \
60 DEF:arp_max=${name}.rrd:count:MAX \
61 CDEF:avg1=PREV\(arp_avg\) \
62 CDEF:avg2=PREV\(avg1\) \
63 CDEF:avg3=PREV\(avg2\) \
64 CDEF:avg4=PREV\(avg3\) \
65 CDEF:min1=PREV\(arp_min\) \
66 CDEF:min2=PREV\(min1\) \
67 CDEF:max1=PREV\(arp_max\) \
68 CDEF:max2=PREV\(max1\) \
69 CDEF:prumer_avg=arp_avg,avg1,avg2,avg3,+,+,+,4,/ \
70 CDEF:prumer_min=arp_min,min1,min2,+,+,3,/ \
71 CDEF:prumer_max=arp_max,max1,max2,+,+,3,/ \
72 CDEF:maxmin=max2,min2,- \
73 AREA:min2#FFFFFF \
74 STACK:maxmin#e0e0e0 \
75 LINE1:max2#FFa1a1:"max" \
76 LINE1:min2#a8a8FF:"min" \
77 LINE2:prumer_avg#202020:"avg" \
78 --vertical-label "ARP table size" \
79 --height 200 \
80 --width ${width} \
81 ${xgridstr} \
82 --title "${name} ${popis}"
83}
84 
85if [ $timediff -lt 86400 ]
86then
87 rrdtool graph ${target_img_dir}/${name}_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \
88 DEF:arp_avg=${name}.rrd:count:AVERAGE \
89 LINE2:arp_avg#0000FF:"ARP" \
90 --vertical-label "ARP table size" \
91 --height 200 \
92 --width ${width} \
93 ${xgridstr} \
94 --title "${name} ${popis}"
95else
96 flow_graph
97fi

Powered by WebSVN 2.2.1