request problem with cisco hsrp

Achim Stumpf <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hi list,

I am trying to get information about a cisco router. The ordinary 
queries work fine, but if i am trying to get information about the hsrp 
setup it fails.

My script is attached in the Mail.

Output of the script:
[snmp@clusty4 checkRouter]$ ./newgrp.pl

Creating SNMP session for 192.168.222.72

----------------------------------------------------------------------
Hostname   : snmptest2
Location   : testlocation
Contact    : testcontact
CVersion   : Cisco Internetwork Operating System Software
IOS (tm) C2600 Software (C2600-I-M), Version 12.3(19), RELEASE SOFTWARE 
(fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2006 by cisco Systems, Inc.
Compiled Fri 12-May-06 04:13


-----------------------------------BEGIN-----------------------------------
SNMP Version  : 1
VirtualIPaddr : noSuchInstance
Error         :
VirtualMAC    : noSuchInstance
Error         :
ActiveRouter  : noSuchInstance
Error         :
StandbyRouter : noSuchInstance
Error         :

----------------------------------- END -----------------------------------

Always I get noSuchInstance, but if i am doing the same with snmpwalk:

[root@clusty4 logs]# snmpwalk 192.168.222.72 -c test -v1 
1.3.6.1.4.1.9.9.106.1.2.1.1.11
SNMPv2-SMI::enterprises.9.9.106.1.2.1.1.11.1.1 = IpAddress: 192.168.222.70

With snmpwalk everything works fine. But why it does not work with the 
net::snmp module. Do you guys have any ideas for me????

Thanks a lot,

Achim

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
newgrp.pl (application/x-perl, 2.3 KB)
#!/usr/bin/perl -w


use strict;
use vars qw(@device $error $response);
use Net::SNMP;
use IO::Handle;
use Socket;


my $host = '192.168.222.72';
my $check_delay = 30;

print "\nCreating SNMP session for $host\n";

my ($session,$error) = Net::SNMP->session(
			-version   => 'snmpv2c',
			-hostname  => $host,
			-community => 'test',
			-port      => 161);

while (!$SIG{TERM}) {
	### get std. SNMP infos
	my $hostname = &getSNMP($session,$host,'1.3.6.1.2.1.1.5.0');
	my $location = &getSNMP($session,$host,'1.3.6.1.2.1.1.6.0');
	my $contact  = &getSNMP($session,$host,'1.3.6.1.2.1.1.4.0');
	my $cversion = &getSNMP($session,$host,'1.3.6.1.2.1.1.1.0');


	### Lets print some first values
	printf ("\n");
	printf ("-"x35); printf ("-"x35);
	printf ("\n");
	printf ("Hostname   : $hostname\n");
	printf ("Location   : $location\n");
	printf ("Contact    : $contact\n");
	printf ("CVersion   : $cversion\n");
	printf ("\n");

	### START HSRP request

	# get the snmp version
	my $rfc_version = $session->version;

	my $virtualip = &getSNMP($session,$host,'1.3.6.1.4.1.9.9.106.1.2.1.1.11');
	my $error1 = $session->error;
	my $virtualmac = &getSNMP($session,$host,'1.3.6.1.4.1.9.9.106.1.2.1.1.16');
	my $error2 = $session->error;
	my $activerouter = &getSNMP($session,$host,'1.3.6.1.4.1.9.9.106.1.2.1.1.13');
	my $error3 = $session->error;
	my $standbyrouter = &getSNMP($session,$host,'1.3.6.1.4.1.9.9.106.1.2.1.1.14');
	my $error4 = $session->error;
	
	printf ("\n");
	printf ("-"x35); printf ("BEGIN"); printf ("-"x35);
	printf ("\n");
	printf ("SNMP Version  : $rfc_version\n");
	printf ("VirtualIPaddr : $virtualip\n");
	printf ("Error         : $error1\n");
	printf ("VirtualMAC    : $virtualmac\n");
	printf ("Error         : $error2\n");
	printf ("ActiveRouter  : $activerouter\n");
	printf ("Error         : $error3\n");
	printf ("StandbyRouter : $standbyrouter\n");
	printf ("Error         : $error4\n");
	printf ("\n");

	### END of HSRP request

	printf ("-"x35); printf (" END "); printf ("-"x35);
	printf ("\n");
	sleep $check_delay;
};

$session->close();

sub getSNMP {
	my ($session,$host,$oid) = @_;
	if (!defined ($response = $session->get_request($oid))) {
		printf "Error while get_request of $oid for $host\n";
	};
	if (defined $response) {
		return $response->{$oid};
	}
	else {
		return 'Error';
	};
};
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.