System Information Functions

In this section:

It is now possible to obtain and work with system information. This section describes the _sysinfo() and _chaninfo() functions.


Top of page

x
_sysinfo(): Information About the Server

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:

  • processor. Number of processors available to the server.

    A common use of the processor value is to regulate parallel operations to avoid over-committing processors and developing a CPU-availability delay.

  • version. Current server version (for example, 7.0.3).
  • shortversion. Current software version that is shortened to the primary release level (for example, 7.0).
  • debug. Determines if the debug trace level is set. Returns true or false.
  • deep. Determines if the deep trace level is set. Returns true or false.
  • external. Determines if the external trace level is set. Returns true or false.
  • envar. Accesses an environment variable.

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'))

Top of page

x
_chaninfo(): Information About a Channel

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:

name

string

Is the name of the channel. If an asterisk (*) is specified, the current channel in which the function is running will be evaluated.

type

keyword

Is the type of information that is to be obtained. Supported values include:

  • state. The state of the channel. Possible values include:
    • active. The channel is available to process messages.
    • begin. The channel is starting.
    • retry. The channel is not processing messages and is awaiting a retry cycle.
    • config. The channel cannot process messages due to a configuration error.
    • stopping. A stop order has been issued. No further messages are being accepted, but the channel has not completed its work.
    • stopped. The channel is not active.
    • waiting. The channel is on a backup server and is not executing.
    • inactive. The channel was marked inactive in the configuration and awaits an explicit start command.
  • ispassive. Is the channel passivated. In some cases, such as an internal queue becoming too full, a passivate can be issued to a listener. Many listeners handle passivation automatically. However, some listeners require process flow support. In such a case, the passivate state test will return as true. The process flow may want to issue a sleep loop until the state becomes false, or take another action.
  • workers. The number of workers (threads) defined for the channel.
  • active. The number of messages currently being processed by the channel. A common use for this value is to regulate parallel operations to avoid over-committing processor resources.
  • debug. Determines if the debug trace level is set. Returns true or false.
  • deep. Determines if the deep trace level is set. Returns true or false.
  • external. Determines if the external trace level is set. Returns true or false.
  • pending. Count of messages on the pending queue at the instant that the call is made. For channels that do not support pending, if pending is not configured, or if the specific queue type count is not available, a value of 0 is returned.

    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