I need to get a list of IP addresses of phones from Cisco Unified Call Manager, and I would like to be able to do this using Perl and standard modules as much as possible.
I can get addresses using snmpwalk (we use SNMP v3), but for some reason, when I use existing code to try to do the same through SNMP or Net :: SNMP, I only get one IP address. I can't seem to get a single one to give me a complete list.
Here is my snmpwalk command:
snmpwalk -v3 -u <user> -A <password> -l authNoPriv -a SHA <ip address> 1.3.6.1.4.1.9.9.156.1.2.1.1.6
I also get the Phone Description field (156.1.2.1.1.4) and the two fields merge into a text file, so I can use them to query the phones themselves using LWP.
It would be great to combine these two functions in one script to get an IP address and request a phone for its specific details.
Does anyone have a code that does this?
Edit:
snmpwalk returns (a whole bunch):
SNMPv2-SMI::enterprises.9.9.156.1.2.1.1.6.100 = IpAddress: xxx.xxx.xxx.xxx
My Perl code that returns a single IP address (I have to retype it because it is on a closed network without Internet access):
use SNMP; my $ccmip = "xxx.xxx.xxx.xxx"; my $user = "<username>"; my $pass = "<password>"; $sess = new SNMP::Session(DestHost => $ccmip, SecName => $user, SecLevel => 'authnoPriv', AuthPass => $pass, AuthProto => 'SHA', PrivProto => 'AES', PrivPass => $pass, Version => 3); my $vars = new SNMP::VarList(['1.3.6.1.4.1.9.9.156.1.2.1.1.6']); my @values = $sess->getnext($vars); my @table = (); while ((!$sess->{ErrorStr})) { push(@table, $values[0]); @values = $sess->getnext($vars); }