@@ -35,10 +35,11 @@ import (
3535)
3636
3737var (
38- first = true
39- errorCount = 0
40- lastPoll = time .Now ()
41- platformString = ""
38+ first = true
39+ errorCount = 0
40+ lastPoll = time .Now ()
41+ lastQueueDiscovery = time .Now ()
42+ platformString = ""
4243)
4344
4445const (
@@ -125,9 +126,9 @@ func Collect() error {
125126 }
126127 err = mqmetric .CollectSubStatus (config .cf .MonitoredSubscriptions )
127128 if err != nil {
128- log .Errorf ("Error collecting topic status: %v" , err )
129+ log .Errorf ("Error collecting subscription status: %v" , err )
129130 } else {
130- log .Debugf ("Collected all topic status" )
131+ log .Debugf ("Collected all subscription status" )
131132 }
132133
133134 err = mqmetric .CollectQueueStatus (config .cf .MonitoredQueues )
@@ -136,6 +137,25 @@ func Collect() error {
136137 } else {
137138 log .Debugf ("Collected all queue status" )
138139 }
140+
141+ if mqmetric .GetPlatform () == ibmmq .MQPL_ZOS {
142+ err = mqmetric .CollectUsageStatus ()
143+ if err != nil {
144+ log .Errorf ("Error collecting bufferpool/pageset status: %v" , err )
145+ } else {
146+ log .Debugf ("Collected all buffer pool/pageset status" )
147+ }
148+ }
149+ }
150+ }
151+
152+ thisDiscovery := time .Now ()
153+ elapsed = thisDiscovery .Sub (lastQueueDiscovery )
154+ if config .cf .RediscoverDuration > 0 {
155+ if elapsed >= config .cf .RediscoverDuration {
156+ s := config .cf .MonitoredQueues
157+ err = mqmetric .RediscoverAndSubscribe (s , true , "" )
158+ lastQueueDiscovery = thisDiscovery
139159 }
140160 }
141161
@@ -212,7 +232,7 @@ func Collect() error {
212232 chlName := mqmetric .ChannelStatus .Attributes [mqmetric .ATTR_CHL_NAME ].Values [key ].ValueString
213233 connName := mqmetric .ChannelStatus .Attributes [mqmetric .ATTR_CHL_CONNNAME ].Values [key ].ValueString
214234 jobName := mqmetric .ChannelStatus .Attributes [mqmetric .ATTR_CHL_JOBNAME ].Values [key ].ValueString
215- key1 := chlName + "/" + connName + "/" + jobName + "/" + rqmName
235+ key1 := "channel/" + chlName + "/" + connName + "/" + jobName + "/" + rqmName
216236
217237 if pt , ok = ptMap [key1 ]; ! ok {
218238 pt = pointsStruct {}
@@ -238,7 +258,7 @@ func Collect() error {
238258 for key , value := range attr .Values {
239259 if value .IsInt64 {
240260 qName := mqmetric .QueueStatus .Attributes [mqmetric .ATTR_Q_NAME ].Values [key ].ValueString
241- key1 := qName
261+ key1 := "queue/" + qName
242262
243263 if pt , ok = ptMap [key1 ]; ! ok {
244264 pt = pointsStruct {}
@@ -261,7 +281,7 @@ func Collect() error {
261281 if value .IsInt64 {
262282 topicName := mqmetric .TopicStatus .Attributes [mqmetric .ATTR_TOPIC_STRING ].Values [key ].ValueString
263283 topicStatusType := mqmetric .TopicStatus .Attributes [mqmetric .ATTR_TOPIC_STATUS_TYPE ].Values [key ].ValueString
264- key1 := mqmetric .TopicKey (topicName , topicStatusType )
284+ key1 := "topic/" + mqmetric .TopicKey (topicName , topicStatusType )
265285
266286 if pt , ok = ptMap [key1 ]; ! ok {
267287 pt = pointsStruct {}
@@ -285,7 +305,7 @@ func Collect() error {
285305 if value .IsInt64 {
286306 qMgrName := mqmetric .QueueManagerStatus .Attributes [mqmetric .ATTR_QMGR_NAME ].Values [key ].ValueString
287307
288- key1 := qMgrName
308+ key1 := "qmgr/" + qMgrName
289309
290310 if pt , ok = ptMap [key1 ]; ! ok {
291311 pt = pointsStruct {}
@@ -311,7 +331,7 @@ func Collect() error {
311331 subTypeString := strings .Replace (ibmmq .MQItoString ("SUBTYPE" , subType ), "MQSUBTYPE_" , "" , - 1 )
312332 topicString := mqmetric .SubStatus .Attributes [mqmetric .ATTR_SUB_TOPIC_STRING ].Values [key ].ValueString
313333
314- key1 := subId
334+ key1 := "subscription/" + subId
315335
316336 if pt , ok = ptMap [key1 ]; ! ok {
317337 pt = pointsStruct {}
@@ -326,11 +346,61 @@ func Collect() error {
326346 pt .Tags ["topic" ] = topicString
327347 }
328348
329- pt .Metric [fixup (attr .MetricName )] = mqmetric .QueueManagerNormalise (attr , value .ValueInt64 )
349+ pt .Metric [fixup (attr .MetricName )] = mqmetric .SubNormalise (attr , value .ValueInt64 )
330350 ptMap [key1 ] = pt
331351 }
332352 }
333353 }
354+
355+ if mqmetric .GetPlatform () == ibmmq .MQPL_ZOS {
356+ for _ , attr := range mqmetric .UsageBpStatus .Attributes {
357+ for key , value := range attr .Values {
358+ bpId := mqmetric .UsageBpStatus .Attributes [mqmetric .ATTR_BP_ID ].Values [key ].ValueString
359+ bpLocation := mqmetric .UsageBpStatus .Attributes [mqmetric .ATTR_BP_LOCATION ].Values [key ].ValueString
360+ bpClass := mqmetric .UsageBpStatus .Attributes [mqmetric .ATTR_BP_CLASS ].Values [key ].ValueString
361+ if value .IsInt64 && ! attr .Pseudo {
362+ key1 := "bufferpool/" + bpId
363+ if pt , ok = ptMap [key1 ]; ! ok {
364+ pt = pointsStruct {}
365+ pt .ObjectType = "bufferpool"
366+ pt .Metric = make (map [string ]float64 )
367+ pt .Tags = make (map [string ]string )
368+ pt .Tags ["bufferpool" ] = bpId
369+ pt .Tags ["location" ] = bpLocation
370+ pt .Tags ["pageclass" ] = bpClass
371+ pt .Tags ["qmgr" ] = strings .TrimSpace (config .cf .QMgrName )
372+ pt .Tags ["platform" ] = platformString
373+ }
374+ pt .Metric [fixup (attr .MetricName )] = mqmetric .UsageNormalise (attr , value .ValueInt64 )
375+ ptMap [key1 ] = pt
376+ }
377+ }
378+ }
379+
380+ for _ , attr := range mqmetric .UsagePsStatus .Attributes {
381+ for key , value := range attr .Values {
382+ psId := mqmetric .UsagePsStatus .Attributes [mqmetric .ATTR_PS_ID ].Values [key ].ValueString
383+ bpId := mqmetric .UsagePsStatus .Attributes [mqmetric .ATTR_PS_BPID ].Values [key ].ValueString
384+ if value .IsInt64 && ! attr .Pseudo {
385+ key1 := "pageset/" + psId
386+ if pt , ok = ptMap [key1 ]; ! ok {
387+ pt = pointsStruct {}
388+ pt .ObjectType = "pageset"
389+ pt .Metric = make (map [string ]float64 )
390+ pt .Tags = make (map [string ]string )
391+ pt .Tags ["pageset" ] = psId
392+ pt .Tags ["bufferpool" ] = bpId
393+ pt .Tags ["qmgr" ] = strings .TrimSpace (config .cf .QMgrName )
394+ pt .Tags ["platform" ] = platformString
395+ }
396+ pt .Metric [fixup (attr .MetricName )] = mqmetric .UsageNormalise (attr , value .ValueInt64 )
397+ ptMap [key1 ] = pt
398+ }
399+
400+ }
401+ }
402+ }
403+
334404 }
335405
336406 for _ , pt := range ptMap {
0 commit comments