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

81 lines
1.2 KiB
Text
Raw Normal View History

2018-04-17 01:17:57 +02:00
#!/bin/sh
# -*- sh -*-
: <<=cut
=head1 NAME
ipset - Graph number of members of netfilter ipsets
=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
2018-04-18 04:05:06 +02:00
set -eu
2016-07-29 16:10:19 +02:00
2018-04-18 04:04:15 +02:00
get_ipset_list() {
ipset list -n
2016-08-01 16:58:20 +02:00
}
2016-07-29 16:10:19 +02:00
2018-04-18 04:04:15 +02:00
2018-04-18 04:05:06 +02:00
if [ "${1:-}" = "autoconf" ]; then
2018-04-18 04:04:15 +02:00
if [ -e /sbin/ipset ] || [ -n "$(which ipset)" ]; then
echo 'yes'
else
echo 'no (ipset binary not present)'
fi
exit 0
fi
2018-04-18 04:05:06 +02:00
if [ "${1:-}" = "config" ]; then
2016-07-29 16:10:19 +02:00
echo graph_title Netfilter IPSets
echo graph_category network
echo graph_vlabel Members
echo graph_args --base 1000 --logarithmic --units=si
2018-04-18 04:04:15 +02:00
get_ipset_list | while read -r list; do
2016-07-29 16:10:19 +02:00
echo "$list.label $list"
echo "$list.min 0"
2018-04-18 04:04:15 +02:00
done
[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] || exit 0
2018-04-18 04:04:15 +02:00
fi
2016-07-29 16:10:19 +02:00
2018-04-18 04:04:15 +02:00
get_ipset_list | while read -r list; do
echo "$list.value $(( $(ipset list "$list" | wc -l) - 7 ))"
done
2016-07-29 16:10:19 +02:00
exit 0