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

Modified ipset according to #734

This commit is contained in:
Tomas Mudrunka 2018-04-17 01:17:57 +02:00
parent 616bbd931e
commit ccebcb7b4f

61
plugins/network/ipset Normal file → Executable file
View file

@ -1,12 +1,50 @@
#!/bin/bash #!/bin/sh
#Graph number of members of netfilter ipsets # -*- sh -*-
#(c) Tomas Mudrunka 2016
# : <<=cut
#Add this line to sudoers:
#ALL ALL = (root) NOPASSWD: /sbin/ipset list [!-]*, /sbin/ipset list -n =head1 NAME
#
#%# family=auto ipset - Graph number of members of netfilter ipsets
#%# capabilities=autoconf
=head1 APPLICABLE SYSTEMS
Any system with a compatible ipset command.
=head1 CONFIGURATION
Ipset has to be run as root:
[ipset]
user root
=head1 INTERPRETATION
This plugin draws number of members for each ipset present in the kernel
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 VERSION
0.1 first release
0.2 added docs, munin best practices
=head1 BUGS
None known
=head1 AUTHOR
Originally: Tomas Mudrunka 2016-2018 ( github.com/harvie )
=head1 LICENSE
GPLv2
=cut
[ "$1" = "autoconf" ] && { [ "$1" = "autoconf" ] && {
[ -e /sbin/ipset -o -n "$(which ipset)" ] && echo 'yes' || echo 'no (ipset binary not present)' [ -e /sbin/ipset -o -n "$(which ipset)" ] && echo 'yes' || echo 'no (ipset binary not present)'
@ -18,14 +56,15 @@
echo graph_category network echo graph_category network
echo graph_vlabel Members echo graph_vlabel Members
echo graph_args --base 1000 --logarithmic --units=si echo graph_args --base 1000 --logarithmic --units=si
exit 0
} }
sudo ipset list -n | while read list; do ipset list -n | while read list; do
[ "$1" = "config" ] && { [ "$1" = "config" ] && {
echo "$list.label $list" echo "$list.label $list"
echo "$list.min 0" echo "$list.min 0"
} || { } || {
echo "$list.value $(( $(sudo ipset list $list | wc -l) - 7 ))" echo "$list.value $(( $(ipset list "$list" | wc -l) - 7 ))"
} }
done; done;