@@ -31,6 +31,7 @@ about running MQ channels
31
31
32
32
import (
33
33
"github.com/ibm-messaging/mq-golang/ibmmq"
34
+ "regexp"
34
35
"strings"
35
36
)
36
37
@@ -131,7 +132,13 @@ func CollectChannelStatus(patterns string) error {
131
132
}
132
133
133
134
// 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
+ }
135
142
136
143
}
137
144
@@ -245,16 +252,18 @@ func collectChannelStatus(pattern string, instanceType int32) error {
245
252
if cfh .Reason != ibmmq .MQRC_NONE {
246
253
continue
247
254
}
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
+ }
250
259
}
251
260
}
252
261
253
262
return err
254
263
}
255
264
256
265
// 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 {
258
267
var elem * ibmmq.PCFParameter
259
268
260
269
chlName := ""
@@ -293,7 +302,18 @@ func parseData(cfh *ibmmq.MQCFH, buf []byte) string {
293
302
}
294
303
295
304
// 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
+ }
297
317
298
318
ChannelStatus .Attributes [ATTR_CHL_NAME ].Values [key ] = newStatusValueString (chlName )
299
319
ChannelStatus .Attributes [ATTR_CHL_CONNNAME ].Values [key ] = newStatusValueString (connName )
0 commit comments