2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/arp/arp
Sven Hartge 4a56eb1897 arp: use only awk to process ARP cache
Simplify the processing of the output of arp -an to use only awk.
Reduces the needed subprocesses in the pipe.
2012-04-20 15:32:28 +02:00

43 lines
1001 B
Bash
Executable File

#!/bin/sh
#
# Plugin to monitor total ARP entries
#
# Parameters understood:
#
# config (required)
# autoconf (optional)
#
# Made by Sven Hartge (sven AT svenhartge DOT de)
#
#%# family=contrib
#%# capabilities=autoconf
if [ "$1" = "autoconf" ]; then
# Search for arp
which arp >/dev/null 2>/dev/null || (echo "no (can't find arp binary)" && exit 1)
# ...or success
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title ARP entries'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel Entries'
echo 'graph_category network'
echo 'graph_scale no'
echo 'graph_info This graph shows the number of ARP entries registered by the system.'
echo 'entries.label ARP entries'
echo 'entries.draw LINE2'
echo 'entries.type GAUGE'
echo 'entries.info Number of ARP entries'
exit 0
fi
arp -an | awk 'BEGIN { regex="<incomplete>";} { if (!match($4,regex)) { a[$4] }} END{for(i in a){n++};print "entries.value " n}'