summaryrefslogtreecommitdiff
path: root/make_graph.sh
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2016-05-01 16:07:10 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2016-05-01 16:07:10 +0200
commit0264e42fe2d28da57b4e2bad51fe760cd4ddbc6d (patch)
tree562d81ae9eef922a2cabfcdfe006606c09f62ba3 /make_graph.sh
parent625daa2239cbacce0645f151b3672cefb990b0b7 (diff)
downloadif_rrd_fast-0264e42fe2d28da57b4e2bad51fe760cd4ddbc6d.zip
if_rrd_fast-0264e42fe2d28da57b4e2bad51fe760cd4ddbc6d.tar.gz
if_rrd_fast-0264e42fe2d28da57b4e2bad51fe760cd4ddbc6d.tar.bz2
Licence fix + rddtool graph wrapper to output graphs
Diffstat (limited to 'make_graph.sh')
-rwxr-xr-xmake_graph.sh83
1 files changed, 83 insertions, 0 deletions
diff --git a/make_graph.sh b/make_graph.sh
new file mode 100755
index 0000000..5cd3074
--- /dev/null
+++ b/make_graph.sh
@@ -0,0 +1,83 @@
+#!/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:ds0=/tmp/out.rrd:rx:AVERAGE
+DEF:ds1=/tmp/out.rrd:tx:AVERAGE
+DEF:ds2=/tmp/out.rrd:rx:MAX
+DEF:ds3=/tmp/out.rrd:tx:MAX
+CDEF:ds0b=ds0,8,*
+CDEF:ds1b=ds1,8,*
+CDEF:ds2b=ds2,8,*
+CDEF:ds3b=ds3,8,*
+CDEF:inbound=ds0b,-1,*
+CDEF:outbound=ds1b,1,*
+CDEF:in_peak=ds2b,-1,*
+CDEF:out_peak=ds3b,1,*
+VDEF:ds0max=ds0b,MAXIMUM
+VDEF:ds0avg=ds0b,AVERAGE
+VDEF:ds0pct=ds0b,95,PERCENT
+VDEF:ds1max=ds1b,MAXIMUM
+VDEF:ds1avg=ds1b,AVERAGE
+VDEF:ds1pct=ds1b,95,PERCENT
+VDEF:ds2max=ds2b,MAXIMUM
+VDEF:ds3max=ds3b,MAXIMUM
+
+LINE1:0#cccc00
+
+COMMENT:             
+COMMENT:Maximum    
+COMMENT:Average    
+COMMENT:95th%tile\l
+
+AREA:inbound#0099ff:inbound  
+GPRINT:ds0max:%6.2lf %Sbps
+GPRINT:ds0avg:%6.2lf %Sbps
+GPRINT:ds0pct:%6.2lf %Sbps\l
+
+AREA:outbound#44ff44:outbound 
+GPRINT:ds1max:%6.2lf %Sbps
+GPRINT:ds1avg:%6.2lf %Sbps
+GPRINT:ds1pct:%6.2lf %Sbps\l
+
+LINE1:in_peak#0066bb:in_peak  
+GPRINT:ds2max:%6.2lf %Sbps\l
+
+LINE1:out_peak#00aa00:out_peak 
+GPRINT:ds3max:%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