File: digital-bug

package info (click to toggle)
libsnmp-session-perl 1.14~git20221124T101957-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,104 kB
  • sloc: perl: 11,920; ansic: 25; makefile: 15
file content (32 lines) | stat: -rwxr-xr-x 791 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/local/bin/perl

#Check for SNMP Values

use BER;					
require 'SNMP_Session.pm';

#Variables
$host=@ARGV[0] || die "usage";
$community=@ARGV[1] || 'public';
$port='161';
 
$session = SNMP_Session->open ($host, $community, $port)
        || die "Couldn't open SNMP session to $host";


#Oid's
$oid1=encode_oid (1,3,6,1,2,1,1,5,0);

if ($session->get_request_response ($oid1)){
	($bindings) = $session->decode_get_response
($session->{pdu_buffer});

        while ($bindings ne '') {
              ($binding,$bindings) = &decode_sequence ($bindings);
              ($oid,$value) = &decode_by_template ($binding, "%O%@");
              print $pretty_oids{$oid}," => ",
                    &pretty_print ($value), "\n";
        }
} else {
        die "No response from agent on $host";
}