如何配置 Munin 来监控 ppp0

如何配置 Munin 来监控 ppp0

我在 Ubuntu Jaunty 笔记本电脑上使用 Munin。它显示了所有内容的出色图表,除了 ppp0(我用它来连接互联网)。所以我需要配置 munin 来显示 ppp0 使用情况图表

我尝试阅读文档和一些教程,并在 munin-node 插件目录中添加了 if_ppp0 和 if_error_ppp0。创建了两个符号链接,正如我所料,它们指向正确的插件,if_ 和 if_error(仅跟踪了对 if_eth0 和 if_error_eth0 所做的操作,对 ppp0 也做了同样的事情)。但这还不够。ppp0 不在图表中。

我找不到任何建议编辑的配置行,这些配置行将包括监控池中的 ppp0。考虑到 munin 的流行程度,没有任何地方写有关 ppp 的内容,这有点令人惊讶。

我擅长使用 Perl 和 bash,以前也编写过 rrd。所以我编辑了 if_ 和 if_error perl 文件的插件,并将看起来像“eth|wlan|....”的正则表达式更改为“eth|ppp|wlan|....”。这样做没有造成任何损坏,也没有修复任何问题。看来我必须在其他地方做点别的事情,但不知道是什么。请帮忙。

答案1

默认的 eth 脚本使用 ethtool,它在 ppp 链接上不起作用。

此外,eth 脚本使用 COUNTER 而不是 DERIVE,这会在您每次重新连接 ppp 链接时产生严重的峰值。

这是我的脚本(将 up.max、down.max 更改为您的 ppp 链接带宽)...

#!/bin/sh

INTERFACE=`basename $0 | sed 's/^if_//g'`

if [ "$1" = "autoconf" ]; then
    if [ -r /proc/net/dev ]; then
        echo yes
        exit 0
    else
        echo "no (/proc/net/dev not found)"
        exit 1
    fi
fi

if [ "$1" = "suggest" ]; then
    if [ -r /proc/net/dev ]; then
        egrep '^ *(ppp|eth|wlan|ath|ra|msh|venet|veth)[0-9]+:' /proc/net/dev | cut -f1 -d: | sed 's/ //g'
        exit 0
    else
        exit 1
    fi
fi

if [ "$1" = "config" ]; then

    echo "graph_order down up" 
    echo "graph_title $INTERFACE traffic"
    echo 'graph_args --base 1000'
    echo 'graph_vlabel bits in (-) / out (+) per ${graph_period}'
    echo 'graph_category network'
    echo "graph_info This graph shows the traffic of the $INTERFACE network interface. Please note that the traffic is shown in bits per second, not bytes. IMPORTANT: Since the data source for this plugin use 32bit counters, this plugin is really unreliable and unsuitable for most 100Mb (or faster) interfaces, where bursts are expected to exceed 50Mbps. This means that this plugin is unsuitable for most production environments. To avoid this problem, use the ip_ plugin instead."
    echo 'down.label received'
        echo 'down.type DERIVE'
        echo 'down.graph no'
        echo 'down.cdef down,8,*'
        echo 'up.label bps'
    echo 'up.type DERIVE'
    echo 'up.negative down'
    echo 'up.cdef up,8,*'
    case "$INTERFACE" in
        ath*|wlan*|ra*)
            echo -n "up.info Traffic of the $INTERFACE interface. Maximum speed is "
            which iwlist >/dev/null 2>/dev/null || echo "undeterminable (please install iwlist)."
            iwlist $INTERFACE rate 2>/dev/null | awk '/Current Bit Rate/ { split ($0, arr, "[=:]"); split (arr[2], arr2, "M"); print (arr2[1]*1000000) " bits per second.\nup.max " (arr2[1]*1000000) "\ndown.max "(arr2[1]*1000000); }'
            ;;
        *)
            #echo -n "up.info Traffic of the $INTERFACE interface. Maximum speed is "
            #which ethtool >/dev/null 2>/dev/null || echo "undeterminable (please install ethtool)."
            #ethtool $INTERFACE 2>/dev/null | awk '/Speed/ { split ($2, arr2, "M"); print (arr2[1]*1000000) " bits per second.\nup.max " (arr2[1]*1000000) "\ndown.max "(arr2[1]*1000000); }'
            echo "up.info Traffic of the $INTERFACE interface. Maximum speed is 100000000 bits per second."
            echo "up.min 0"
            echo "down.min 0"
            echo "up.max 100000000"
            echo "down.max 100000000"

            ;;
    esac
    exit 0
fi;

# Escape dots in the interface name (eg. vlans) before using it as a regex
awk -v interface="$INTERFACE" \
    'BEGIN { gsub(/\./, "\\.", interface) } \
    $1 ~ "^" interface ":" {
        split($0, a, /: */); $0 = a[2]; \
        print "down.value " $1 "\nup.value " $9 \
    }' \
    /proc/net/dev

相关内容