snmpping.pl
Upload User: shbosideng
Upload Date: 2013-05-04
Package Size: 1555k
Code Size: 1k
Category:

SNMP

Development Platform:

C/C++

  1. #!/usr/sepp/bin/perl
  2. use lib qw(../../run);
  3. use BER;
  4. require 'SNMP_Session.pm';
  5. my $host = @ARGV[0];
  6. my $community = @ARGV[1];
  7. my $port = 161;
  8. $session = SNMP_Session->open ($host, $community, $port) 
  9. || die "couldn't open SNMP session to $host";
  10. $oid1 = encode_oid (1, 3, 6, 1, 2, 1, 1, 1, 0);
  11. if ($session->get_request_response ($oid1)) {
  12.      ($bindings) = $session->decode_get_response($session->{pdu_buffer});
  13.         while ($bindings ne '') {
  14.         ($binding,$bindings) = &decode_sequence ($bindings);
  15.         ($oid,$value) = &decode_by_template ($binding, "%O%@");
  16.         print $pretty_oids{$oid}," => ",
  17.         &pretty_print ($value), "n";
  18.         }
  19. }