Skip to content

Commit d5bb8e3

Browse files
committed
Add hostname for 9.3.2 qmgrs
1 parent e57d083 commit d5bb8e3

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎mqmetric/discover.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ type ObjInfo struct {
9090
Description string
9191
// Qmgr attributes
9292
QMgrName string
93+
HostName string
9394
// These are used for queue information
9495
AttrMaxDepth int64 // The queue attribute value. Not the max depth reported by RESET QSTATS
9596
AttrUsage int64 // Normal or XMITQ

‎mqmetric/qmgr.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ func parseQMgrData(instanceType int32, cfh *ibmmq.MQCFH, buf []byte) string {
338338
// And then re-parse the message so we can store the metrics now knowing the map key
339339
parmAvail = true
340340
offset = 0
341+
hostname := DUMMY_STRING
341342
for parmAvail && cfh.CompCode != ibmmq.MQCC_FAILED {
342343
elem, bytesRead = ibmmq.ReadPCFParameter(buf[offset:])
343344
offset += bytesRead
@@ -352,12 +353,15 @@ func parseQMgrData(instanceType int32, cfh *ibmmq.MQCFH, buf []byte) string {
352353
startTime = strings.TrimSpace(elem.String[0])
353354
case ibmmq.MQCACF_Q_MGR_START_DATE:
354355
startDate = strings.TrimSpace(elem.String[0])
356+
case ibmmq.MQCACF_HOST_NAME: // This started to be available from 9.3.2
357+
hostname = strings.TrimSpace(elem.String[0])
355358
}
356359
}
357360
}
358361

359362
now := time.Now()
360363
st.Attributes[ATTR_QMGR_UPTIME].Values[key] = newStatusValueInt64(statusTimeDiff(now, startDate, startTime))
364+
qMgrInfo.HostName = hostname
361365

362366
traceExitF("parseQMgrData", 0, "Key: %s", key)
363367
return key
@@ -400,3 +404,24 @@ func parseQMgrListeners(cfh *ibmmq.MQCFH, buf []byte) bool {
400404
func QueueManagerNormalise(attr *StatusAttribute, v int64) float64 {
401405
return statusNormalise(attr, v)
402406
}
407+
408+
// Return the nominated MQCA* attribute from the object's attributes
409+
// stored in the map. The "key" is unused for now, but might be useful
410+
// if we do a version that supports connections to multiple qmgrs. And it keeps
411+
// the function looking like the equivalent for the Queue query.
412+
func GetQueueManagerAttribute(key string, attribute int32) string {
413+
v := DUMMY_STRING
414+
415+
switch attribute {
416+
case ibmmq.MQCACF_HOST_NAME:
417+
v = qMgrInfo.HostName
418+
default:
419+
v = DUMMY_STRING
420+
}
421+
v = strings.TrimSpace(v)
422+
423+
if v == "" {
424+
v = DUMMY_STRING
425+
}
426+
return v
427+
}

0 commit comments

Comments
 (0)