加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
if_ 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/bash
# -*- sh -*-
: << =cut
=head1 NAME
if_ - Wildcard plugin to monitor traffic network interfaces
=head1 CONFIGURATION
=head2 ENVIRONMENT VARIABLES
This plugin does not use environment variables
=head2 WILDCARD PLUGIN
This is a wildcard plugin. To monitor an interface, link
if_<interface> to this file. E.g.
ln -s /usr/share/munin/plugins/if_ \
/etc/munin/node.d/if_eth0
...will monitor eth0.
Any device found in /usr/bin/kstat can be monitored.
=head1 AUTHOR
Unknown author
=head1 LICENSE
GPLv2
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf suggest
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
INTERFACE=${0##*/if_}
if [ "$1" = "autoconf" ]; then
if [ -x /usr/bin/kstat ]; then
echo yes
exit 0
else
echo "no (/usr/bin/kstat not found)"
exit 0
fi
fi
if [ "$1" = "suggest" ]; then
if [ -x /usr/bin/kstat ]; then
kstat -p -s rbytes64 | awk -F: '{ print $3 }'
exit 0
else
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo "graph_order rbytes obytes"
echo "graph_title $INTERFACE traffic"
echo 'graph_args --base 1000'
echo 'graph_vlabel bits per ${graph_period} in (-) / out (+)'
echo 'graph_category network'
echo 'rbytes.label received'
echo 'rbytes.type DERIVE'
echo 'rbytes.graph no'
echo 'rbytes.cdef rbytes,8,*'
echo 'rbytes.min 0'
print_warning rbytes
print_critical rbytes
echo 'obytes.label bps'
echo 'obytes.type DERIVE'
echo 'obytes.negative rbytes'
echo 'obytes.cdef obytes,8,*'
echo 'obytes.min 0'
print_warning obytes
print_critical obytes
exit 0
fi
kstat -C -c net -n $INTERFACE -s rbytes64 | sed 's/.*\(.bytes\)64./\1.value /'
kstat -C -c net -n $INTERFACE -s obytes64 | sed 's/.*\(.bytes\)64./\1.value /'
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化