1 | 1 | simandl | #!/bin/bash |
2 | | | |
3 | | | name=conntrack |
4 | | | timediff=$1 |
5 | | | suffix=$2 |
6 | | | popis=$3 |
7 | | | width=$4 |
8 | | | |
9 | | | PATH=$PATH:/opt/rrdtool/bin |
10 | | | |
11 | | | datadir=/var/statistiky/system |
12 | | | target_img_dir="/var/www/heaven/stat/img" |
13 | | | |
14 | | | cd $datadir |
15 | | | |
16 | | | xgridstr="" |
17 | | | |
18 | | | if [ $timediff -ge 604800 ] |
19 | | | then |
20 | | | xgridstr="--x-grid HOUR:12:DAY:1:DAY:1:86400:%d.%m." |
21 | | | fi |
22 | | | if [ $timediff -ge 2678400 ] |
23 | | | then |
24 | | | xgridstr="--x-grid DAY:1:DAY:7:DAY:2:86400:%d.%m." |
25 | | | fi |
26 | | | |
27 | | | now=`date +%s` |
28 | | | |
29 | | | rrdtool graph ${target_img_dir}/${name}_tcp_established_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \ |
30 | | | DEF:tcp_est_avg=${name}.rrd:tcp_established:AVERAGE \ |
31 | | | DEF:tcp_est_min=${name}.rrd:tcp_established:MIN \ |
32 | | | DEF:tcp_est_max=${name}.rrd:tcp_established:MAX \ |
33 | | | DEF:syn_sent=${name}.rrd:tcp_syn_sent:MAX \ |
34 | | | DEF:syn_recv=${name}.rrd:tcp_syn_recv:MAX \ |
35 | | | DEF:close=${name}.rrd:tcp_close:MAX \ |
36 | | | DEF:close_wait=${name}.rrd:tcp_close_wait:MAX \ |
37 | | | DEF:fin_wait=${name}.rrd:tcp_fin_wait:MAX \ |
38 | | | DEF:time_wait=${name}.rrd:tcp_time_wait:MAX \ |
39 | | | DEF:udp_max=${name}.rrd:udp:MAX \ |
40 | | | DEF:ip_conntrack_max=${name}.rrd:ip_conntrack_max:MAX \ |
41 | | | CDEF:tcp_all_max=tcp_est_max,syn_sent,syn_recv,close,close_wait,fin_wait,time_wait,+,+,+,+,+,+ \ |
42 | | | CDEF:all_max=udp_max,tcp_all_max,+ \ |
43 | | | LINE2:ip_conntrack_max#e71b1e:"ip_conntrack_max" \ |
44 | | | LINE1:all_max#0000FF:"TCP+UDP (max)" \ |
45 | | | LINE2:tcp_est_avg#00ff00:"established (avg)" \ |
46 | | | LINE1:tcp_est_max#202020:"established (max)" \ |
47 | | | --vertical-label "TCP conntrack" \ |
48 | | | --height 200 \ |
49 | | | --width ${width} \ |
50 | | | ${xgridstr} \ |
51 | | | --title "Established ${name} ${popis}" |
52 | | | |
53 | | | |
54 | | | rrdtool graph ${target_img_dir}/${name}_tcp_other_${suffix}.png --imgformat PNG --start `expr $now - ${timediff}` --end $now \ |
55 | | | DEF:syn_sent=${name}.rrd:tcp_syn_sent:AVERAGE \ |
56 | | | DEF:syn_recv=${name}.rrd:tcp_syn_recv:AVERAGE \ |
57 | | | DEF:close=${name}.rrd:tcp_close:AVERAGE \ |
58 | | | DEF:close_wait=${name}.rrd:tcp_close_wait:AVERAGE \ |
59 | | | DEF:fin_wait=${name}.rrd:tcp_fin_wait:AVERAGE \ |
60 | | | DEF:time_wait=${name}.rrd:tcp_time_wait:AVERAGE \ |
61 | | | DEF:udp=${name}.rrd:udp:AVERAGE \ |
62 | | | AREA:udp#d0d0d0:"UDP" \ |
63 | | | STACK:syn_sent#ff7d7e:"SYN_SENT" \ |
64 | | | STACK:syn_recv#e71b1e:"SYN_RECV" \ |
65 | | | STACK:fin_wait#00ab22:"FIN_WAIT" \ |
66 | | | STACK:close_wait#8598dc:"CLOSE_WAIT" \ |
67 | | | STACK:close#252edc:"CLOSE" \ |
68 | | | STACK:time_wait#909090:"TIME_WAIT" \ |
69 | | | --vertical-label "conntrack" \ |
70 | | | --height 200 \ |
71 | | | --width ${width} \ |
72 | | | ${xgridstr} \ |
73 | | | --title "Other than established ${name} ${popis}" |