NAME

NetSNMP::bridge - SNMP bridge which maps static files into a MIB space.


SYNOPSIS

The idea is that utilities, crontabs or daemons regularly write some statistics into a flat text file. The values in this file are then bridged into the MIB space. E.g. if the file contains:

        $ cat /var/db/snmp/1.3.6.1.4.1.9999
        1.3.6.1.4.1.99999.1.0 counter 3012

then an SNMP get gives


        $ snmpget -v2c -c public foo.site.com 1.3.6.1.4.1.99999.1.0
        3012
        $

or when a MIB is defined containing the entry:

        tcpShutdowns OBJECT-TYPE
                SYNTAX Counter
                MAX-ACCESS read-only
                STATUS current
                DESCRIPTION
              "Number of TCP shutdowns seen by the foo daemon"
               ::= { enterprises 99999 1 }
        ....

the output/data would be like:

        $ snmpwalk foo.site.com tcpShutdowns
        tcpShutdowns: 3012
        $

The fileformat used is the expected wire format of the 'pass' and 'pass-persistant' API of net-snmp; i.e. an OID, a type and a value on one line.

Note that there are two ways to use this bridge:

Which of those two is chosen depends on the situation - though when in doubt - start with the 'agentx' sub agent - as it is the most simplest situation to debug.


PREPARATION

The first step is to create some sample files with the statistics or values which are to be exposed or monitored by SNMP. These are simple ascii test files with one value per line.


SUBAGENT

Use as a sub agent (stand alone) - i.e. the snmpd daemon waits for this daemon to connect to it; and this daemon will try to reconnect at regular intervals should it loose the connection.

Setup

Trouble shooting.

Ccheck x/r of the unix agentx socket and higher directories. check log or run with -DALL -f flags.

Other configuration options.

Consult the snmpd.conf mange page on agentXPingInterval, agentXTimeout and agentXRetries.


EMBEDDED

In this case the embedded perl interpreter of net-snmp is used. This has the advantage that there is one daemon less to worry about - but has the downsites that faults are not as isolated.

Setup

Trouble shooting.

Check the log (run with -DALL -f flag).

This script will only pick up (new) OID files at startup time.


EXAMPLE

As a quick experiment - you could consider installing a small crontab along these lines -- which will let you monitor the number of hits from apache, the last hit of apache and the # of mails - along with the number of apache children running.

        #!/bin/sh
        # Gather various counts:
        #
        L=`wc -l /var/log/maillog`
        M=`wc -l /var/log/apache2/access_log`
        H=`tail -1 /var/log/apache2/access_log`
        G=`ps ax | grep httpd | wc -l`
        # Output counts into a statistics file for
        # the SNMP bridge.
        (
          echo 1.3.6.1.4.1.8072.9999.1.0 counter $L
          echo 1.3.6.1.4.1.8072.9999.2.0 counter $M
          echo 1.3.6.1.4.1.8072.9999.3.0 gauge   $G
          echo 1.3.6.1.4.1.8072.9999.4.0 string  $H
        ) > /var/db/snmp/$OID.new
        # note - atomic move rather than copy.
        #
        mv /var/db/snmp/$OID.new /var/db/snmp/$OID
        exit 0

The following 'mrtg' lines would graph above counter and gauge:

        Target[maillog]: 1.3.6.1.4.1.8072.9999.1&1.3.6.1.4.1.8072.9999.2.0:public@localhost
        Title[maillog]: Maillog and hits
        Options[maillog]: growright, nopercent
        PageTop[maillog]: <h2>Maillog and apche hits </h2>
        LegendI[maillog]: maillog
        LegendO[maillog]: apache hits
        Target[maillog]: 1.3.6.1.4.1.8072.9999.3&1.3.6.1.4.1.8072.9999.3.0:public@localhost
        Title[maillog]: Number of Apache processes
        Options[maillog]: growright, nopercent, gauge
        PageTop[maillog]: <h2>Apache processes</h2>
        LegendI[maillog]: apache processes
        LegendO[maillog]: apache processes


BUGS

Please report bugs to the net-snmp developers forum or bug tracker.


SEE ALSO

The net-snmp manual pages, in particular snmpd.conf and the section on the pass-directive.


AUTHOR

Dirk-Willem van Gulik <dirkx[at]webweaving[dot]org>


COPYRIGHT AND LICENSE

Copyright 2004 by Dirk-Willem van Gulik

This library is open source software; you can redistribute it and/or modify it under the same terms as net-snmp itself, the Apache Software License or any version of the BSD license.