summaryrefslogtreecommitdiff
path: root/make_graph.sh
blob: 0af9a0a045db19811a54099943493c75e54d384d (plain)
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
41
42
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
#
# Record network device counters every 1 second and write in RRD or plain text.
#
# Copyright 2016 Ludovic Pouzenc <ludovic@pouzenc.fr>
#
# This file is part of if_rrd_fast.
#
# if_rrd_fast is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# if_rrd_fast is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with if_rrd_fast.  If not, see <http://www.gnu.org/licenses/>.
#

rsync -i stg.chd.sx:out.rrd /tmp/

statements="
DEF:dsrxavg=/tmp/out.rrd:rx:AVERAGE
DEF:dstxavg=/tmp/out.rrd:tx:AVERAGE
DEF:dsrxmax=/tmp/out.rrd:rx:MAX
DEF:dstxmax=/tmp/out.rrd:tx:MAX
DEF:dsrxmin=/tmp/out.rrd:rx:MIN
DEF:dstxmin=/tmp/out.rrd:tx:MIN

CDEF:dsrxavgb=dsrxavg,8,*
CDEF:dstxavgb=dstxavg,8,*
CDEF:dsrxmaxb=dsrxmax,8,*
CDEF:dstxmaxb=dstxmax,8,*
CDEF:dsrxminb=dsrxmin,8,*
CDEF:dstxminb=dstxmin,8,*

CDEF:inbound=dsrxavgb,-1,*
CDEF:outbound=dstxavgb,1,*
CDEF:in_max=dsrxmaxb,-1,*
CDEF:out_max=dstxmaxb,1,*
CDEF:in_min=dsrxminb,-1,*
CDEF:out_min=dstxminb,1,*

VDEF:totrxavgmax=dsrxavgb,MAXIMUM
VDEF:totrxavgavg=dsrxavgb,AVERAGE
VDEF:totrxavgpct=dsrxavgb,95,PERCENT
VDEF:tottxavgmax=dstxavgb,MAXIMUM
VDEF:tottxavgavg=dstxavgb,AVERAGE
VDEF:tottxavgpct=dstxavgb,95,PERCENT
VDEF:totrxmaxmax=dsrxmaxb,MAXIMUM
VDEF:tottxmaxmax=dstxmaxb,MAXIMUM

LINE1:0#cccc00

COMMENT:             
COMMENT:Maximum    
COMMENT:Average    
COMMENT:95th%tile\l

AREA:in_max#0099ff:in_max  
GPRINT:totrxmaxmax:%6.2lf %Sbps\l

AREA:out_max#44ff44:out_max 
GPRINT:tottxmaxmax:%6.2lf %Sbps\l

AREA:in_min#ffffff:
AREA:out_min#ffffff:

LINE1:inbound#0066bb:inbound  
GPRINT:totrxavgmax:%6.2lf %Sbps
GPRINT:totrxavgavg:%6.2lf %Sbps
GPRINT:totrxavgpct:%6.2lf %Sbps\l

LINE1:outbound#00aa00:outbound 
GPRINT:tottxavgmax:%6.2lf %Sbps
GPRINT:tottxavgavg:%6.2lf %Sbps
GPRINT:tottxavgpct:%6.2lf %Sbps\l
"

if [ $# -eq 1 ]
then	ts=$1
else	#read -p "Last timestamp ? " ts
	[ -z "$ts" ] && ts=now
fi

for res in 1 60 300 3600
do
	rrdtool graph /var/www/lpo/out$res.png --imgformat PNG --width 1152 --height 720 \
		--start "end-$((1152*$res))s" --end $ts --lower-limit -190000000 --upper-limit 190000000 --rigid \
		--title "Network traffic" $statements
done