Skip to content

Commit d45b267

Browse files
committed
Make sure tags are available for queue/qmgr even when
useObjectStatus=false
1 parent 96602e5 commit d45b267

File tree

4 files changed

+60
-25
lines changed

4 files changed

+60
-25
lines changed

CHANGELOG.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
Newest updates are at the top of this file.
33

4+
## Nov 12 2025 - v5.6.7
5+
- mqmetric - Improve performance of clearing response queues if messages are (wrongly) persistent
6+
* Add warning message if persistent messages are found
7+
- mqmetric - Make sure queue/qmgr attributes are always available for tagging metrics
8+
49
## Nov 03 2025 - v5.6.6
510
- mqmetric - Fix for ibm-messaging/mq-metric-samples#440
611

@@ -22,13 +27,13 @@ Newest updates are at the top of this file.
2227
- samples - JWT prefer to use ClientSecret instead of Password
2328

2429
## May 08 2025 - v5.6.3
25-
- mqmetric - Fixes for #222 and ibm-messaging/mq-metric-samples#395
30+
- mqmetric - Fixes for ibm-messaging/mg-golang#222 and ibm-messaging/mq-metric-samples#395
2631

2732
## Feb 28 2025 - v5.6.2
2833
- Update for MQ 9.4.2
2934
- ibmmq - Add function to map PCF attribute values to strings
3035
- ibmmq - Interpret more PCF types (the filters)
31-
- ibmmq - MaxSCOLength fix - PR #216
36+
- ibmmq - MaxSCOLength fix - (#216)
3237
- ibmmq - Add MQIGolangVersion function
3338
- ibmmq - Handle MQ C client callbacks with wrong hObj (#217)
3439
- mqmetric - Ignore the EXTENDED queue metrics unless explicitly enabled
@@ -63,7 +68,7 @@ Newest updates are at the top of this file.
6368
- mqmetric - MQ 9.3 permits resource subscriptions for queues with '/' in name
6469

6570
## Nov 08 2023 - v5.5.2
66-
- ibmmq - #204 data race fix
71+
- ibmmq - data race fix (#204)
6772
- mqmetric - deal with empty QueueSubFilter option
6873

6974
## Oct 19 2023 - v5.5.1
@@ -102,7 +107,7 @@ Newest updates are at the top of this file.
102107
- Update expected Go compiler version
103108

104109
## Jul 23 2022 - v5.3.1
105-
- Fix #189 compile problem
110+
- Fix compile problem (#189)
106111

107112
## Jun 23 2022 - v5.3.0
108113
- Update for MQ 9.3.0
@@ -141,8 +146,8 @@ Scope of mqmetric changes seem to justify new minor number
141146
* Update for MQ 9.2.2
142147
* Add DltMH calls to clarify samples
143148
* mqmetric - Restructure to allow multiple connections & reduce public interfaces
144-
* mqmetric - Deal with discovery of large numbers of queues (#133, #161)
145-
* ibmmq - Add PutDateTime as time.Time field in MQMD, MQDLH. Use of the string forms should be considered deprecated (inspired by #159)
149+
* mqmetric - Deal with discovery of large numbers of queues (ibm-messaging/mg-golang#133, ibm-messaging/mg-golang#161)
150+
* ibmmq - Add PutDateTime as time.Time field in MQMD, MQDLH. Use of the string forms should be considered deprecated (inspired by ibm-messaging/mg-golang#159)
146151
* Add a DEPRECATIONS file for when advance notice might be needed
147152

148153
## Dec 04 2020 - v5.1.3
@@ -229,9 +234,9 @@ Scope of mqmetric changes seem to justify new minor number
229234

230235
## May 31 2019 - v4.0.6
231236
* mqmetric - Allow limited monitoring of V8 Distributed platforms
232-
* Set `ibmmq.usePublications` to *false* to enable in monitor programs #104
237+
* Set `ibmmq.usePublications` to *false* to enable in monitor programs(#104)
233238
* mqmetric - Added queue_attribute_max_depth to permit %full calculation
234-
* Set `ibmmq.useStatus` to *true* to enable in monitor programs #105
239+
* Set `ibmmq.useStatus` to *true* to enable in monitor programs (#105)
235240
* samples - Correct use of the new form of the Inq() verb
236241

237242
## April 23 2019

mqmetric/discover.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -796,16 +796,15 @@ func discoverQueues(monitoredQueuePatterns string) error {
796796
qInfoMap[qName] = qInfoElem
797797
}
798798

799-
if ci.useStatus {
800-
if usingRegExp {
801-
for qName, _ := range qInfoMap {
802-
if len(qName) > 0 {
803-
inquireQueueAttributes(qName)
804-
}
799+
// Get the object attributes that are going to be used for tags
800+
if usingRegExp {
801+
for qName, _ := range qInfoMap {
802+
if len(qName) > 0 {
803+
inquireQueueAttributes(qName)
805804
}
806-
} else {
807-
inquireQueueAttributes(monitoredQueuePatterns)
808805
}
806+
} else {
807+
inquireQueueAttributes(monitoredQueuePatterns)
809808
}
810809

811810
if ci.localSlashWarning {
@@ -1461,15 +1460,14 @@ func Normalise(elem *MonElement, key string, value int64) float64 {
14611460
}
14621461

14631462
// Convert suitable metrics to base units
1464-
if elem.Datatype == ibmmq.MQIAMO_MONITOR_PERCENT ||
1465-
elem.Datatype == ibmmq.MQIAMO_MONITOR_HUNDREDTHS {
1463+
switch elem.Datatype {
1464+
case ibmmq.MQIAMO_MONITOR_PERCENT, ibmmq.MQIAMO_MONITOR_HUNDREDTHS:
14661465
f = f / 100
1467-
} else if elem.Datatype == ibmmq.MQIAMO_MONITOR_MB {
1466+
case ibmmq.MQIAMO_MONITOR_MB:
14681467
f = f * 1024 * 1024
1469-
} else if elem.Datatype == ibmmq.MQIAMO_MONITOR_GB {
1468+
case ibmmq.MQIAMO_MONITOR_GB:
14701469
f = f * 1024 * 1024 * 1024
1471-
} else if elem.Datatype ==
1472-
ibmmq.MQIAMO_MONITOR_MICROSEC {
1470+
case ibmmq.MQIAMO_MONITOR_MICROSEC:
14731471
f = f / 1000000
14741472
}
14751473

mqmetric/metrics.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ and the basic associated metric name.
254254
As an example, one of the metrics available in Prometheus might be "ibmmq_channel_bytes_sent" with
255255
the full name created by combining the product name, the class, and the individual metric.
256256

257-
Access to these metrics requires the "useObjectStatus" (or "-ibmmq.useStatus" as command line flag) configuration
257+
For queues and queue managers, these metrics are always available.
258+
259+
Access to other metrics in this set requires the "useObjectStatus" (or "-ibmmq.useStatus" as command line flag) configuration
258260
attribute to be set for the collector.
259261

260262
Class: amqp

mqmetric/status.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929

3030
// var statusDummy = fmt.Sprintf("dummy")
3131
var timeTravelWarningIssued = false
32+
var persistenceWarningIssued = false
3233

3334
/*
3435
This file defines types and constructors for elements related to status
@@ -169,12 +170,15 @@ func statusTimeEpoch(d string, t string) int64 {
169170
}
170171

171172
func clearQ(hObj ibmmq.MQObject) {
173+
p := 0
172174
buf := make([]byte, 0)
173-
// Empty replyQ in case any left over from previous errors
175+
// Empty reply and publication destination queues in case any left over from previous runs.
176+
// Do it in batches if the messages are persistent. Which they shouldn't be, but you
177+
// never know.
174178
for ok := true; ok; {
175179
getmqmd := ibmmq.NewMQMD()
176180
gmo := ibmmq.NewMQGMO()
177-
gmo.Options = ibmmq.MQGMO_NO_SYNCPOINT
181+
gmo.Options = ibmmq.MQGMO_SYNCPOINT_IF_PERSISTENT
178182
gmo.Options |= ibmmq.MQGMO_FAIL_IF_QUIESCING
179183
gmo.Options |= ibmmq.MQGMO_NO_WAIT
180184
gmo.Options |= ibmmq.MQGMO_CONVERT
@@ -184,7 +188,33 @@ func clearQ(hObj ibmmq.MQObject) {
184188
if err != nil && err.(*ibmmq.MQReturn).MQCC == ibmmq.MQCC_FAILED {
185189
ok = false
186190
}
191+
192+
if getmqmd.Persistence == ibmmq.MQPER_PERSISTENT {
193+
p++
194+
if (p % 50) == 0 {
195+
err = hObj.GetHConn().Cmit()
196+
if err != nil {
197+
logError("Problem committing removal of persistent messages: %v", err)
198+
} else {
199+
p = 0
200+
}
201+
}
202+
203+
if !persistenceWarningIssued {
204+
persistenceWarningIssued = true
205+
logWarn("Response messages are unnecessarily persistent. Check the DEFPSIST value on the configured reply queues.")
206+
}
207+
}
187208
}
209+
210+
// If we've not committed removal of a final batch of persistent messages, do it now.
211+
if p > 0 {
212+
err := hObj.GetHConn().Cmit()
213+
if err != nil {
214+
logError("Problem committing removal of persistent messages: %v", err)
215+
}
216+
}
217+
188218
return
189219
}
190220

0 commit comments

Comments
 (0)