Developing your own resource monitoring program
We can develop your own program to monitor system resources.
Each queue manager publishes resource usage data to topics. This data is consumed by subscribers to those topics. When a queue manager starts, the queue manager publishes a set of messages on meta-topics. These messages describe which resource usage topics are supported by the queue manager, and the content of the messages published to those topics. Administrative tools can subscribe to the metadata to discover what resource usage information is available, and on what topics, and then subscribe to the advertised topics.
The topic tree for the metadata has the following structure:$SYS/MQ/INFO/QMGR/QMGR-NAME/Monitor/class[/instance]/type]For a list of possible classes, see Monitor system resource usage by using the amqsrua command. The source code for the amqsrua program is provided as an IBM MQ sample. We can use this program as a guide for creating your own monitoring program. We can retrieve the source for the sample from an IBM MQ client installation. The source file is named amqsruaa.c and is located in the samples directory:The amqsrua program subscribes to MQ resource usage topics and formats the resulting published PCF data. The program source provides a basic example of how to subscribe to and consume this type of administrative data. The amqsrua program completes the following tasks:
- On Linux and UNIX platforms, MQ_INSTALLATION_PATH/samp/
- On Windows platforms, MQ_INSTALLATION_PATH\tools\c\Samples\
- Creates a non-durable subscription to the topics identified by the input parameters.
- Calls MQGET repeatedly to get messages from the topics, and writes to stdout.
- Writes a message for each MQI reason (other than MQRC_NONE).
- Stops if there is a MQI completion code of MQCC_FAILED, or when the requested number of resource usage publications have been consumed.