rrd_graph_l4.sh 7.36 KB
Newer Older
's avatar
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
#
# Copyright (c) 2006, CESNET
# All rights reserved.
#
# LICENSE TERMS
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the company nor the names of its contributors 
#       may be used to endorse or promote products derived from this 
#       software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
# THE COMPANY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 
# $Id: rrd_graph_l4.sh,v 1.1 2006/11/23 10:32:13 ubik Exp $
#

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

usage() {
  echo "Usage: $0 <prefix_in> <prefix_out> <filename_graph> <start_time> <end_time> <resolution 1> <resolution 2> <title>"
  echo "One of <prefix_in> or <prefix_out> can be empty string \"\""
  echo "Example:"
  echo "$0 \\"
's avatar
committed
41
42
  echo "   /var/lib/abw/rrd/perfmon-plzen.cesnet.cz-eth1-0-1 \\"
  echo "   /var/lib/abw/rrd/perfmon-plzen.cesnet.cz-eth2-0-1 \\"
's avatar
committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  echo "   graph-Plzen_PoP-l4.png \\"
  echo "   \"14:33 20060504\" \"15:00 20060504\""
  echo "   1 60"
  echo "   \"CESNET - GN2\""
}

if [ $# -ne 8 ]; then
  usage
  exit -1
fi

PREFIX_IN=$1
PREFIX_OUT=$2
FILENAME_GRAPH=$3
START_TIME=$4
END_TIME=$5
R1=$6
R2=$7
TITLE=$8

if [ "x$PREFIX_OUT" != "x" -a "x$PREFIX_IN" != "x" ]; then

rrdtool graph ${FILENAME_GRAPH} --width 600 --height 450 \
	--start "${START_TIME}" --end "${END_TIME}" \
	--slope-mode --interlaced --vertical-label "out    Mb/s    in" \
's avatar
committed
68
	--title "${TITLE}: L3/L4 protocols, interval $R1 second(s), avg/max $R2 seconds" -X 0 \
's avatar
committed
69
70
71
72
73
	DEF:all_in=${PREFIX_IN}-all.rrd:mbps:AVERAGE:step=$R1 \
	DEF:all_in_avg_r2=${PREFIX_IN}-all.rrd:mbps:AVERAGE:step=$R2 \
	DEF:all_in_max_r2=${PREFIX_IN}-all.rrd:mbps:MAX:step=$R2 \
	DEF:tcp_in=${PREFIX_IN}-tcp.rrd:mbps:AVERAGE:step=$R1 \
	DEF:udp_in=${PREFIX_IN}-udp.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
74
	DEF:icmp_in=${PREFIX_IN}-icmp.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
75
76
77
78
79
80
81
	DEF:multicast_in=${PREFIX_IN}-multicast.rrd:mbps:AVERAGE:step=$R1 \
	DEF:ip6_in=${PREFIX_IN}-ip6.rrd:mbps:AVERAGE:step=$R1 \
	DEF:all_out=${PREFIX_OUT}-all.rrd:mbps:AVERAGE:step=$R1 \
	DEF:all_out_avg_r2=${PREFIX_OUT}-all.rrd:mbps:AVERAGE:step=$R2 \
	DEF:all_out_max_r2=${PREFIX_OUT}-all.rrd:mbps:MAX:step=$R2 \
	DEF:tcp_out=${PREFIX_OUT}-tcp.rrd:mbps:AVERAGE:step=$R1 \
	DEF:udp_out=${PREFIX_OUT}-udp.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
82
	DEF:icmp_out=${PREFIX_OUT}-icmp.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
83
84
	DEF:multicast_out=${PREFIX_OUT}-multicast.rrd:mbps:AVERAGE:step=$R1 \
	DEF:ip6_out=${PREFIX_OUT}-ip6.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
85
86
	CDEF:other_in=all_in,tcp_in,-,udp_in,-,icmp_in,- \
	CDEF:other_out=all_out,tcp_out,-,udp_out,-,icmp_out,- \
's avatar
committed
87
88
89
90
91
	CDEF:all_out_neg=all_out,-1,* \
	CDEF:all_out_neg_avg_r2=all_out_avg_r2,-1,* \
	CDEF:all_out_neg_max_r2=all_out_max_r2,-1,* \
	CDEF:tcp_out_neg=tcp_out,-1,* \
	CDEF:udp_out_neg=udp_out,-1,* \
's avatar
committed
92
	CDEF:icmp_out_neg=icmp_out,-1,* \
's avatar
committed
93
94
95
96
97
98
	CDEF:multicast_out_neg=multicast_out,-1,* \
	CDEF:ip6_out_neg=ip6_out,-1,* \
	CDEF:other_out_neg=other_out,-1,* \
	AREA:all_in#FF0000:"Other" \
	LINE:0 \
	AREA:udp_in#FFFF00:"UDP":STACK \
's avatar
committed
99
	AREA:icmp_in#AF5000:"ICMP":STACK \
's avatar
committed
100
101
102
103
	AREA:tcp_in#00FF00:"TCP":STACK \
	AREA:all_out_neg#FF0000 \
	LINE:0 \
	AREA:udp_out_neg#FFFF00::STACK \
's avatar
committed
104
	AREA:icmp_out_neg#AF5000::STACK \
's avatar
committed
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
	AREA:tcp_out_neg#00FF00::STACK \
	LINE2:multicast_in#FF00FF:"Multicast" \
	LINE2:multicast_out_neg#FF00FF \
	LINE2:ip6_in#000000D0:"IPv6" \
	LINE2:ip6_out_neg#000000D0 \
	LINE2:all_in_avg_r2#00FFFF:"Average ($R2 seconds)" \
	LINE2:all_out_neg_avg_r2#00FFFF \
	LINE2:all_in_max_r2#0000FF:"Maximum ($R2 seconds)" \
	LINE2:all_out_neg_max_r2#0000FF \
	LINE:0#000000

elif [ "x$PREFIX_IN" != "x" ]; then

rrdtool graph ${FILENAME_GRAPH} --width 600 --height 450 \
	--start "${START_TIME}" --end "${END_TIME}" \
	--slope-mode --interlaced --vertical-label "    Mb/s    in" \
's avatar
committed
121
	--title "${TITLE}: L3/L4 protocols, interval $R1 second(s), avg/max $R2 seconds" -X 0 \
's avatar
committed
122
123
124
125
126
	DEF:all_in=${PREFIX_IN}-all.rrd:mbps:AVERAGE:step=$R1 \
	DEF:all_in_avg_r2=${PREFIX_IN}-all.rrd:mbps:AVERAGE:step=$R2 \
	DEF:all_in_max_r2=${PREFIX_IN}-all.rrd:mbps:MAX:step=$R2 \
	DEF:tcp_in=${PREFIX_IN}-tcp.rrd:mbps:AVERAGE:step=$R1 \
	DEF:udp_in=${PREFIX_IN}-udp.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
127
	DEF:icmp_in=${PREFIX_IN}-icmp.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
128
129
	DEF:multicast_in=${PREFIX_IN}-multicast.rrd:mbps:AVERAGE:step=$R1 \
	DEF:ip6_in=${PREFIX_IN}-ip6.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
130
	CDEF:other_in=all_in,tcp_in,-,udp_in,-,icmp_in,- \
's avatar
committed
131
132
133
134
	AREA:all_in#FF0000:"Other" \
	LINE:0 \
	AREA:udp_in#FFFF00:"UDP":STACK \
	AREA:tcp_in#00FF00:"TCP":STACK \
's avatar
committed
135
	AREA:icmp_in#FF00FF:"ICMP":STACK \
's avatar
committed
136
137
138
139
140
141
142
143
144
145
146
	LINE2:multicast_in#FF00FF:"Multicast" \
	LINE2:ip6_in#000000D0:"IPv6" \
	LINE2:all_in_avg_r2#00FFFF:"Average ($R2 seconds)" \
	LINE2:all_in_max_r2#0000FF:"Maximum ($R2 seconds)" \
	LINE:0#000000

elif [ "x$PREFIX_OUT" != "x" ]; then

rrdtool graph ${FILENAME_GRAPH} --width 600 --height 450 \
	--start "${START_TIME}" --end "${END_TIME}" \
	--slope-mode --interlaced --vertical-label "out    Mb/s    " \
's avatar
committed
147
	--title "${TITLE}: L3/L4 protocols, interval $R1 second(s), avg/max $R2 seconds" -X 0 \
's avatar
committed
148
149
150
151
152
	DEF:all_out=${PREFIX_OUT}-all.rrd:mbps:AVERAGE:step=$R1 \
	DEF:all_out_avg_r2=${PREFIX_OUT}-all.rrd:mbps:AVERAGE:step=$R2 \
	DEF:all_out_max_r2=${PREFIX_OUT}-all.rrd:mbps:MAX:step=$R2 \
	DEF:tcp_out=${PREFIX_OUT}-tcp.rrd:mbps:AVERAGE:step=$R1 \
	DEF:udp_out=${PREFIX_OUT}-udp.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
153
	DEF:icmp_out=${PREFIX_OUT}-icmp.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
154
155
	DEF:multicast_out=${PREFIX_OUT}-multicast.rrd:mbps:AVERAGE:step=$R1 \
	DEF:ip6_out=${PREFIX_OUT}-ip6.rrd:mbps:AVERAGE:step=$R1 \
's avatar
committed
156
	CDEF:other_out=all_out,tcp_out,-,udp_out,-,icmp_out,- \
's avatar
committed
157
158
159
160
161
	CDEF:all_out_neg=all_out,-1,* \
	CDEF:all_out_neg_avg_r2=all_out_avg_r2,-1,* \
	CDEF:all_out_neg_max_r2=all_out_max_r2,-1,* \
	CDEF:tcp_out_neg=tcp_out,-1,* \
	CDEF:udp_out_neg=udp_out,-1,* \
's avatar
committed
162
	CDEF:icmp_out_neg=icmp_out,-1,* \
's avatar
committed
163
164
165
166
167
168
169
	CDEF:multicast_out_neg=multicast_out,-1,* \
	CDEF:ip6_out_neg=ip6_out,-1,* \
	CDEF:other_out_neg=other_out,-1,* \
	AREA:all_out_neg#FF0000:"Other" \
	LINE:0 \
	AREA:udp_out_neg#FFFF00:"UDP":STACK \
	AREA:tcp_out_neg#00FF00:"TCP":STACK \
's avatar
committed
170
	AREA:icmp_out_neg#FF00FF:"ICMP":STACK \
's avatar
committed
171
172
173
174
175
176
177
178
179
180
181
182
183
184
	LINE2:multicast_out_neg#FF00FF:"Multicast" \
	LINE2:ip6_out_neg#000000D0:"IPv6" \
	LINE2:all_out_neg_avg_r2#00FFFF:"Average ($R2 seconds)" \
	LINE2:all_out_neg_max_r2#0000FF:"Maximum ($R2 seconds)" \
	LINE:0#000000

else

	echo "At least one of <prefix_in> or <prefix_out> must be non-empty"
	echo ""
	usage
	exit -1

fi