perfSONAR_PS::Services::MP::Agent::Script - A module that will run a given script and


perfSONAR_PS-Services-PingER documentation  | view source Contained in the perfSONAR_PS-Services-PingER distribution.

Index


NAME

Top

perfSONAR_PS::Services::MP::Agent::Script - A module that will run a given script and return it's output.

DESCRIPTION

Top

Inherited perfSONAR_PS::Services::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.

SYNOPSIS

Top

  # create and setup a new Agent  
  my $agent = perfSONAR_PS::Services::MP::Agent::Script( $command, $options );
  $agent->init();

  # 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 )

Creates a new agent class

  $command = complete path to command line tool to run, eg /bin/myScript.pl
  $arguments = string of arguments to supply to above script.

command( $string )

accessor/mutator function for the script to execute

arguments( $string )

accessor/mutator function for the arguments to be supplied to the script

init( )

does anything necessary before running the collect() such as modifying the options etc. Check to see that the script exists =cut sub init { my $self = shift; if( ! -e $self->command() ) { $self->error( "Script '" . $self->command() . "' not found."); $logger->error( $self->error() ); return -1; } return 0; }

collectMeasurements( )

Runs the command with the options specified in constructor.

Returns:

 -1 = something failed
  0 = command ran okay

on success, this method should call the parse() method to determine the relevant performance output from the script.


perfSONAR_PS-Services-PingER documentation  | view source Contained in the perfSONAR_PS-Services-PingER distribution.