View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Aaron Brown > perfSONAR_PS-Services-PingER-0.09 > perfSONAR_PS::Services::MP::Agent::SNMP



Annotate this POD

View/Report Bugs
Module Version: 0.09   Source  


perfSONAR_PS::Services::MP::Agent::SNMP - A module that will query a SNMP device and return it's output.


Inherited perfSONAR_PS::MP::Agent::Base class that allows a command to be executed. Specific tools should inherit from this class and override parse() in order to be able to format the command line output in a well understood data structure.


  # command line to run, variables are indicated with the '%...%' notation
  my $command = '/bin/ping -c %count% %destination%';
  # options to use, the above keys defined in $command will be 
  # substituted with the following values
  my %options = (
      'count' => 10,
      'destination' => 'localhost',
  # create and setup a new Agent  
  my $agent = perfSONAR_PS::Services::MP::Agent::CommandLine( $command, $options );
  # collect the results (i.e. run the command)
  if( $mp->collectMeasurements() == 0 )
        # get the raw datastructure for the measurement
        print "Results:\n" . $self->results() . "\n";

  # opps! something went wrong! :(
  else {
    print STDERR "Command: '" . $self->commandString() . "' failed with result '" . $self->results() . "': " . $agent->error() . "\n"; 

new( $command, $options, $namespace)

Creates a new agent class

  $host = device to query
  $port = udp port number to query on $host
  $ver = snmp version number (1,2c,3)
  $comm = community string to use to query device
  $vars = hash of OIDs to query

init( )

Setup the snmp agent

collectMeasurement( @var )

collect the snmp oids defined. Optional list of variables to collect @var (otherwise will use whatever was defined in the constructor or overloaded with $self->variables())

host( $string )

accessor/mutator function for the host to query

port( $string )

accessor/mutator function for the udp port to query

version( $string )

accessor/mutator function for the snmp version to use

version( $string )

accessor/mutator function for the snmp community string

variables( $string )

accessor/mutator function for the hash of snmp oids to collect

addVariable( $string )

Add the snmp oid to the list of variable to collect

removeVariables( )

Clears the list of snmp oids to collect

removeVariables( $string )

removes a single snmp oid variable from teh list to query

getVariableCount( )

determines the number of snmp oid variables to poll

collectVariables( )

Actually polls the host on port with community string and version the list of variables.

Input: @vars = list of oids to collect, if not supplied, will use $self->variables().


  -1 = something went wrong (use $self->error() )
   0 = everything went okay


creates and sets a Net::SNMP session for use in collection of oids


closes the Net::SNMP session


  -1 = could not close the session;
   0 = closed session okay
syntax highlighting: