Big Sister
List of all members
Requester::Requester Class Reference

Requesters are responsible for providing the data requested via a "get" statement in tests.cfg (Monitor::Tester). More...

Inheritance diagram for Requester::Requester:
Requester::apcupsd Requester::df Requester::fileaccess Requester::ldap Requester::lxNetwork Requester::mailq Requester::mysql Requester::ntptrace Requester::oracle Requester::procMeminfo Requester::procs Requester::realhttp Requester::SlowRequester Requester::snmp Requester::tcp Requester::WatchRequester Requester::who Requester::win32perf Requester::win32service

Public Class Methods

 new ()
 create a requester.

Public Object Methods

void register (list domains)
 Register a requester for one or multiple domains.
hashref request (hashref env, scalar domain, arrayref variables)
 Computes (or requests) the values of the variables listed in variables.
boolean fail_novar (boolean fail)
 Not used any more?
hashref getinfo (arrayref gets, arrayref indexes)
 Called by the default request() method with gets set to the list of the variables, indexes set to the list of variable indexes to be retrieved.
hashref getwalk (arrayref gets, arrayref indexes, arrayref walks)
 Similiar to getinfo(), but getwalk() is called by the default request() method if the request includes a "walk" and passes the list of variables to be walked via the walks parameter.
boolean available (hashref env)
 Determine if a requester is willing to perform (handle requests) for a given tester environment.
boolean command_available (list cmd)
 Tests if cmd is runnable - usually called by classes inherited from Requester::Requester in their available() method in order to find out if a system command they require is present or not.
int criticalness (int criticalness)
 Get/Set the criticalness of a handler.
int consumes (int consumes)
 Get/set consume level of a handler.

Public Functions

list probe_consumes (hashref env, arrayref variables)
 Given a list of variable names and an environment, probe_consumes() will try to determine the criticalness/consumes values for the requests that it takes to get all those variable's values.
hashref get (hashref env, arrayref variables)
 Given a list of variable names and a tester environment requests all the variables and returns the result in a hash ref.
Requester::Requester get_handler (scalar domain)
 Given the name of a domain this function searches for a request handler that is willing to perform requests for this domain.
boolean load_module (scalar module)
 Given the name of a module tries to dynamically load Requester::modulename.

Protected Functions

protected void preexit ()
 This function is called during program shutdown.
protected hashref _get (hashref env, arrayref variables, scalar probe_only)
 Implements both the get() and probe_consumes() call.
protected void set_cache (hashref env, scalar domain, scalar name, hashref value)
 Given a domain, variable name and a value stores the value in the cache under the given domain/name.
protected void clear_cache ()
 Clear the variable cache.

Detailed Description

Requesters are responsible for providing the data requested via a "get" statement in tests.cfg (Monitor::Tester).

Member Function Documentation

protected hashref Requester::Requester::_get ( hashref  env,
arrayref  variables,
scalar  probe_only 
)

Implements both the get() and probe_consumes() call.

Parameters
envTester environment
variablesList of variable names
probe_onlyIf set use probe_consumes() semantics, otherwise get() is performed
Returns
Hashref compatible with get() if called with probe_only not set, otherwise a hashref with the keys being the names of domains that need a requester to be called.
boolean Requester::Requester::available ( hashref  env)

Determine if a requester is willing to perform (handle requests) for a given tester environment.

Usually, available() will return false if some required system command is not installed, some API is missing, the test works only against a local machine but the target host is not the local machine, etc.

Parameters
envTester environment
Returns
true if requester is willing to handle requests, false otherwise
protected void Requester::Requester::clear_cache ( )

Clear the variable cache.

boolean Requester::Requester::command_available ( list  cmd)

Tests if cmd is runnable - usually called by classes inherited from Requester::Requester in their available() method in order to find out if a system command they require is present or not.

Note
The command in question is actually executed via system(), so it is required that the cmd argument includes "save" command line options ensuring that no harm is done to the system and Big Sister.
Parameters
cmdThe command to be tested for availability.
int Requester::Requester::consumes ( int  consumes)

Get/set consume level of a handler.

The higher the "consumes" figure is the more other handlers will suffer if running in parallel with this handler.

Parameters
consumes(optional) if defined, set the consumes figure to this value
Returns
The current 'consumes' figure.
int Requester::Requester::criticalness ( int  criticalness)

Get/Set the criticalness of a handler.

The higher the criticalness the more the handler will suffer from other handlers to be running in parallel.

Parameters
criticalness(optional) If defined, set the criticalness to this value
Returns
The level of criticalness.
boolean Requester::Requester::fail_novar ( boolean  fail)

Not used any more?

Todo:
check if fail_novar() is still in use by someone, and if yes, what the hell it is used for
hashref Requester::Requester::get ( hashref  env,
arrayref  variables 
)

Given a list of variable names and a tester environment requests all the variables and returns the result in a hash ref.

Parameters
envTester environment
variablesA list of variable names.
Returns
A hash ref.
Requester::Requester Requester::Requester::get_handler ( scalar  domain)

Given the name of a domain this function searches for a request handler that is willing to perform requests for this domain.

If no handler has been registered yet, it tries to dynamically load one via load_module().

Parameters
domainThe name of the domain
Returns
The handler of the domain or undef if none was found.
hashref Requester::Requester::getinfo ( arrayref  gets,
arrayref  indexes 
)

Called by the default request() method with gets set to the list of the variables, indexes set to the list of variable indexes to be retrieved.

If gets or indexes are undefined, this means that a 'walk' through all the possible variables has to be performed.

The default behaviour is to call the getwalk() method with an empty walks list. So, a requester implementation has to implement at least one of request(), getinfo() or getwalk() in order to do something useful.

Parameters
getsThe list of names of the variables that have to be retrieved.
indexesThe list of variable indexes that have to be retrieved.
Returns
A folded hashref, at the first level the hashref uses the variable index as key, the values each point to a hashref with the name of the respective variable as a key, the scalar value as the value.

Reimplemented in Requester::SlowRequester, and Requester::expedap.

hashref Requester::Requester::getwalk ( arrayref  gets,
arrayref  indexes,
arrayref  walks 
)

Similiar to getinfo(), but getwalk() is called by the default request() method if the request includes a "walk" and passes the list of variables to be walked via the walks parameter.

The default behaviour of getwalk() is to just call getinfo() with gets/indexes unset. This has been the default behaviour before getwalk() has been introduced, so getwalk() behaves the same in order to avoid breaking existing requesters. A requester implementation has to implement at least one of request(), getinfo() or getwalk() in order to do something useful.

Parameters
getsThe list of names of the variables that have to be retrieved.
indexesThe list of variable indexes that have to be retrieved.
walksThe list of variables that have to be "walked"
Returns
A folded hashref, at the first level the hashref uses the variable index as key, the values each point to a hashref with the name of the respective variable as a key, the scalar value as the value.

Reimplemented in Requester::expedap.

boolean Requester::Requester::load_module ( scalar  module)

Given the name of a module tries to dynamically load Requester::modulename.

Parameters
moduleThe name of a module
Returns
true if successful, false otherwise
Requester::Requester::new ( )

create a requester.

Reimplemented in Requester::expedap.

protected void Requester::Requester::preexit ( )

This function is called during program shutdown.

list Requester::Requester::probe_consumes ( hashref  env,
arrayref  variables 
)

Given a list of variable names and an environment, probe_consumes() will try to determine the criticalness/consumes values for the requests that it takes to get all those variable's values.

Parameters
envTester environment
variablesA list of variable names.
Returns
An array with two values: The first one being the criticalness, the 2nd one the consumer level of the most critical or most consuming requester that has to be called. Returns undef if no requester has to be called at all.
void Requester::Requester::register ( list  domains)

Register a requester for one or multiple domains.

Each Requester has to register itself under a unique domain name. Typically, a requester will create an instance of itself on load (a singleton) and register this instance via register(). This instance will then get "get" requests for the registered domains.

Parameters
domainsThe list of domain names to register.
hashref Requester::Requester::request ( hashref  env,
scalar  domain,
arrayref  variables 
)

Computes (or requests) the values of the variables listed in variables.

The default request() method will process the list of variables and then call getwalk() if the request includes a walk, getinfo() otherwise.

Parameters
envTester environment
domainThe name of the domain the request is associated with. If the requester in question is registered for one single domain only, this is always the name of the registered domain.
variablesList of variable names that are requested. Variable names starting with '@' mean that the requester is supposed to return all variables/values below this prefix.
Returns
A hashref containing the variable names associated with their values. Returns 'undef' if the requester cannot perform the request (i.e. because the variable names are unknown or the underlying system failed)
protected void Requester::Requester::set_cache ( hashref  env,
scalar  domain,
scalar  name,
hashref  value 
)

Given a domain, variable name and a value stores the value in the cache under the given domain/name.

Parameters
envTester environment
domainDomain name
nameVariable name
valueValue associated with domain/name. The values being stored in the cache are required to be hash references.

The documentation for this class was generated from the following file: