root / plugins / other / ip6_ @ f5515445
Historique | Voir | Annoter | Télécharger (2,01 ko)
| 1 | 2cd2a7af | Lasse Karstensen | #!/bin/sh |
|---|---|---|---|
| 2 | # |
||
| 3 | # Patched version of ip_ plugin to support IPv6 and ip6tables. |
||
| 4 | # Most of plugin done by munin core developers. Modified for IPv6 support |
||
| 5 | # by Lasse Karstensen <lasse.karstensen@gmail.com> February 2009. |
||
| 6 | # |
||
| 7 | # Wildcard-plugin to monitor IP addresses through ip6tables. To monitor an |
||
| 8 | # IP, link ip6_<ipaddress> to this file with : replaced with _. E.g. |
||
| 9 | # |
||
| 10 | # ln -s /usr/share/node/node/plugins-auto/ip6_ /etc/munin/plugins/ip_2001_db8_1__100 |
||
| 11 | # |
||
| 12 | # ...will monitor the IP 2001:db8:1::10. |
||
| 13 | # |
||
| 14 | # Additionally, you need these ip6tables rules as the first rules (they don't do anything, just make packet counts) |
||
| 15 | # |
||
| 16 | # ip6tables -A INPUT -d 2001:db8:1::10 |
||
| 17 | # ip6tables -A OUTPUT -s 2001:db8:1::10 |
||
| 18 | # |
||
| 19 | # Furthermore, this plugin needs to be run as root for ip6tables to work. |
||
| 20 | # |
||
| 21 | # |
||
| 22 | # Magic markers (optional - used by munin-config and some installation |
||
| 23 | # scripts): |
||
| 24 | #%# family=auto |
||
| 25 | #%# capabilities=autoconf suggest |
||
| 26 | |||
| 27 | IP=`basename $0 | sed 's/^ip6_//g' | tr '_' ':' ` |
||
| 28 | |||
| 29 | if [ "$1" = "autoconf" ]; then |
||
| 30 | if [ -r /proc/net/dev ]; then |
||
| 31 | ip6tables -L INPUT -v -n -x >/dev/null 2>/dev/null |
||
| 32 | if [ $? -gt 0 ]; then |
||
| 33 | echo "no (could not run ip6tables as user `whoami`)" |
||
| 34 | exit 1 |
||
| 35 | else |
||
| 36 | echo yes |
||
| 37 | exit 0 |
||
| 38 | fi |
||
| 39 | else |
||
| 40 | echo "no (/proc/net/dev not found)" |
||
| 41 | exit 1 |
||
| 42 | fi |
||
| 43 | fi |
||
| 44 | |||
| 45 | if [ "$1" = "suggest" ]; then |
||
| 46 | f5515445 | splebel | ip6tables -L INPUT -v -n -x 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\}##"
|
| 47 | 2cd2a7af | Lasse Karstensen | exit 0 |
| 48 | fi |
||
| 49 | |||
| 50 | if [ "$1" = "config" ]; then |
||
| 51 | f5515445 | splebel | echo "graph_order out in" |
| 52 | echo "graph_title $IP IPv6 traffic" |
||
| 53 | echo 'graph_args --base 1000' |
||
| 54 | echo 'graph_vlabel bits per ${graph_period}'
|
||
| 55 | 2cd2a7af | Lasse Karstensen | echo 'graph_category network' |
| 56 | f5515445 | splebel | echo 'out.label sent' |
| 57 | echo 'out.type DERIVE' |
||
| 58 | echo 'out.min 0' |
||
| 59 | echo 'out.cdef out,8,*' |
||
| 60 | echo 'in.label received' |
||
| 61 | echo 'in.type DERIVE' |
||
| 62 | echo 'in.min 0' |
||
| 63 | echo 'in.cdef in,8,*' |
||
| 64 | exit 0 |
||
| 65 | 2cd2a7af | Lasse Karstensen | fi; |
| 66 | |||
| 67 | ip6tables -L INPUT -v -n -x | grep -m1 $IP | awk "{ print \"in.value \" \$2 }"
|
||
| 68 | ip6tables -L OUTPUT -v -n -x | grep -m1 $IP | awk "{ print \"out.value \" \$2 }" |
