2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Initial version

This commit is contained in:
wandrer _KaszpiR_ 2009-09-28 11:47:45 +02:00 committed by Steve Schnepp
parent 9e0ff89cc2
commit 69d3d4a59e

67
plugins/other/vnstat_ Executable file
View File

@ -0,0 +1,67 @@
#! /bin/bash
#
# Simple munin plugin to get total traffic transferred on all network interfaces.
# Uses vnStat to keep track of the traffic.
#
# author: wandrer (wandrer@gmail.com)
# site: http://roguenoise.org/munin_plugin_vnstat
#
# If the plugin is run as root it will update the vnStat database before getting
# the stats.
#
# 2009.09.28 _KaszpiR_
# - quick an ddirty update to support multiple interfaces, for example symlink vnstat_ to vnstat_eth0 and vnstat_eth1
# rember to run before that vnstat -u -i eth0 and vnstat -u -i eth1 to build databases (read manual of vnstat)
# other updates of this script maybe soon
IFACE=`echo $0 | awk -F_ '{print $1}'
# Config section
if [ "$1" = "config" ]; then
echo 'graph_title Total Traffic'
echo 'graph_args --base 1000 --lower-limit 0'
echo 'graph_vlabel Traffic'
echo 'graph_category network'
echo 'graph_info Total network traffic in bytes.'
echo 'totaltx.label Sent'
echo 'totaltx.info Total data sent.'
echo 'totaltx.cdef totaltx,1000000,*'
echo 'totalrx.label Received'
echo 'totalrx.info Total data received.'
echo 'totalrx.cdef totalrx,1000000,*'
exit 0
fi;
# The Script
# Running as root?
if [ `whoami` = "root" ]; then
`vnstat -u`
fi;
# Grabs the totals from the database.
TOTALSRX=`vnstat --dumpdb -i $IFACE | grep 'totalrx;' | cut -d';' -f2`
TOTALSTX=`vnstat --dumpdb -i $IFACE | grep 'totaltx;' | cut -d';' -f2`
TOTALSRXMB=0
TOTALSTXMB=0
for TOTALRX in $TOTALSRX
do
let 'TOTALSRXMB += TOTALRX'
done
for TOTALTX in $TOTALSTX
do
let 'TOTALSTXMB += TOTALTX'
done
echo 'totalrx.value' $TOTALSRXMB
echo 'totaltx.value' $TOTALSTXMB
exit 0