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