How to correctly use DERIVE or COUNTER in munin plugins

Posted by Johan on Server Fault See other posts from Server Fault or by Johan
Published on 2010-03-30T08:46:34Z Indexed on 2010/03/30 8:53 UTC
Read the original article Hit count: 479

Filed under:
|
|

I'm using munin to monitor my server.

I've been able to write plugins for it, but only if the graph type is GAUGE. When I try COUNTER or DERIVE, no data is logged or graphed.

The plugin i'm currently stuck on is for monitoring bandwidth usage, and is as follows:

/etc/munin/plugins/bandwidth2

#!/bin/sh

if [ "$1" = "config" ]; then
    echo 'graph_title Bandwidth Usage 2'
    echo 'graph_vlabel Bandwidth'
    echo 'graph_scale no'
    echo 'graph_category network'
    echo 'graph_info Bandwidth usage.'

    echo 'used.label Used'
    echo 'used.info Bandwidth used so far this month.'
    echo 'used.type DERIVE'
    echo 'used.min 0'

    echo 'remain.label Remaining'
    echo 'remain.info Bandwidth remaining this month.'
    echo 'remain.type DERIVE'
    echo 'remain.min 0'

    exit 0
fi

cat /var/log/zen.log

The contents of /var/log/zen.log are:

used.value 61.3251953125
remain.value 20.0146484375

And the resulting database is:

<!-- Round Robin Database Dump --><rrd> <version> 0003 </version>
    <step> 300 </step> <!-- Seconds -->
    <lastupdate> 1269936605 </lastupdate> <!-- 2010-03-30 09:10:05 BST -->

    <ds>
            <name> 42 </name>
            <type> DERIVE </type>
            <minimal_heartbeat> 600 </minimal_heartbeat>
            <min> 0.0000000000e+00 </min>
            <max> NaN </max>

            <!-- PDP Status -->
            <last_ds> 61.3251953125 </last_ds>
            <value> NaN </value>
            <unknown_sec> 5 </unknown_sec>
    </ds>

<!-- Round Robin Archives -->   <rra>
            <cf> AVERAGE </cf>
            <pdp_per_row> 1 </pdp_per_row> <!-- 300 seconds -->

            <params>
            <xff> 5.0000000000e-01 </xff>
            </params>
            <cdp_prep>
                    <ds>
                    <primary_value> NaN </primary_value>
                    <secondary_value> NaN </secondary_value>
                    <value> NaN </value>
                    <unknown_datapoints> 0 </unknown_datapoints>
                    </ds>
            </cdp_prep>
            <database>
                    <!-- 2010-03-28 09:15:00 BST / 1269764100 --> <row><v> NaN </v></row>
                    <!-- 2010-03-28 09:20:00 BST / 1269764400 --> <row><v> NaN </v></row>
                    <!-- 2010-03-28 09:25:00 BST / 1269764700 --> <row><v> NaN </v></row>
                    <snip>

The value for last_ds is correct, it just doesn't seem to make it into the actual database.

If I change DERIVE to GAUGE, it works as expected.

munin-run bandwidth2 

outputs the contents of /var/log/zen.log

I've been all over the (sparse) docs for munin plugins, and can't find my mistake. Modifying an existing plugin didn't work for me either.

© Server Fault or respective owner

Related posts about munin

Related posts about plugin