rrd_graph_apps.sh 6.11 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$
#

34
35
RRD_DIR=/var/lib/rrd

'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 "   /var/lib/rrd/perfmon-plzen.cesnet.cz-eth1-0-1 \\"
  echo "   /var/lib/rrd/perfmon-plzen.cesnet.cz-eth2-0-1 \\"
  echo "   perfmon-plzen_apps.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

's avatar
committed
63
rrdtool graph ${FILENAME_GRAPH} --width 650 --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
81
82
83
84
85
86
	--title "${TITLE}: applications, 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:http_in=${PREFIX_IN}-http.rrd:mbps:AVERAGE:step=$R1 \
	DEF:https_in=${PREFIX_IN}-https.rrd:mbps:AVERAGE:step=$R1 \
	DEF:ftp_in=${PREFIX_IN}-ftp.rrd:mbps:AVERAGE:step=$R1 \
	DEF:gnutella_in=${PREFIX_IN}-gnutella.rrd:mbps:AVERAGE:step=$R1 \
	DEF:torrent_in=${PREFIX_IN}-torrent.rrd:mbps:AVERAGE:step=$R1 \
	DEF:dc_in=${PREFIX_IN}-dc.rrd:mbps:AVERAGE:step=$R1 \
	DEF:edonkey_in=${PREFIX_IN}-edonkey.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:http_out=${PREFIX_OUT}-http.rrd:mbps:AVERAGE:step=$R1 \
	DEF:https_out=${PREFIX_OUT}-https.rrd:mbps:AVERAGE:step=$R1 \
	DEF:ftp_out=${PREFIX_OUT}-ftp.rrd:mbps:AVERAGE:step=$R1 \
	DEF:gnutella_out=${PREFIX_OUT}-gnutella.rrd:mbps:AVERAGE:step=$R1 \
	DEF:torrent_out=${PREFIX_OUT}-torrent.rrd:mbps:AVERAGE:step=$R1 \
	DEF:dc_out=${PREFIX_OUT}-dc.rrd:mbps:AVERAGE:step=$R1 \
	DEF:edonkey_out=${PREFIX_OUT}-edonkey.rrd:mbps:AVERAGE:step=$R1 \
87
	CDEF:all_out_neg=all_out,-1,* \
's avatar
   
committed
88
89
	CDEF:all_out_neg_avg_r2=all_out_avg_r2,-1,* \
	CDEF:all_out_neg_max_r2=all_out_max_r2,-1,* \
90
91
92
93
94
95
96
	CDEF:http_out_neg=http_out,-1,* \
	CDEF:https_out_neg=https_out,-1,* \
	CDEF:ftp_out_neg=ftp_out,-1,* \
	CDEF:gnutella_out_neg=gnutella_out,-1,* \
	CDEF:torrent_out_neg=torrent_out,-1,* \
	CDEF:dc_out_neg=dc_out,-1,* \
	CDEF:edonkey_out_neg=edonkey_out,-1,* \
's avatar
   
committed
97
	AREA:all_in#FFFF00:"Other" \
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
	LINE:0 \
	AREA:http_in#00FF00:"HTTP":STACK \
	AREA:https_in#FF0000:"HTTPS":STACK \
	AREA:ftp_in#FF00FF:"FTP":STACK \
	AREA:gnutella_in#50AF00:"Gnutella":STACK \
	AREA:torrent_in#AF5000:"BitTorrent":STACK \
	AREA:dc_in#AF50AF:"DC":STACK \
	AREA:edonkey_in#5050AF:"eDonkey":STACK \
	AREA:all_out_neg#FFFF00 \
	LINE:0 \
	AREA:http_out_neg#00FF00::STACK \
	AREA:https_out_neg#FF0000::STACK \
	AREA:ftp_out_neg#FF00FF::STACK \
	AREA:gnutella_out_neg#50FF00::STACK \
	AREA:torrent_out_neg#FF5000::STACK \
	AREA:dc_out_neg#FF50FF::STACK \
	AREA:edonkey_out_neg#5050FF::STACK \
's avatar
   
committed
115
116
117
118
	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 \
119
	LINE:0#000000
120

's avatar
committed
121
else
122

's avatar
committed
123
rrdtool graph ${FILENAME_GRAPH} --width 650 --height 225 \
124
	--start "${START_TIME}" --end "${END_TIME}" \
's avatar
committed
125
	--slope-mode --interlaced --vertical-label "    Mb/s    " \
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
	--title "${TITLE}: applications, 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:http_in=${PREFIX_IN}-http.rrd:mbps:AVERAGE:step=$R1 \
	DEF:https_in=${PREFIX_IN}-https.rrd:mbps:AVERAGE:step=$R1 \
	DEF:ftp_in=${PREFIX_IN}-ftp.rrd:mbps:AVERAGE:step=$R1 \
	DEF:gnutella_in=${PREFIX_IN}-gnutella.rrd:mbps:AVERAGE:step=$R1 \
	DEF:torrent_in=${PREFIX_IN}-torrent.rrd:mbps:AVERAGE:step=$R1 \
	DEF:dc_in=${PREFIX_IN}-dc.rrd:mbps:AVERAGE:step=$R1 \
	DEF:edonkey_in=${PREFIX_IN}-edonkey.rrd:mbps:AVERAGE:step=$R1 \
	AREA:all_in#FFFF00:"Other" \
	LINE:0 \
	AREA:http_in#00FF00:"HTTP":STACK \
	AREA:https_in#FF0000:"HTTPS":STACK \
	AREA:ftp_in#FF00FF:"FTP":STACK \
	AREA:gnutella_in#50AF00:"Gnutella":STACK \
	AREA:torrent_in#AF5000:"BitTorrent":STACK \
	AREA:dc_in#AF50AF:"DC":STACK \
	AREA:edonkey_in#5050AF:"eDonkey":STACK \
	LINE2:all_in_avg_r2#00FFFF:"Average ($R2 seconds)" \
	LINE2:all_in_max_r2#0000FF:"Maximum ($R2 seconds)" \
	LINE:0#000000

fi