Host and process utility functions

You can use utility functions to obtain information about the environment in which the probe is running.

The following table describes the host and process functions supported in rules files.

Table 1. Host and process utility functions  

Function

Description

Example

getenv(string)

Returns the value of a specified environment variable.

$My_OMNIHOME = getenv("OMNIHOME")

gethostaddr(string)

Returns the IP address of the host using a naming service (for example, DNS or /etc/hosts). The argument can be a string containing a host name or an IP address. If the host cannot be looked up, the original value is returned.

Note: DNS lookup (and other similar services) can take an appreciable amount of time which can severely impact the performance of the probe. You should consider instead using a lookup table in the rules file, and only use gethostaddr if the host is not in the table.

@Summary = $Summary + " Node: " + $Node + " Address: " + gethostaddr($Node)

gethostname(string)

Returns the name of the host using a naming service (for example, DNS or /etc/hosts). The argument can be a string containing a host name or IP address. If the host cannot be looked up, the original value is returned.

Note: DNS lookup (and other similar services) can take an appreciable amount of time which can severely impact the performance of the probe. You should consider instead using a lookup table in the rules file, and only use gethostname if the host is not in the table.

@Summary = $Summary + " Node: " + $Node + " Name: " + gethostname($Node)

getpid()

Returns the process ID of the running probe.

$My_PID = getpid()

getplatform()

Returns the operating system platform the probe is running under. One of the following values is returned: linux2x86, solaris2, hpux11, aix5, or win32.

log(INFO, "Netcool Platform = " + getplatform())

hostname()

Returns the name of the host on which the probe is running.

$My_Hostname = hostname()