rrd_graph_l4.sh 5.24 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
#!/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$
#

's avatar
   
committed
34
RRD_DIR=/usr/local/abw/rrd
35

's avatar
committed
36
37
38
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

if [ $# -ne 8 ]; then
's avatar
   
committed
39
  echo "Usage: $0 <prefix_in> <prefix_out> <filename_graph> <start_time> <end_time> <resolution 1> <resolution 2> <title>"
's avatar
committed
40
  echo "<prefix_out> can be empty string \"\""
's avatar
   
committed
41
42
43
44
45
46
47
48
  echo "Example:"
  echo "$0 \\"
  echo "   /usr/local/abw/rrd/perfmon-plzen.cesnet.cz-eth1-0-1 \\"
  echo "   /usr/local/abw/rrd/perfmon-plzen.cesnet.cz-eth2-0-1 \\"
  echo "   graph-Plzen_PoP-l4.png \\"
  echo "   \"14:33 20060504\" \"15:00 20060504\""
  echo "   1 60"
  echo "   \"CESNET - GN2\""
49
50
51
52
53
54
55
56
  exit -1
fi

PREFIX_IN=$1
PREFIX_OUT=$2
FILENAME_GRAPH=$3
START_TIME=$4
END_TIME=$5
's avatar
   
committed
57
58
59
R1=$6
R2=$7
TITLE=$8
60

's avatar
committed
61
if [ "x$PREFIX_OUT" != "x" ]; then
62
63

rrdtool graph ${FILENAME_GRAPH} --width 600 --height 450 \
64
65
	--start "${START_TIME}" --end "${END_TIME}" \
	--slope-mode --interlaced --vertical-label "out    Mb/s    in" \
's avatar
   
committed
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
	--title "${TITLE}: L4 protocols, interval $R1 second(s), avg/max $R2 seconds" -X 0 \
	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 \
	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 \
	DEF:multicast_out=${PREFIX_OUT}-multicast.rrd:mbps:AVERAGE:step=$R1 \
	DEF:ip6_out=${PREFIX_OUT}-ip6.rrd:mbps:AVERAGE:step=$R1 \
81
82
83
	CDEF:other_in=all_in,tcp_in,-,udp_in,- \
	CDEF:other_out=all_out,tcp_out,-,udp_out,- \
	CDEF:all_out_neg=all_out,-1,* \
's avatar
   
committed
84
85
	CDEF:all_out_neg_avg_r2=all_out_avg_r2,-1,* \
	CDEF:all_out_neg_max_r2=all_out_max_r2,-1,* \
86
87
88
	CDEF:tcp_out_neg=tcp_out,-1,* \
	CDEF:udp_out_neg=udp_out,-1,* \
	CDEF:multicast_out_neg=multicast_out,-1,* \
's avatar
   
committed
89
	CDEF:ip6_out_neg=ip6_out,-1,* \
90
	CDEF:other_out_neg=other_out,-1,* \
's avatar
   
committed
91
	AREA:all_in#FF0000:"Other" \
92
	LINE:0 \
's avatar
   
committed
93
94
95
	AREA:udp_in#FFFF00:"UDP":STACK \
	AREA:tcp_in#00FF00:"TCP":STACK \
	AREA:all_out_neg#FF0000 \
96
	LINE:0 \
's avatar
   
committed
97
98
99
100
101
102
	AREA:udp_out_neg#FFFF00::STACK \
	AREA:tcp_out_neg#00FF00::STACK \
	LINE2:all_in_avg_r2#00FFFF:"$R2 second average" \
	LINE2:all_out_neg_avg_r2#00FFFF \
	LINE2:all_in_max_r2#0000FF:"$R2 second maximum" \
	LINE2:all_out_neg_max_r2#0000FF \
103
104
	LINE2:multicast_in#FF00FF:"Multicast" \
	LINE2:multicast_out_neg#FF00FF \
's avatar
   
committed
105
106
	LINE2:ip6_in#000000D0:"IPv6" \
	LINE2:ip6_out_neg#000000D0 \
107
	LINE:0#000000
108

's avatar
committed
109
else
110

's avatar
committed
111
rrdtool graph ${FILENAME_GRAPH} --width 700 --height 250 \
112
	--start "${START_TIME}" --end "${END_TIME}" \
's avatar
committed
113
	--slope-mode --interlaced --vertical-label "    Mb/s    " \
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
	--title "${TITLE}: L4 protocols, interval $R1 second(s), avg/max $R2 seconds" -X 0 \
	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 \
	DEF:multicast_in=${PREFIX_IN}-multicast.rrd:mbps:AVERAGE:step=$R1 \
	DEF:ip6_in=${PREFIX_IN}-ip6.rrd:mbps:AVERAGE:step=$R1 \
	CDEF:other_in=all_in,tcp_in,-,udp_in,- \
	AREA:all_in#FF0000:"Other" \
	LINE:0 \
	AREA:udp_in#FFFF00:"UDP":STACK \
	AREA:tcp_in#00FF00:"TCP":STACK \
	LINE2:all_in_avg_r2#00FFFF:"$R2 second average" \
	LINE2:all_in_max_r2#0000FF:"$R2 second maximum" \
	LINE2:multicast_in#FF00FF:"Multicast" \
	LINE2:ip6_in#000000D0:"IPv6" \
	LINE:0#000000

fi