我正在尝试创建一个arp-scan munin插件(基于arp插件),以查找我本地网络上连接的计算机数量。
#!/bin/sh
#
# Plugin to monitor total ARP entries
#
# Parameters understood:
#
# config (required)
# autoconf (optional)
#
# Made by Baziel de Leeuw
#
#%# family=contrib
#%# capabilities=autoconf
if [ "$1" = "autoconf" ]; then
# Search for arp
which arp-scan >/dev/null 2>/dev/null || (echo "no (can't find arp-scan 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 active ipaddresses registered by the system.'
echo 'entries.label ARP_SCAN entries'
echo 'entries.draw LINE2'
echo 'entries.type GAUGE'
echo 'entries.info Number of active local ipaddresses'
exit 0
fi
ARPENTRIES=$(arp-scan --interface=eth0 --localnet -q -N | tail -1 |rev |cut -f2 -d' '|rev)
let ARPENTRIES=$ARPENTRIES+1
printf "entries.value ";
echo $ARPENTRIES
如果我正常运行它需要大约一秒钟并给出一个可能的答案(通常在我的系统上为4或5) 如果我通过munin-run运行它立即完成并始终给出答案'1') 像这样:
[20102 root@server3 plugins]# ./arpscan;munin-run arpscan;./arpscan
entries.value 5
entries.value 1
entries.value 5
有人知道为什么会这样吗? 这是我的第一个插件,所以它可能是基本的。
谢谢,
Baziel
答案 0 :(得分:0)
问题是plugin-conf.d / munin-node中缺少的部分 添加
后可以使用[arpscan]
user root
所以它只是缺少一些权限。还是很奇怪,它给出了一个错误的答案。