Skip to content

Commit 7e63565

Browse files
committed
Make use of Saved status on channels
1 parent 2ed93ed commit 7e63565

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

mqmetric/channel.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ about running MQ channels
3131

3232
import (
3333
"github.com/ibm-messaging/mq-golang/ibmmq"
34+
"regexp"
3435
"strings"
3536
)
3637

@@ -131,7 +132,13 @@ func CollectChannelStatus(patterns string) error {
131132
}
132133

133134
// This would allow us to extract SAVED information too
134-
err = collectChannelStatus(pattern, ibmmq.MQOT_CURRENT_CHANNEL)
135+
errCurrent := collectChannelStatus(pattern, ibmmq.MQOT_CURRENT_CHANNEL)
136+
errSaved := collectChannelStatus(pattern, ibmmq.MQOT_SAVED_CHANNEL)
137+
if errCurrent != nil {
138+
err = errCurrent
139+
} else {
140+
err = errSaved
141+
}
135142

136143
}
137144

@@ -245,16 +252,18 @@ func collectChannelStatus(pattern string, instanceType int32) error {
245252
if cfh.Reason != ibmmq.MQRC_NONE {
246253
continue
247254
}
248-
key := parseData(cfh, replyBuf[offset:datalen])
249-
channelsSeen[key] = true
255+
key := parseData(instanceType, cfh, replyBuf[offset:datalen])
256+
if key != "" {
257+
channelsSeen[key] = true
258+
}
250259
}
251260
}
252261

253262
return err
254263
}
255264

256265
// Given a PCF response message, parse it to extract the desired statistics
257-
func parseData(cfh *ibmmq.MQCFH, buf []byte) string {
266+
func parseData(instanceType int32, cfh *ibmmq.MQCFH, buf []byte) string {
258267
var elem *ibmmq.PCFParameter
259268

260269
chlName := ""
@@ -293,7 +302,18 @@ func parseData(cfh *ibmmq.MQCFH, buf []byte) string {
293302
}
294303

295304
// Create a unique key for this channel instance
296-
key = chlName + "/" + connName + "/" + jobName
305+
key = chlName + "/" + connName + "/" + rqmName + "/" + jobName
306+
307+
// Look to see if we've already seen a Current channel status that matches
308+
// the Saved version. If so, then don't bother with the Saved status
309+
if instanceType == ibmmq.MQOT_SAVED_CHANNEL {
310+
subKey := chlName + "/" + connName + "/" + rqmName + "/.*"
311+
for k, _ := range channelsSeen {
312+
if regexp.MatchString(subkey, k) {
313+
return ""
314+
}
315+
}
316+
}
297317

298318
ChannelStatus.Attributes[ATTR_CHL_NAME].Values[key] = newStatusValueString(chlName)
299319
ChannelStatus.Attributes[ATTR_CHL_CONNNAME].Values[key] = newStatusValueString(connName)

0 commit comments

Comments
 (0)