Skip to content

Commit 23c6eca

Browse files
committed
issue74 added "STOPPED" status for listener
1 parent abcbba6 commit 23c6eca

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,12 +1445,17 @@ This section provides a mapping between MQ listener statuses and metric values,
14451445
</tr>
14461446
<tr>
14471447
<td>STARTING</td>
1448-
<td>0.5</td>
1448+
<td>0.75</td>
14491449
</tr>
14501450
<tr>
14511451
<td>STOPPING</td>
1452+
<td>0.5</td>
1453+
</tr>
1454+
<tr>
1455+
<td>STOPPED</td>
14521456
<td>0</td>
14531457
</tr>
1458+
14541459
</tbody>
14551460
</table>
14561461

src/main/java/ru/cinimex/exporter/mq/MQPCFSubscriber.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,13 @@ private void updateMetricsWithWildcards(PCFMessage[] pcfResponse) {
116116
updateMetricWithoutWildcards(directPCFResponse[0], objectName);
117117
} catch (PCFException e) {
118118
//This error means, that channel has status "inactive".
119-
logger.warn("Channel {} is possibly inactive.", objectName);
120-
if (e.reasonCode == MQConstants.MQRCCF_CHL_STATUS_NOT_FOUND) {
119+
if (object.getType() == MQObject.MQType.CHANNEL && e.reasonCode == MQConstants.MQRCCF_CHL_STATUS_NOT_FOUND) {
121120
MetricsManager.updateMetric(MetricsReference.getMetricName(object.getType()), MetricsReference.getMetricValue(object.getType(), MQConstants.MQCHS_INACTIVE), queueManagerName, objectName);
121+
logger.warn("Channel {} is possibly inactive.", objectName);
122+
}
123+
if (object.getType() == MQObject.MQType.LISTENER && e.reasonCode == MQConstants.MQRC_UNKNOWN_OBJECT_NAME) {
124+
MetricsManager.updateMetric(MetricsReference.getMetricName(object.getType()), MetricsReference.getMetricValue(object.getType(), MQConstants.MQSVC_STATUS_STOPPED), queueManagerName, objectName);
125+
logger.warn("Listener {} is possibly stopped.", objectName);
122126
}
123127
} catch (IOException | MQException e) {
124128
logger.error("Error occurred during sending PCF command: ", e);
@@ -145,6 +149,10 @@ public void run() {
145149
logger.warn("Channel {} is possibly inactive.", object.getName());
146150
MetricsManager.updateMetric(MetricsReference.getMetricName(object.getType()), MetricsReference.getMetricValue(object.getType(), MQConstants.MQCHS_INACTIVE), queueManagerName, object.getName());
147151
}
152+
if (object.getType() == MQObject.MQType.LISTENER && e.reasonCode == MQConstants.MQRC_UNKNOWN_OBJECT_NAME) {
153+
MetricsManager.updateMetric(MetricsReference.getMetricName(object.getType()), MetricsReference.getMetricValue(object.getType(), MQConstants.MQSVC_STATUS_STOPPED), queueManagerName, object.getName());
154+
logger.warn("Listener {} is possibly stopped.", object.getName());
155+
}
148156
} catch (MQException | IOException e) {
149157
logger.error("Error occurred during sending PCF command: ", e);
150158
}

src/main/java/ru/cinimex/exporter/prometheus/metrics/MetricsReference.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@ public class MetricsReference {
162162

163163
private static HashMap<Integer, Double> listenerStatus = new HashMap<Integer, Double>() {
164164
{
165-
put(MQConstants.MQSVC_STATUS_RUNNING, (double) 1);
166-
put(MQConstants.MQSVC_STATUS_STARTING, 0.5);
167-
put(MQConstants.MQSVC_STATUS_STOPPING, (double) 0);
165+
put(MQConstants.MQSVC_STATUS_RUNNING, 1.0);
166+
put(MQConstants.MQSVC_STATUS_STARTING, 0.75);
167+
put(MQConstants.MQSVC_STATUS_STOPPING, 0.5);
168+
put(MQConstants.MQSVC_STATUS_STOPPED, 0.0);
168169
}
169170
};
170171

0 commit comments

Comments
 (0)