++ed by:

1 PAUSE user

Author image Michael Vincent
and 1 contributors


Cisco::SNMP - Interface for Cisco Management


  use Cisco::SNMP::Memory;

  my $cm = Cisco::SNMP::Memory->new(
      hostname  => '',
      community => 'public'

  my $mem = $cm->memory_info();
  print  "Memory Pool Name    |   Total(K)    |    Used(K)    |Percent(%)\n";
  for (0..$#{$mem}) {
      printf "%-20s|%15.2f|%15.2f|%7.2f\n", 
          $mem->memTotal($_) / 1000,
          $mem->memUsed($_) / 1000,
          $mem->memUsed($_) / $mem->memTotal($_) * 100


Cisco::SNMP is a class implementing several management functions for Cisco devices - mostly via SNMP. Cisco::SNMP uses the Net::SNMP module to do the SNMP calls.

Cisco::SNMP is the successor to the now deprecated Cisco::Management.

Cisco::SNMP supports IPv6 on systems with IPv6 configured but requires Socket version 1.94 or greater. This may cause issues on Perl versions less than 5.14, where the default Socket module is of a lesser version. The requirement stems from the use of the getaddrinfo() and getnameinfo() functions not available on older versions of Socket.


new() - create a new Cisco::SNMP object

  my $cm = Cisco::SNMP::_MODULE_->new([OPTIONS]);

Create a new Cisco::SNMP::_MODULE_ object - where _MODULE_ is a sub-module in the Cisco::SNMP suite (SEE ALSO) - with OPTIONS as optional parameters. Valid options are:

  Option     Description                            Default
  ------     -----------                            -------
  -community SNMP read/write community string       private
  -family    Address family IPv4/IPv6               IPv4
               Valid values for IPv4:
                 4, v4, ip4, ipv4, AF_INET (constant)
               Valid values for IPv6:
                 6, v6, ip6, ipv6, AF_INET6 (constant)
  -hostname  Remote device to connect to            localhost
  -port      Port to connect to                     161
  -timeout   Timeout to wait for request in seconds 10
  -version   SNMP version to use                    1
  [Additional options available from Net::SNMP module]

Family provides hint for resolving names provided for hostname to addresses.

Single option is hostname.

Single option may also be a valid Cisco::SNMP::_MODULE_ object in which case the object is re-blessed to the calling class.

session() - return Net::SNMP session object

  $session = $cm->session;

Return the Net::SNMP session object created by the Cisco::SNMP new() method. This is useful to call Net::SNMP methods directly without having to create a new Net::SNMP object. For example:

  my $cm = Cisco::SNMP::Memory->new(
      -host      => 'router1',
      -community => 'snmpRW'
  my $session = $cm->session();
  # get_request() is a Net::SNMP method

In this case, the get_request call is a method provided by the Net::SNMP module that can be accessed directly via the $session object returned by the $cm->session() method.

close() - close session


Close the session.

error() - print last error

  printf "Error: %s\n", $cm->error();

Return last error.

DEFAULT_FAMILY() - change the default address family for resolution

  [$previous] = Cisco::SNMP::DEFAULT_FAMILY(#);

Sets the default family for name resolution if none is provided. Default is IPv4. THIS MAY CHANGE IN FUTURE RELEASES!!!

Called with no #, current value is returned. Called with valid #, setting is changed to # and previous value is returned. Valid values for # are: 4, AF_INET (constant), 6, AF_INET6 (constant).




This distribution comes with several scripts (installed to the default bin install directory) that not only demonstrate example uses but also provide functional execution.


Cisco::SNMP::Config, Cisco::SNMP::CPU, Cisco::SNMP::Entity, Cisco::SNMP::Interface, Cisco::SNMP::Line, Cisco::SNMP::Memory, Cisco::SNMP::Password, Cisco::SNMP::ProxyPing, Cisco::SNMP::System


This software is released under the same terms as Perl itself. If you don't know what that means visit http://perl.com/.


Copyright (C) Michael Vincent 2015


All rights reserved