2009-02-05 13:02:46 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2018-08-02 02:03:42 +02:00
|
|
|
# Patched version of ip_ plugin to support IPv6 and ip6tables.
|
2009-02-05 13:02:46 +01:00
|
|
|
# Most of plugin done by munin core developers. Modified for IPv6 support
|
|
|
|
# by Lasse Karstensen <lasse.karstensen@gmail.com> February 2009.
|
|
|
|
#
|
|
|
|
# Wildcard-plugin to monitor IP addresses through ip6tables. To monitor an
|
|
|
|
# IP, link ip6_<ipaddress> to this file with : replaced with _. E.g.
|
|
|
|
#
|
|
|
|
# ln -s /usr/share/node/node/plugins-auto/ip6_ /etc/munin/plugins/ip_2001_db8_1__100
|
|
|
|
#
|
|
|
|
# ...will monitor the IP 2001:db8:1::10.
|
|
|
|
#
|
|
|
|
# Additionally, you need these ip6tables rules as the first rules (they don't do anything, just make packet counts)
|
|
|
|
#
|
|
|
|
# ip6tables -A INPUT -d 2001:db8:1::10
|
|
|
|
# ip6tables -A OUTPUT -s 2001:db8:1::10
|
|
|
|
#
|
|
|
|
# Furthermore, this plugin needs to be run as root for ip6tables to work.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Magic markers (optional - used by munin-config and some installation
|
|
|
|
# scripts):
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf suggest
|
|
|
|
|
|
|
|
IP=`basename $0 | sed 's/^ip6_//g' | tr '_' ':' `
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
if [ -r /proc/net/dev ]; then
|
2018-02-24 22:58:04 +01:00
|
|
|
ip6tables -L INPUT -v -n -x -w >/dev/null 2>/dev/null
|
2009-02-05 13:02:46 +01:00
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
echo "no (could not run ip6tables as user `whoami`)"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo yes
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "no (/proc/net/dev not found)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "suggest" ]; then
|
2018-02-24 22:58:04 +01:00
|
|
|
ip6tables -L INPUT -v -n -x -w 2>/dev/null | awk --posix '$8 ~ /^([0-9a-f]{1,4}(\:|\:\:)){1,7}([0-9a-f]{1,4})\/([0-9]{1,3})$/ { if (done[$8]!=1) {print $8; done[$8]=1;}}'|sed "s#/[0-9]\{1,3\}##"
|
2009-02-05 13:02:46 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
2011-05-19 17:56:39 +02:00
|
|
|
echo "graph_order out in"
|
|
|
|
echo "graph_title $IP IPv6 traffic"
|
|
|
|
echo 'graph_args --base 1000'
|
|
|
|
echo 'graph_vlabel bits per ${graph_period}'
|
2009-02-05 13:02:46 +01:00
|
|
|
echo 'graph_category network'
|
2011-05-19 17:56:39 +02:00
|
|
|
echo 'out.label sent'
|
|
|
|
echo 'out.type DERIVE'
|
|
|
|
echo 'out.min 0'
|
|
|
|
echo 'out.cdef out,8,*'
|
|
|
|
echo 'in.label received'
|
|
|
|
echo 'in.type DERIVE'
|
|
|
|
echo 'in.min 0'
|
2018-08-02 02:03:42 +02:00
|
|
|
echo 'in.cdef in,8,*'
|
2011-05-19 17:56:39 +02:00
|
|
|
exit 0
|
2009-02-05 13:02:46 +01:00
|
|
|
fi;
|
|
|
|
|
2018-02-24 22:58:04 +01:00
|
|
|
ip6tables -L INPUT -v -n -x -w | grep -m1 $IP | awk "{ print \"in.value \" \$2 }"
|
|
|
|
ip6tables -L OUTPUT -v -n -x -w | grep -m1 $IP | awk "{ print \"out.value \" \$2 }"
|