|
| 1 | +# IBM MQ Metrics |
| 2 | + |
| 3 | +:warning: This software is under development. |
| 4 | + |
| 5 | +## Use case |
| 6 | + |
| 7 | +IBM MQ, formerly known as WebSphere MQ (message queue) series, is an IBM software for |
| 8 | +program-to-program messaging across multiple platforms. |
| 9 | + |
| 10 | +The IBM MQ metrics utility here can monitor multiple queues managers and their resources, |
| 11 | +namely queues, topics, channels and listeners The metrics are extracted out using the |
| 12 | +[PCF command messages](https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.adm.doc/q020010_.htm). |
| 13 | + |
| 14 | +The metrics for queue manager, queue, topic, channel and listener can be configured. |
| 15 | + |
| 16 | +The MQ Monitor is compatible with IBM MQ version 7.x, 8.x and 9.x. |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +This software requires compilation with Java 11. |
| 21 | +It targets language level 8 and outputs java 8 class files. |
| 22 | + |
| 23 | +The extension has a dependency on the following jar's depending on IBM MQ version: |
| 24 | + |
| 25 | +* v8.0.0 and above |
| 26 | + |
| 27 | +``` |
| 28 | +com.ibm.mq.allclient.jar |
| 29 | +``` |
| 30 | + |
| 31 | +* For other versions |
| 32 | + |
| 33 | +``` |
| 34 | +com.ibm.mq.commonservices.jar |
| 35 | +com.ibm.mq.jar |
| 36 | +com.ibm.mq.jmqi.jar |
| 37 | +com.ibm.mq.headers.jar |
| 38 | +com.ibm.mq.pcf.jar |
| 39 | +dhbcore.jar |
| 40 | +connector.jar |
| 41 | +``` |
| 42 | + |
| 43 | +These jar files are typically found in ```/opt/mqm/java/lib``` on a UNIX server but may be |
| 44 | +found in an alternate location depending upon your environment. |
| 45 | + |
| 46 | +In case of **CLIENT** transport type, IBM MQ Client must be installed to get the MQ jars. |
| 47 | +[The IBM MQ Client jars can be downloaded here](https://developer.ibm.com/messaging/mq-downloads/). |
| 48 | + |
| 49 | +### MQ monitoring configuration |
| 50 | + |
| 51 | +This software reads events from event queues associated with the queue manager: |
| 52 | + |
| 53 | +* `SYSTEM.ADMIN.PERFM.EVENT`: Performance events, such as low, high, and full queue depth events. |
| 54 | +* `SYSTEM.ADMIN.QMGR.EVENT`: Authority events |
| 55 | +* `SYSTEM.ADMIN.CONFIG.EVENT`: Configuration events |
| 56 | + |
| 57 | +Please turn on those events to take advantage of this monitoring. |
| 58 | + |
| 59 | +## Build |
| 60 | + |
| 61 | +Build the package with: |
| 62 | + |
| 63 | +```shell |
| 64 | +cd ibm-mq-metrics |
| 65 | +../gradlew shadowJar |
| 66 | +``` |
| 67 | + |
| 68 | +Note: Due to restrictive licensing, this uber-jar (fat-jar) does not include the IBM client jar. |
| 69 | + |
| 70 | +## Run |
| 71 | + |
| 72 | +Run the standalone jar alongside the IBM jar: |
| 73 | + |
| 74 | +```shell |
| 75 | +cd ibm-mq-metrics |
| 76 | +java \ |
| 77 | + -Djavax.net.ssl.keyStore=key.jks \ |
| 78 | + -Djavax.net.ssl.keyStorePassword=<password> \ |
| 79 | + -Djavax.net.ssl.trustStore=key.jks \ |
| 80 | + -Djavax.net.ssl.trustStorePassword=<password> \ |
| 81 | + -cp build/libs/opentelemetry-ibm-mq-monitoring-<version>-all.jar:lib/com.ibm.mq.allclient.jar \ |
| 82 | + io.opentelemetry.ibm.mq.opentelemetry.Main \ |
| 83 | + ./my-config.yml |
| 84 | +``` |
| 85 | + |
| 86 | +## Connection |
| 87 | + |
| 88 | +There are two transport modes in which this extension can be run: |
| 89 | + |
| 90 | +* **Binding** : Requires WMQ Extension to be deployed in machine agent on the same machine where |
| 91 | + WMQ server is installed. |
| 92 | +* **Client** : In this mode, the WMQ extension is installed on a different host than the IBM MQ |
| 93 | + server. Please install the [IBM MQ Client](https://developer.ibm.com/messaging/mq-downloads/) |
| 94 | + for this mode to get the necessary jars as mentioned previously. |
| 95 | + |
| 96 | +If this extension is configured for **CLIENT** transport type |
| 97 | + |
| 98 | +1. Please make sure the MQ's host and port is accessible. |
| 99 | +2. Credentials of user with correct access rights would be needed in config.yml. |
| 100 | +3. If the hosting OS for IBM MQ is Windows, Windows user credentials will be needed. |
| 101 | + |
| 102 | +If you are in **Bindings** mode, please make sure to start the MA process under a user which has |
| 103 | +the following permissions on the broker. Similarly, for **Client** mode, please provide the user |
| 104 | +credentials in config.yml which have permissions listed below. |
| 105 | + |
| 106 | +The user connecting to the queueManager should have the inquire, get, put (since PCF responses |
| 107 | +cause dynamic queues to be created) permissions. For metrics that execute MQCMD_RESET_Q_STATS |
| 108 | +command, chg permission is needed. |
| 109 | + |
| 110 | +### SSL Support |
| 111 | + |
| 112 | +_Note: The following is only needed for versions of Java 8 before 8u161._ |
| 113 | + |
| 114 | +1. Configure the IBM SSL Cipher Suite in the config.yml. |
| 115 | + Note that, to use some CipherSuites the unrestricted policy needs to be configured in JRE. |
| 116 | + Please visit [this link](http://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.security.component.80.doc/security-component/sdkpolicyfiles.html) |
| 117 | + for more details. For Oracle JRE, please update with [JCE Unlimited Strength Jurisdiction Policy](http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html). |
| 118 | + The download includes a readme file with instructions on how to apply these files to JRE. |
| 119 | + |
| 120 | +2. Please add the following JVM arguments to the MA start up command or script. |
| 121 | + |
| 122 | + ```-Dcom.ibm.mq.cfg.useIBMCipherMappings=false``` (If you are using IBM Cipher Suites, set the |
| 123 | + flag to true. Please visit [this link](http://www.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.dev.doc/q113210_.htm) for more details. |
| 124 | + ) |
| 125 | +3. To configure SSL, the MA's trust store and keystore needs to be setup with the JKS filepath. |
| 126 | + They can be passed either as Machine Agent JVM arguments or configured in config.yml (sslConnection) <br /> |
| 127 | + |
| 128 | + a. Machine Agent JVM arguments as follows: |
| 129 | + |
| 130 | + ```-Djavax.net.ssl.trustStore=<PATH_TO_JKS_FILE>```<br /> |
| 131 | + ```-Djavax.net.ssl.trustStorePassword=<PASS>```<br /> |
| 132 | + ```-Djavax.net.ssl.keyStore=<PATH_TO_JKS_FILE>```<br /> |
| 133 | + ```-Djavax.net.ssl.keyStorePassword=<PASS>```<br /> |
| 134 | + |
| 135 | + b. sslConnection in config.yml, configure the trustStorePassword. Same holds for keyStore configuration as well. |
| 136 | + |
| 137 | + ``` |
| 138 | + sslConnection: |
| 139 | + trustStorePath: "" |
| 140 | + trustStorePassword: "" |
| 141 | +
|
| 142 | + keyStorePath: "" |
| 143 | + keyStorePassword: "" |
| 144 | + ``` |
| 145 | +
|
| 146 | +## Configuration |
| 147 | +
|
| 148 | +**Note** : Please make sure to not use tab (\t) while editing yaml files. You may want to validate |
| 149 | +the yaml file using a [yaml validator](https://jsonformatter.org/yaml-validator). Configure the monitor by copying and editing the |
| 150 | +config.yml file in <code>src/main/resources/config.yml</code>. |
| 151 | +
|
| 152 | +1. Configure the queueManagers with appropriate fields and filters. You can configure multiple |
| 153 | + queue managers in one configuration file. |
| 154 | +2. To run the extension at a frequency > 1 minute, please configure the taskSchedule section. |
| 155 | + Refer to the [Task Schedule](https://community.appdynamics.com/t5/Knowledge-Base/Task-Schedule-for-Extensions/ta-p/35414) doc for details. |
| 156 | +
|
| 157 | +### Monitoring Workings - Internals |
| 158 | +
|
| 159 | +This software extracts metrics through [PCF framework](https://www.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.adm.doc/q019990_.htm). |
| 160 | +[A complete list of PCF commands are listed here](https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.ref.adm.doc/q086870_.htm). |
| 161 | +Each queue manager has an administration queue with a standard queue name and |
| 162 | +the extension sends PCF command messages to that queue. On Windows and Unix platforms, the PCF |
| 163 | +commands are sent is always sent to the SYSTEM.ADMIN.COMMAND.QUEUE queue. |
| 164 | +[More details mentioned here](https://www.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.adm.doc/q020010_.htm) |
| 165 | +
|
| 166 | +By default, the PCF responses are sent to the SYSTEM.DEFAULT.MODEL.QUEUE. Using this queue causes |
| 167 | +a temporary dynamic queue to be created. You can override the default here by using the |
| 168 | +`modelQueueName` and `replyQueuePrefix` fields in the config.yml. |
| 169 | +[More details mentioned here](https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.ref.adm.doc/q083240_.htm) |
| 170 | +
|
| 171 | +## Metrics |
| 172 | +
|
| 173 | +See [docs/metrics.md](docs/metrics.md). |
| 174 | +
|
| 175 | +## Troubleshooting |
| 176 | +
|
| 177 | +1. Error `Completion Code '2', Reason '2495'` |
| 178 | + Normally this error occurs if the environment variables are not set up correctly for this extension to work MQ in Bindings Mode. |
| 179 | +
|
| 180 | + If you are seeing `Failed to load the WebSphere MQ native JNI library: 'mqjbnd'`, please add the following jvm argument when starting the MA. |
| 181 | +
|
| 182 | + -Djava.library.path=\<path to libmqjbnd.so\> For eg. on Unix it could -Djava.library.path=/opt/mqm/java/lib64 for 64-bit or -Djava.library.path=/opt/mqm/java/lib for 32-bit OS |
| 183 | +
|
| 184 | + Sometimes you also have run the setmqenv script before using the above jvm argument to start the machine agent. |
| 185 | +
|
| 186 | + . /opt/mqm/bin/setmqenv -s |
| 187 | +
|
| 188 | + For more details, please check this [doc](https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.1.0/com.ibm.mq.doc/zr00610_.htm) |
| 189 | +
|
| 190 | + This might occur due to various reasons ranging from incorrect installation to applying |
| 191 | + IBM Fix Packs, but most of the time it happens when you are trying to connect in `Bindings` |
| 192 | + mode and machine agent is not on the same machine on which WMQ server is running. If you want |
| 193 | + to connect to WMQ server from a remote machine then connect using `Client` mode. |
| 194 | +
|
| 195 | + Another way to get around this issue is to avoid using the Bindings mode. Connect using CLIENT |
| 196 | + transport type from a remote box. |
| 197 | +
|
| 198 | +2. Error `Completion Code '2', Reason '2035'` |
| 199 | + This could happen for various reasons but for most of the cases, for **Client** mode the |
| 200 | + user specified in config.yml is not authorized to access the queue manager. Also sometimes |
| 201 | + even if userid and password are correct, channel auth (CHLAUTH) for that queue manager blocks |
| 202 | + traffics from other ips, you need to contact admin to provide you access to the queue manager. |
| 203 | + For Bindings mode, please make sure that the MA is owned by a mqm user. |
| 204 | +
|
| 205 | +3. `MQJE001: Completion Code '2', Reason '2195'` |
| 206 | + This could happen in **Client** mode. Please make sure that the IBM MQ dependency jars are correctly referenced in classpath of monitor.xml |
| 207 | +
|
| 208 | +4. `MQJE001: Completion Code '2', Reason '2400'` |
| 209 | + This could happen if unsupported cipherSuite is provided or JRE not having/enabled unlimited jurisdiction policy files. Please check SSL Support section. |
| 210 | +
|
| 211 | +5. If you are seeing `NoClassDefFoundError` or `ClassNotFoundException` error for any of the MQ dependency even after providing correct path in monitor.xml, then you can also try copying all the required jars in WMQMonitor (MAHome/monitors/WMQMonitor) folder and provide classpath in monitor.xml like below |
| 212 | +
|
| 213 | + ``` |
| 214 | + <classpath>opentelemetry-ibm-mq-monitoring-<version>-all.jar;com.ibm.mq.allclient.jar</classpath> |
| 215 | + ``` |
| 216 | +
|
| 217 | + OR |
| 218 | +
|
| 219 | + ``` |
| 220 | + <classpath>opentelemetry-ibm-mq-monitoring-<version>-all.jar;com.ibm.mq.jar;com.ibm.mq.jmqi.jar;com.ibm.mq.commonservices.jar;com.ibm.mq.headers.jar;com.ibm.mq.pcf.jar;connector.jar;dhbcore.jar</classpath> |
| 221 | + ``` |
| 222 | +
|
| 223 | +## Component Owners |
| 224 | +
|
| 225 | +- [Antoine Toulme Sharma](https://github.com/atoulme), Splunk |
| 226 | +- [Jason Plumb](https://github.com/breedx-splk), Splunk |
| 227 | +
|
| 228 | +Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). |
0 commit comments