@@ -105,19 +105,10 @@ const ClassNameQ = "STATQ"
105105const maxBufSize = 100 * 1024 * 1024 // 100 MB
106106const defaultMaxQDepth = 5000
107107
108- // Metrics is the global variable for the tree of data
109- var Metrics AllMetrics
110-
111- // Only issue the warning about a '/' in an object name once.
112- var globalSlashWarning = false
113- var localSlashWarning = false
114-
115108var qInfoMap map [string ]* ObjInfo
116109var chlInfoMap map [string ]* ObjInfo
117110
118111var locale string
119- var discoveryDone = false
120- var publicationCount = 0
121112
122113func GetDiscoveredQueues () []string {
123114 traceEntry ("GetDiscoveredQueues" )
@@ -130,7 +121,7 @@ func GetDiscoveredQueues() []string {
130121}
131122
132123func GetProcessPublicationCount () int {
133- return publicationCount
124+ return ci . publicationCount
134125}
135126
136127/*
@@ -153,14 +144,14 @@ func VerifyConfig() (int32, error) {
153144 var compCode = ibmmq .MQCC_OK
154145
155146 traceEntry ("VerifyConfig" )
156- if ! discoveryDone {
147+ if ! ci . discoveryDone {
157148 err = fmt .Errorf ("Error: Need to call DiscoverAndSubscribe first" )
158149 compCode = ibmmq .MQCC_FAILED
159150 }
160151
161152 if err == nil {
162153 selectors := []int32 {ibmmq .MQIA_MAX_Q_DEPTH , ibmmq .MQIA_DEFINITION_TYPE }
163- v , err = replyQObj .InqMap (selectors )
154+ v , err = ci . si . replyQObj .InqMap (selectors )
164155 if err == nil {
165156 maxQDepth := v [ibmmq .MQIA_MAX_Q_DEPTH ].(int32 )
166157 // Function has tuning based on number of queues to be monitored
@@ -172,8 +163,8 @@ func VerifyConfig() (int32, error) {
172163 // and assume monitor collection interval is one minute
173164 // Since we don't do pubsub-based collection on z/OS, this qdepth doesn't matter
174165 recommendedDepth := (20 + len (qInfoMap )* 5 ) * 6
175- if maxQDepth < int32 (recommendedDepth ) && usePublications {
176- err = fmt .Errorf ("Warning: Maximum queue depth on %s may be too low. Current value = %d. Suggested depth based on queue count is at least %d" , replyQBaseName , maxQDepth , recommendedDepth )
166+ if maxQDepth < int32 (recommendedDepth ) && ci . usePublications {
167+ err = fmt .Errorf ("Warning: Maximum queue depth on %s may be too low. Current value = %d. Suggested depth based on queue count is at least %d" , ci . si . replyQBaseName , maxQDepth , recommendedDepth )
177168 compCode = ibmmq .MQCC_WARNING
178169 }
179170
@@ -184,7 +175,7 @@ func VerifyConfig() (int32, error) {
184175 // separate patterns, then this will overestimate what's needed. Hence it's a warning, not an error.
185176 recommendedDepth = len (chlInfoMap ) + 20
186177 if maxQDepth < int32 (recommendedDepth ) && len (chlInfoMap ) > 0 {
187- err = fmt .Errorf ("Warning: Maximum queue depth on %s may be too low. Current value = %d. Suggested depth based on channel count is at least %d\n " , replyQBaseName , maxQDepth , recommendedDepth )
178+ err = fmt .Errorf ("Warning: Maximum queue depth on %s may be too low. Current value = %d. Suggested depth based on channel count is at least %d\n " , ci . si . replyQBaseName , maxQDepth , recommendedDepth )
188179 compCode = ibmmq .MQCC_WARNING
189180 }
190181
@@ -193,7 +184,7 @@ func VerifyConfig() (int32, error) {
193184 // A LOCAL queue would end up with mixed sets of replies/publications
194185 defType := v [ibmmq .MQIA_DEFINITION_TYPE ].(int32 )
195186 if defType == ibmmq .MQQDT_PREDEFINED {
196- err = fmt .Errorf ("Error: ReplyQ parameter %s must refer to a MODEL queue," , replyQBaseName )
187+ err = fmt .Errorf ("Error: ReplyQ parameter %s must refer to a MODEL queue," , ci . si . replyQBaseName )
197188 compCode = ibmmq .MQCC_FAILED
198189 }
199190 }
@@ -212,7 +203,7 @@ issuing the MQSUB calls to collect the data
212203func DiscoverAndSubscribe (dc DiscoverConfig ) error {
213204 traceEntry ("DiscoverAndSubscribe" )
214205
215- discoveryDone = true
206+ ci . discoveryDone = true
216207 redo := false
217208
218209 qInfoMap = make (map [string ]* ObjInfo )
@@ -225,7 +216,7 @@ func DiscoverAndSubscribe(dc DiscoverConfig) error {
225216func RediscoverAndSubscribe (dc DiscoverConfig ) error {
226217 traceEntry ("RediscoverAndSubscribe" )
227218
228- discoveryDone = true
219+ ci . discoveryDone = true
229220 redo := true
230221
231222 // Assume queues have been deleted and we will tidy up later.
@@ -309,8 +300,8 @@ func discoverAndSubscribe(dc DiscoverConfig, redo bool) error {
309300 // we round up the number of qmgr subs and per-queue subs. This will need extension if more object types are supported
310301 // in the amqsrua-style of resource subscriptions. Add a few extra just in case.
311302 recommendedHandles := 20 + len (qInfoMap )* 5 + 10
312- if maxHandles < int32 (recommendedHandles ) && usePublications {
313- err = fmt .Errorf ("MAXHANDS attribute on queue manager needs increasing. Current value = %d. Recommended minimum based on number of monitored queues = %d" , maxHandles , recommendedHandles )
303+ if ci . si . maxHandles < int32 (recommendedHandles ) && ci . usePublications {
304+ err = fmt .Errorf ("MAXHANDS attribute on queue manager needs increasing. Current value = %d. Recommended minimum based on number of monitored queues = %d" , ci . si . maxHandles , recommendedHandles )
314305 }
315306 }
316307
@@ -334,9 +325,9 @@ func discoverClasses(dc DiscoverConfig, metaPrefix string) error {
334325 traceEntry ("discoverClasses" )
335326 // Have to know the starting point for the topic that tells about classes
336327 if metaPrefix == "" {
337- rootTopic = "$SYS/MQ/INFO/QMGR/" + resolvedQMgrName + "/Monitor/METADATA/CLASSES"
328+ rootTopic = "$SYS/MQ/INFO/QMGR/" + ci . si . resolvedQMgrName + "/Monitor/METADATA/CLASSES"
338329 } else {
339- rootTopic = metaPrefix + "/INFO/QMGR/" + resolvedQMgrName + "/Monitor/METADATA/CLASSES"
330+ rootTopic = metaPrefix + "/INFO/QMGR/" + ci . si . resolvedQMgrName + "/Monitor/METADATA/CLASSES"
340331 }
341332 sub , err = subscribeManaged (rootTopic , & metaReplyQObj )
342333 if err == nil {
@@ -382,7 +373,7 @@ func discoverClasses(dc DiscoverConfig, metaPrefix string) error {
382373 }
383374 }
384375
385- subsOpened = true
376+ ci . si . subsOpened = true
386377 traceExitErr ("discoverClasses" , 0 , err )
387378 return err
388379}
@@ -592,7 +583,7 @@ func discoverStats(dc DiscoverConfig) error {
592583 Metrics .Classes = make (map [int ]* MonClass )
593584
594585 // Allow us to proceed on z/OS even though it does not support pub/sub resources
595- if metaPrefix == "" && ! usePublications {
586+ if metaPrefix == "" && ! ci . usePublications {
596587 traceExit ("discoverStats" , 1 )
597588 return nil
598589 }
@@ -681,7 +672,7 @@ func discoverQueues(monitoredQueuePatterns string) error {
681672 qList , err = inquireObjects (monitoredQueuePatterns , ibmmq .MQOT_Q )
682673 }
683674
684- localSlashWarning = false
675+ ci . localSlashWarning = false
685676 if len (qList ) > 0 {
686677 //fmt.Printf("Monitoring Queues: %v\n", qList)
687678 for i := 0 ; i < len (qList ); i ++ {
@@ -697,8 +688,8 @@ func discoverQueues(monitoredQueuePatterns string) error {
697688 // Because of the possible complexities of pattern matching, we don't
698689 // actually fail the discovery process, but instead issue a warning and continue with
699690 // other queues.
700- if strings .Contains (qName , "/" ) && globalSlashWarning == false {
701- localSlashWarning = true // First time through, issue the warning for all queues
691+ if strings .Contains (qName , "/" ) && ci . globalSlashWarning == false {
692+ ci . localSlashWarning = true // First time through, issue the warning for all queues
702693 logError ("Warning: Cannot subscribe to queue containing '/': %s" , qName )
703694 continue
704695 }
@@ -711,7 +702,7 @@ func discoverQueues(monitoredQueuePatterns string) error {
711702 qInfoMap [qName ] = qInfoElem
712703 }
713704
714- if useStatus {
705+ if ci . useStatus {
715706 if usingRegExp {
716707 for qName , _ := range qInfoMap {
717708 if len (qName ) > 0 {
@@ -723,8 +714,8 @@ func discoverQueues(monitoredQueuePatterns string) error {
723714 }
724715 }
725716
726- if localSlashWarning {
727- globalSlashWarning = true
717+ if ci . localSlashWarning {
718+ ci . globalSlashWarning = true
728719 }
729720
730721 if err != nil {
@@ -797,7 +788,7 @@ func inquireObjects(objectPatternsList string, objectType int32) ([]string, erro
797788 pmo .Options |= ibmmq .MQPMO_FAIL_IF_QUIESCING
798789
799790 putmqmd .Format = "MQADMIN"
800- putmqmd .ReplyToQ = statusReplyQObj .Name
791+ putmqmd .ReplyToQ = ci . si . statusReplyQObj .Name
801792 putmqmd .MsgType = ibmmq .MQMT_REQUEST
802793 putmqmd .Report = ibmmq .MQRO_PASS_DISCARD_AND_EXPIRY
803794
@@ -826,7 +817,7 @@ func inquireObjects(objectPatternsList string, objectType int32) ([]string, erro
826817
827818 // We don't see shared queues in the returned set unless explicitly asked for.
828819 // MQQSGD_ALL returns all locals, and (if qmgr in a QSG) also shared queues.
829- if platform == ibmmq .MQPL_ZOS {
820+ if ci . si . platform == ibmmq .MQPL_ZOS {
830821 pcfparm = new (ibmmq.PCFParameter )
831822 pcfparm .Type = ibmmq .MQCFT_INTEGER
832823 pcfparm .Parameter = ibmmq .MQIA_QSG_DISP
@@ -840,7 +831,7 @@ func inquireObjects(objectPatternsList string, objectType int32) ([]string, erro
840831 buf = append (cfh .Bytes (), buf ... )
841832
842833 // And put the command to the queue
843- err = cmdQObj .Put (putmqmd , pmo , buf )
834+ err = ci . si . cmdQObj .Put (putmqmd , pmo , buf )
844835
845836 if err != nil {
846837 traceExitErr ("inquireObjects" , 3 , err )
@@ -863,7 +854,7 @@ func inquireObjects(objectPatternsList string, objectType int32) ([]string, erro
863854 for truncation := true ; truncation ; {
864855 buf = make ([]byte , bufSize )
865856
866- datalen , err = statusReplyQObj .Get (getmqmd , gmo , buf )
857+ datalen , err = ci . si . statusReplyQObj .Get (getmqmd , gmo , buf )
867858 if err == nil {
868859 truncation = false
869860 cfh , offset := ibmmq .ReadPCFHeader (buf )
@@ -955,7 +946,7 @@ func createSubscriptions() error {
955946 }
956947 } else {
957948 topic := fmt .Sprintf (ty .ObjectTopic , key )
958- sub , err = subscribe (topic , & replyQObj )
949+ sub , err = subscribe (topic , & ci . si . replyQObj )
959950 if err == nil {
960951 ty .subHobj [key ] = sub
961952 im [key ].firstCollection = true
@@ -967,7 +958,7 @@ func createSubscriptions() error {
967958
968959 // Don't have a qmgr-level subscription to this topic. Should
969960 // only do this subscription once at startup
970- sub , err = subscribe (ty .ObjectTopic , & replyQObj )
961+ sub , err = subscribe (ty .ObjectTopic , & ci . si . replyQObj )
971962 ty .subHobj [QMgrMapKey ] = sub
972963 }
973964 }
@@ -1008,9 +999,9 @@ func ProcessPublications() error {
1008999
10091000 traceEntry ("ProcessPublications" )
10101001
1011- publicationCount = 0
1002+ ci . publicationCount = 0
10121003
1013- if ! usePublications {
1004+ if ! ci . usePublications {
10141005 traceExit ("ProcessPublications" , 1 )
10151006 return nil
10161007 }
@@ -1023,7 +1014,7 @@ func ProcessPublications() error {
10231014 // Most common error will be MQRC_NO_MESSAGE_AVAILABLE
10241015 // which will end the loop.
10251016 if err == nil {
1026- publicationCount ++
1017+ ci . publicationCount ++
10271018 elemList , _ := parsePCFResponse (data )
10281019
10291020 // A typical publication contains some fixed
0 commit comments