Support for snmp v2c with check_all_interfaces.pl

Matt Nelson matt at frozenatom.com
Tue Jan 20 21:52:58 CET 2009


There apparently is a problem with Net::SNMP->session->get_table() related
to Suse/Opensuse, and 64bit machines.  I tried this at home and everything
worked fine across redhat based distro's.  I found that I can use
Net::SNMP-session-get_request() and it works fine.  Since I do not have time
to dig into this much more, I decided to just "hack" the current script.  I
believe that this is a bug that I am guessing will be fixed with future
releases of net-snmp running on suse.

Below is my temporary fix if anyone wants it:

replace original get_table perl function with:

#######
sub get_table {
    my $oid = shift;
    my $response;
        # HACK by Matt Nelson
        $response = $session->get_table($oid);

        if ( !defined($response) ){
                my $hash = {};
                my $interfaces = scalar(keys(%iface_descr));
                for (my $i=1; $i <= $interfaces; $i++){
                        my $z = $session->get_request(-varbindlist =>
[$oid.'.'.$i]);
                        while (my ($key, $val) = each (%$z)){
                                $hash->{$key} = $val;
                        }
                        $response = $hash;

                }
        }
    if ( !defined($response) ) {
        # END HACK by Matt Nelson
        my $answer = $session->error;
        printf "CRITICAL: Could not read table by SNMP: $answer\n";
        exit STATUS_CRITICAL;
    }
    return %$response;
}
#######

On Mon, Jan 19, 2009 at 6:16 PM, Matt Nelson <matt at frozenatom.com> wrote:

> Sorry for the slow response.
>
> I didn't change anything yet with the original pl code.  I actually
> downloaded it again to a different machine, and it gives the same error:
>
> nagios02:/home/nagios/libexec # ./check_all_interfaces.pl -H databasenode
> -C public -v 1
> CRITICAL: Could not read table by SNMP: Counter length too long (5 bytes)
>
> nagios02:/home/nagios/libexec # ./check_all_interfaces.pl -H databasenode
> -C public -v 2
> CRITICAL: Could not read table by SNMP: Counter length too long (5 bytes)
>
> I wonder if it is something with version running on the remote host??  I'll
> keep digging into this, and idea's are more then welcome.  I'll post any
> solutions I find.
>
>
> On Sat, Jan 17, 2009 at 12:47 AM, Andrea Gabellini <
> andrea.gabellini at telecomitalia.sm> wrote:
>
>> Matt,
>>
>> the original code use snmp v2c as the default, and it works fine. Did you
>> change the default?
>>
>> Andrea
>>
>> Matt Nelson wrote:
>> > I have been using check_all_interfaces.pl for a while on 32bit machines
>> > and it works great for checking the interfaces for errors.  I would like
>> > to use it on a 64bit machine, but it gives the error:
>> >
>> > CRITICAL: Could not read table by SNMP: Counter length too long (5
>> bytes)
>> >
>> > due to it trying to read a Counter64 with snmp v1.  It does not support
>> > v2c, or v3, which supports Counter64.
>> >
>> > Does anyone know of a similar plugin that will work, or a way around
>> this?
>> >
>> >
>> > ------------------------------------------------------------------------
>> >
>> >
>> ------------------------------------------------------------------------------
>> > This SF.net email is sponsored by:
>> > SourcForge Community
>> > SourceForge wants to tell your story.
>> > http://p.sf.net/sfu/sf-spreadtheword
>> >
>> >
>> > ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Nagios-users mailing list
>> > Nagios-users at lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/nagios-users
>> > ::: Please include Nagios version, plugin version (-v) and OS when
>> reporting any issue.
>> > ::: Messages without supporting info will risk being sent to /dev/null
>>
>> --
>>
>> ---------------------------------------
>> Monday is an awful way to spend 1/7th of your life.
>> ---------------------------------------
>> Ing. Andrea Gabellini
>> Email: andrea.gabellini at telecomitalia.sm
>> Skype: andreagabellini
>> Tel: (+378) 0549 886111
>> Fax: (+378) 0549 886188
>>
>> Telecom Italia San Marino S.p.A.
>> Strada degli Angariari, 3
>> 47891 Rovereta
>> Republic of San Marino
>>
>> http://www.telecomitalia.sm
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20090120/862a99f8/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list