<<

NAME

Inca::Process::Profiler - Reports a process's resource usage

SYNOPSIS

  use Inca::Process::Profiler;
  my $profiler = new Inca::Process::Profiler();
  $profiler->addProcess( $$ );
  $profiler->getUsage(); # returns object of type Inca::Process::Usage

DESCRIPTION

Will query the system's ps command for current resource usage for a process or process group. This code is based on a code sample from Jim Hayes'.

CLASS METHODS

new( )

Class constructor which returns a new Inca::Process::Profiler object.

addProcessGroups( @pgids )

Add any number of pgids (process group ids) to gather usage data from.

Arguments:

pgids

An array of pgids that will used to collect usage data from.

addProcesses( @pids )

Add any number of pids to gather usage data from.

Arguments:

pids

An array of pids that will used to collect usage data from.

getProcessGroups( )

Return the pgids being monitored for usage.

Returns:

An array of pgids that is being used to collect usage data from.

getProcesses( )

Return the pids being monitored for usage.

Returns:

An array of pids that is being used to collect usage data from.

getUsage( cumulative => 1 )

Get the current resource usage of all of the pids and pgids that have been added to the object.

Options:

cumulative

If true, getUsage() will return the cumulative resource usage of all monitored pids and pgids. Otherwise, getUsage() will return a reference to a hash array where the keys are the pids and the values are Inca::Process::Usage objects. [default: 1]

Returns:

Returns an object of type Inca::Process::Usage if the cumulative option is set. Otherwise, returns a reference to a hash array where the keys are pids and the values are Inca::Process::Usage objects.

AUTHOR

Shava Smallen <ssmallen@sdsc.edu>

CAVEATS/WARNINGS

Only works on unix variants where ps option -o is supported.

<<