diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2016-05-01 16:07:10 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2016-05-01 16:07:10 +0200 |
commit | 0264e42fe2d28da57b4e2bad51fe760cd4ddbc6d (patch) | |
tree | 562d81ae9eef922a2cabfcdfe006606c09f62ba3 | |
parent | 625daa2239cbacce0645f151b3672cefb990b0b7 (diff) | |
download | if_rrd_fast-0264e42fe2d28da57b4e2bad51fe760cd4ddbc6d.zip if_rrd_fast-0264e42fe2d28da57b4e2bad51fe760cd4ddbc6d.tar.gz if_rrd_fast-0264e42fe2d28da57b4e2bad51fe760cd4ddbc6d.tar.bz2 |
Licence fix + rddtool graph wrapper to output graphs
-rwxr-xr-x | if_rrd_fast.py | 4 | ||||
-rwxr-xr-x | make_graph.sh | 83 |
2 files changed, 86 insertions, 1 deletions
diff --git a/if_rrd_fast.py b/if_rrd_fast.py index 8d7fb24..8e16124 100755 --- a/if_rrd_fast.py +++ b/if_rrd_fast.py @@ -4,6 +4,8 @@ # # 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 @@ -15,7 +17,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with CHD OpenWRT. If not, see <http://www.gnu.org/licenses/>. +# along with if_rrd_fast. If not, see <http://www.gnu.org/licenses/>. # import sys,os,signal,argparse from time import time,sleep; 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 |