master
go 49 lines 1.23 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 //go:build cgo && ibm_mq
4
5 package pcf
6
7 import (
8 "github.com/ibm-messaging/mq-golang/v5/ibmmq"
9 )
10
11 // ResetQueueStats resets queue statistics and returns the peak values.
12 // WARNING: This is destructive - it resets counters to zero!
13 func (c *Client) ResetQueueStats(queueName string) (map[string]int64, error) {
14 params := []pcfParameter{
15 newStringParameter(ibmmq.MQCA_Q_NAME, queueName),
16 }
17
18 response, err := c.sendPCFCommand(ibmmq.MQCMD_RESET_Q_STATS, params)
19 if err != nil {
20 return nil, err
21 }
22
23 attrs, err := c.parsePCFResponseFromParams(response, "")
24 if err != nil {
25 return nil, err
26 }
27
28 mx := make(map[string]int64)
29
30 // Extract peak/high water mark values
31 if highDepth, ok := attrs[ibmmq.MQIA_HIGH_Q_DEPTH]; ok {
32 mx["high_depth"] = int64(highDepth.(int32))
33 }
34
35 // Extract reset message counts
36 if msgEnqCount, ok := attrs[ibmmq.MQIA_MSG_ENQ_COUNT]; ok {
37 mx["msg_enq_count"] = int64(msgEnqCount.(int32))
38 }
39 if msgDeqCount, ok := attrs[ibmmq.MQIA_MSG_DEQ_COUNT]; ok {
40 mx["msg_deq_count"] = int64(msgDeqCount.(int32))
41 }
42
43 // Time since reset
44 if timeSinceReset, ok := attrs[ibmmq.MQIA_TIME_SINCE_RESET]; ok {
45 mx["time_since_reset"] = int64(timeSinceReset.(int32))
46 }
47
48 return mx, nil
49 }