All pastes #192149 Raw Edit

Stuff

public text v1 · immutable
·published 2006-10-05 18:39 UTC
rendered paste body
#!/usr/bin/perl

use Net::SNMP;
use strict;

foreach my $host (@ARGV) {
        my ($session,$error) =  Net::SNMP->session(-hostname => $host, -community => 'public', -version => 1);

        if (!defined($session)) {
                printf("ERROR: %s.\n", $error);
        }

        my $oid = '1.3.6.1.4.1.2021.9.1.100';
        #my $oid = '1.3.6.1.2.1.1.3.0';

        my $result = $session->get_request( -varbindlist => [$oid]);

        if (!defined($result)) {
                printf("ERROR: %s.\n", $session->error);
                $session->close;
                exit 1;
        }

        print $result->{$oid};
        $session->close;
}