PSL discovery programming capsule
This section summarizes typical discovery programming. Use a PSL discovery script to define the PATROL Agent namespace variables for each detected application instance, detect application instances and create icons for them, set the current operational status of each instantiated application instance and check whether previously discovered application instances still exist on the monitored machine and destroy any obsolete application instances.
Typical PSL discovery algorithms
The following table lists typical discovery algorithms.
Typical PSL discovery algorithms
Algorithm | When to use this algorithm | Required/Optional |
---|---|---|
Define the PATROL environment for each detected application instance and set all namespace | If the PATROL KM provides parameters and menu commands that require a specific PATROL environment. | optional |
Create icons for each detected application instance. | To create icons to represent monitored application instances. | optional |
Detect and set the current operational status of each instantiated application instance. | To set up monitoring of detected applications. | optional |
Destroy any obsolete application instances. | To destroy application instances that end normally and no longer require monitoring. | optional |
PSL discovery programming guidelines
Discovery should be built to run as efficiently as possible using the following guidelines:
Application instance detections
- Define the environment for a new instance only at instance creation (i.e. when the create() function is called).
- You should create an icon for every detected application instance you want your users to see.
- Use the Create Icon for Class option only if more than one instance of an application class can occur.
Process cache
- Restrict the process list to a local variable containing all processes related to all instances of an application versus repeated process() function calls.
- Check, using full_discovery(), to determine whether the process list for an application should be rebuilt. If discovery builds a list of process IDs for an application instance, populate the PID list once at instance creation. Then, rebuild the list on full discovery only if the instance state is other than OK. Use the PSL process() function to obtain a list of processes from the Determine and set state only during the application check cycle.
- Determine and set state only during the application check cycle
Parameters
- Avoid setting parameter values in discovery scripts.
Other guidelines
- Discovery scripts should be the only place that the PSL create(), destroy() and change_state() functions are used.
- Use the default discovery cycle unless you have good reason to change it.
Typical PSL discovery script structure
A typical PSL discovery script has the following sections:
- Initialization
- Application instance detection
- Application instantiation
- Application instance destruction
The following table describes of each section and its usage.
Typical PSL discovery script sections
Section | Purpose and usage |
---|---|
Initialization | Set up all context required to use PSL library procedures to access the host environment (such as execute(), system(), popen(),) or cached information provided by the Agent (see process() function). |
If the application instance cannot be discovered and instantiated without user interaction for object-specific authentication, define a separate 'CLASSNAME_SETUP' application class to collect this information by menu commands or setup parameters and store it in the PATROL Agent namespace.
Application detection |
|
Instantiation | Use the PSL ex ists() function to determine if the application instance is already known; if not, use the create() function to create it. |
For ease of programming, combine application detection and instantiation so that the parsing of information collected during application detection is combined with the creation of objects and the setting of their status and instance attributes.
Destruction |
|
Depending on the managed application class, you may wish to maintain audit records on destroyed application instances.
Prototype PSL discovery script
This example illustrates the concept of unconditional instantiation. In unconditional instantiation, no logic is provided to determine whether or not the application instance should be created.
The following discovery script does these things:
- Checks to see if the application instance
ck.process
of the application classck.process
already exists. - If the
ck.process
does not yet exist, the PSL create() function creates an instance of the application classck.process
and sets its state to "OK." - If the application instance
ck.process
already exists, nothing happens.
PslDebug = 0;
if(!exists("/ck.process/ck.process")){
create("/ck.process/ck.process","ck.process",OK);
}
PSL functions used in PSL discovery
The following table lists functions that are often used in discovery scripts.
Common PSL discovery functions
Function | Definition and usage |
---|---|
change_state() | Changes the state of an application instance. This function only changes the rule state (intrinsic state) of an application instance. This function cannot set an instance's combined state which is set by propagation of state from a child to a parent object. Use to explicitly set the state of an application instance. |
create() | Creates a PATROL application instance. Use to create application instance and set its state. |
destroy() | Deletes a PATROL application instance. Use to destroy an obsolete PATROL object. |
exists() | Performs a Boolean check to determine whether a specific PATROL object exists. Use to determine whether a discovered PATROL object already exists in the PATROL Object Store. |
full_discovery() | Performs a Boolean check to determine whether the discovery cycle type is a full discovery cycle. Use to determine whether the current application check cycle is a full discovery cycle. |
get() | Returns the value of a specified PATROL Agent namespace variable or PATROL Agent pconfig database variable. |
proc_exists() | Performs a Boolean check of whether a specific pid exists. Use to test whether a specific process exists. |
process() | Returns a list of processes from the PATROL Agent process cache. Use to explicitly read the PATROL Agent process cache. |
Variables used in PSL discovery
The following table lists variables that are often used in discovery scripts.
Common PSL discovery variables
Variable | Type | Definition and usage |
---|---|---|
/appclassName/Instances | Built-in | Contains the list of currently created application class instances (SIDs). This list is used to manage the destruction of obsolete application instances as follows:
|
Comments
Log in or register to comment.