In this section: |
It is now possible to obtain and work with system information. This section describes the _sysinfo() and _chaninfo() functions.
The _sysinfo() function returns information about the current server. This function uses the following format:
_sysinfo(type [,modifier [,modifier2]])
type | keyword | The type of information that is to be obtained. You can specify one of the following values:
|
Accessing the System Environment Variable (envar)
Most operating systems provide environment variables to pass configuration information to applications. These are not Java system properties, which can be read through the _sreg() function. Instead, these are variables that reside at the operating system level. There are many subtle differences between the ways environment variables are implemented on different operating systems, and variable names are specific to the operating system. For example, variable names on UNIX systems are case-sensitive, while they are case-insensitive on Windows systems. The way in which environment variables are used also varies. For example, Windows systems provide the user name in an environment variable called USERNAME, while UNIX systems might provide the user name in USER, LOGNAME, or both.
To maximize portability, never refer to an environment variable when the same value is available in a system property. For example, if the operating system provides a user name, it will always be available in the system property _sreg('user.name').
To read an environment variable, compose the _sysinfo() function as follows:
_sysinfo('envvar',name [,default])
The following example is applicable to Windows:
_sysinfo('envvar','temp',_concat(_sreg('iwayworkdir'),'/temp'))
The _chaninfo() function returns information about the specified channel. If the specified channel does not exist, an exception is generated when the function is evaluated. This function uses the following format:
_chaninfo(name, [,type])
where:
string
Is the name of the channel. If an asterisk (*) is specified, the current channel in which the function is running will be evaluated.
keyword
Is the type of information that is to be obtained. Supported values include:
Note: In a multi-threaded channel, the pending count may change unpredictably at any moment as messages are added and removed for execution.
The _chaninfo() function can also be run in a script. For example:
if(_chaninfo('ch1','state')='active',stop ch1)
iWay Software |