mqmetric

package
Version: v5.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 9 Imported by: 8

Documentation

Overview

Package mqmetric contains a set of routines common to several commands used to export MQ metrics to different backend storage mechanisms including Prometheus and InfluxDB.

Package mqmetric contains a set of routines common to several commands used to export MQ metrics to different backend storage mechanisms including Prometheus and InfluxDB.

Package mqmetric contains a set of routines common to several commands used to export MQ metrics to different backend storage mechanisms including Prometheus and InfluxDB.

Package mqmetric contains a set of routines common to several commands used to export MQ metrics to different backend storage mechanisms including Prometheus and InfluxDB.

Package mqmetric contains a set of routines common to several commands used to export MQ metrics to different backend storage mechanisms including Prometheus and InfluxDB.

Package mqmetric contains a set of routines common to several commands used to export MQ metrics to different backend storage mechanisms including Prometheus and InfluxDB.

Package mqmetric contains a set of routines common to several commands used to export MQ metrics to different backend storage mechanisms including Prometheus and InfluxDB.

Package mqmetric contains a set of routines common to several commands used to export MQ metrics to different backend storage mechanisms including Prometheus and InfluxDB.

Package mqmetric contains a set of routines common to several commands used to export MQ metrics to different backend storage mechanisms including Prometheus and InfluxDB.

Index

Constants

View Source
const (
	ATTR_CHL_NAME     = "name"
	ATTR_CHL_CONNNAME = "connname"
	ATTR_CHL_JOBNAME  = "jobname"
	ATTR_CHL_RQMNAME  = "rqmname"

	ATTR_CHL_MESSAGES      = "messages"
	ATTR_CHL_BYTES_SENT    = "bytes_sent"
	ATTR_CHL_BYTES_RCVD    = "bytes_rcvd"
	ATTR_CHL_BUFFERS_SENT  = "buffers_sent"
	ATTR_CHL_BUFFERS_RCVD  = "buffers_rcvd"
	ATTR_CHL_BATCHES       = "batches"
	ATTR_CHL_STATUS        = "status"
	ATTR_CHL_STATUS_SQUASH = ATTR_CHL_STATUS + "_squash"
	ATTR_CHL_SUBSTATE      = "substate"
	ATTR_CHL_TYPE          = "type"
	ATTR_CHL_INSTANCE_TYPE = "instance_type"
	ATTR_CHL_SINCE_MSG     = "time_since_msg"

	ATTR_CHL_NETTIME_SHORT = "nettime_short"
	ATTR_CHL_NETTIME_LONG  = "nettime_long"
	ATTR_CHL_BATCHSZ_SHORT = "batchsz_short"
	ATTR_CHL_BATCHSZ_LONG  = "batchsz_long"
	ATTR_CHL_XQTIME_SHORT  = "xmitq_time_short"
	ATTR_CHL_XQTIME_LONG   = "xmitq_time_long"

	ATTR_CHL_MAX_INSTC = "attribute_max_instc"
	ATTR_CHL_MAX_INST  = "attribute_max_inst"

	SQUASH_CHL_STATUS_STOPPED    = 0
	SQUASH_CHL_STATUS_TRANSITION = 1
	SQUASH_CHL_STATUS_RUNNING    = 2

	DUMMY_STRING = "-" // To provide a non-empty value for certain fields
)
View Source
const (
	ATTR_CLUSTER_NAME    = "name"
	ATTR_CLUSTER_QMTYPE  = "qmtype"  // "repos" or "normal" = "full" or "partial"
	ATTR_CLUSTER_STATUS  = "status"  // clussdr status
	ATTR_CLUSTER_SUSPEND = "suspend" // yes/no

)
View Source
const (
	OT_Q             = 1
	OT_NAMELIST      = 2
	OT_PROCESS       = 3
	OT_STORAGE_CLASS = 4
	OT_Q_MGR         = 5
	OT_CHANNEL       = 6
	OT_AUTH_INFO     = 7
	OT_TOPIC         = 8
	OT_COMM_INFO     = 9
	OT_CF_STRUC      = 10
	OT_LISTENER      = 11
	OT_SERVICE       = 12
	OT_APP           = 13
	OT_PUB           = 14
	OT_SUB           = 15
	OT_NHA           = 16
	OT_BP            = 17
	OT_PS            = 18
	OT_CLUSTER       = 19
	OT_LAST_USED     = OT_CLUSTER
)

These object types are the same where possible as the MQI MQOT definitions but there are some unique types here so that correspondence is not completely identical.

View Source
const (
	ATTR_QMGR_NAME                = "name"
	ATTR_QMGR_CONNECTION_COUNT    = "connection_count"
	ATTR_QMGR_CHINIT_STATUS       = "channel_initiator_status"
	ATTR_QMGR_CMD_SERVER_STATUS   = "command_server_status"
	ATTR_QMGR_STATUS              = "status"
	ATTR_QMGR_UPTIME              = "uptime"
	ATTR_QMGR_MAX_CHANNELS        = "max_channels"
	ATTR_QMGR_MAX_ACTIVE_CHANNELS = "max_active_channels"
	ATTR_QMGR_MAX_TCP_CHANNELS    = "max_tcp_channels"
)
View Source
const (
	ATTR_Q_NAME        = "name"
	ATTR_Q_MSGAGE      = "oldest_message_age"
	ATTR_Q_IPPROCS     = "input_handles"
	ATTR_Q_OPPROCS     = "output_handles"
	ATTR_Q_QTIME_SHORT = "qtime_short"
	ATTR_Q_QTIME_LONG  = "qtime_long"
	ATTR_Q_DEPTH       = "depth"
	ATTR_Q_CURFSIZE    = "qfile_current_size"
	ATTR_Q_SINCE_PUT   = "time_since_put"
	ATTR_Q_SINCE_GET   = "time_since_get"
	ATTR_Q_MAX_DEPTH   = "attribute_max_depth"
	ATTR_Q_USAGE       = "attribute_usage"
	ATTR_Q_CURMAXFSIZE = "qfile_max_size"
	// Uncommitted messages - on Distributed platforms, this is any integer;
	// but on z/OS it only indicates 0/1 (MQQSUM_NO/YES)
	ATTR_Q_UNCOM = "uncommitted_messages"

	// The next two attributes are given the same name
	// as the published statistics from the amqsrua-style
	// vaues. That allows a dashboard for Distributed and z/OS
	// to merge the same query.
	ATTR_Q_INTERVAL_PUT = "mqput_mqput1_count"
	ATTR_Q_INTERVAL_GET = "mqget_count"
	// This is the Highest Depth returned over an interval via the
	// RESET QSTATS command. Contrast with the attribute_max_depth
	// value which is the DISPLAY QL(x) MAXDEPTH attribute.
	ATTR_Q_INTERVAL_HI_DEPTH = "hi_depth"
)
View Source
const (
	ATTR_SUB_NAME = "name"
	ATTR_SUB_ID   = "subid"

	ATTR_SUB_TOPIC_STRING  = "topic"
	ATTR_SUB_TYPE          = "type"
	ATTR_SUB_SINCE_PUB_MSG = "time_since_message_published"
	ATTR_SUB_MESSAGES      = "messsages_received"
)
View Source
const (
	ATTR_TOPIC_STRING           = "name"
	ATTR_TOPIC_STATUS_TYPE      = "type"
	ATTR_TOPIC_PUB_MESSAGES     = "messages_published"
	ATTR_TOPIC_SUB_MESSAGES     = "messages_received"
	ATTR_TOPIC_SINCE_PUB_MSG    = "time_since_msg_published"
	ATTR_TOPIC_SINCE_SUB_MSG    = "time_since_msg_received"
	ATTR_TOPIC_PUBLISHER_COUNT  = "publisher_count"
	ATTR_TOPIC_SUBSCRIBER_COUNT = "subscriber_count"
)
View Source
const (
	ATTR_BP_ID           = "id"
	ATTR_BP_LOCATION     = "location"
	ATTR_BP_CLASS        = "pageclass"
	ATTR_BP_FREE         = "buffers_free"
	ATTR_BP_FREE_PERCENT = "buffers_free_percent"
	ATTR_BP_TOTAL        = "buffers_total"

	ATTR_PS_ID           = "id"
	ATTR_PS_BPID         = "bufferpool"
	ATTR_PS_TOTAL        = "pages_total"
	ATTR_PS_UNUSED       = "pages_unused"
	ATTR_PS_NP_PAGES     = "pages_nonpersistent"
	ATTR_PS_P_PAGES      = "pages_persistent"
	ATTR_PS_STATUS       = "status"
	ATTR_PS_EXPAND_COUNT = "expansion_count"
)
View Source
const ClassNameQ = "STATQ"
View Source
const DEFAULT_CONNECTION_KEY = "@defaultConnection"
View Source
const QMgrMapKey = "@self"

QMgrMapKey can never be a real object name and is therefore useful in maps that may contain only this single entry

Variables

View Source
var (
	Metrics            AllMetrics
	QueueManagerStatus StatusSet
	ChannelStatus      StatusSet
	QueueStatus        StatusSet
	TopicStatus        StatusSet
	SubStatus          StatusSet
	UsagePsStatus      StatusSet
	UsageBpStatus      StatusSet
	ClusterStatus      StatusSet
)

This are used externally so we need to maintain them as public exports until there's a major version change. At which point we will move them to fields of the objectStatus structure, retrievable by a getXXX() call instead of as public variables. The mq-metric-samples exporters will then need to change to match.

Functions

func ChannelInitAttributes

func ChannelInitAttributes()

Unlike the statistics produced via a topic, there is no discovery of the attributes available in object STATUS queries. There is also no discovery of descriptions for them. So this function hardcodes the attributes we are going to look for and gives the associated descriptive text. The elements can be expanded later; just trying to give a starting point for now.

func ChannelNormalise

func ChannelNormalise(attr *StatusAttribute, v int64) float64

Return a standardised value. If the attribute indicates that something special has to be done, then do that. Otherwise just make sure it's a non-negative value of the correct datatype

func ClusterInitAttributes added in v5.2.2

func ClusterInitAttributes()

Unlike the statistics produced via a topic, there is no discovery of the attributes available in object STATUS queries. There is also no discovery of descriptions for them. So this function hardcodes the attributes we are going to look for and gives the associated descriptive text. The elements can be expanded later; just trying to give a starting point for now.

func ClusterNormalise added in v5.2.2

func ClusterNormalise(attr *StatusAttribute, v int64) float64

Return a standardised value. If the attribute indicates that something special has to be done, then do that. Otherwise just make sure it's a non-negative value of the correct datatype

func CollectChannelStatus

func CollectChannelStatus(patterns string) error

func CollectClusterStatus added in v5.2.2

func CollectClusterStatus() error

func CollectQueueManagerStatus

func CollectQueueManagerStatus() error

func CollectQueueStatus

func CollectQueueStatus(patterns string) error

func CollectSubStatus

func CollectSubStatus(patterns string) error

func CollectTopicStatus

func CollectTopicStatus(patterns string) error

func CollectUsageStatus

func CollectUsageStatus() error

func DiscoverAndSubscribe

func DiscoverAndSubscribe(dc DiscoverConfig) error

DiscoverAndSubscribe does the work of finding the different resources available from a queue manager and issuing the MQSUB calls to collect the data

func EndConnection

func EndConnection()

EndConnection tidies up by closing the queues and disconnecting.

func FilterRegExp

func FilterRegExp(patterns string, possibleList []string) []string

Patterns are very simple, following normal MQ lines except that they can be prefixed with "!" to exclude them. For example,

"APP*,DEV*,!SYSTEM*"

I decided not to use a full regexp pattern matcher because it's not really natural in the MQ world.

Rules for the pattern matching are:

All positive implies NONE except listed names
All negative implies ALL except listed names
Mixed positive and negative entries is done in two phases:
  Remove the negative patterns
  Filter the remaining set with the positive patterns
Allows patterns like "S*,!SYSTEM*" to still return S.1 but not SYSTEM.DEF.Q

A pattern like "!DEV*,DEV.QUEUE.1" has the negative element given priority over the positive. So DEV.QUEUE.1 does not match here. I could reverse the logic in the mixed model, but I think this is preferable.

func GetCommandLevel

func GetCommandLevel() int32

Return the current command level

func GetConnectionKey added in v5.2.0

func GetConnectionKey() string

func GetDiscoveredQueues

func GetDiscoveredQueues() []string

func GetObjectDescription

func GetObjectDescription(key string, objectType int32) string

func GetPlatform

func GetPlatform() int32

Return the current platform - the MQPL_* definition value. It can be turned into a string if necessary via ibmmq.MQItoString("PL"...)

func GetProcessPublicationCount added in v5.1.0

func GetProcessPublicationCount() int

func InitConnection

func InitConnection(qMgrName string, replyQ string, replyQ2 string, cc *ConnectionConfig) error

InitConnection connects to the queue manager, and then opens both the command queue and a dynamic reply queue to be used for all responses including the publications

func InitConnectionKey added in v5.2.0

func InitConnectionKey(key string, qMgrName string, replyQ string, replyQ2 string, cc *ConnectionConfig) error

func InquireChannels

func InquireChannels(patterns string) ([]string, error)

If we need to list the channels that match a pattern. Not needed for the status queries as they (unlike the pub/sub resource stats) accept patterns in the PCF command

func InquireQueues

func InquireQueues(patterns string) ([]string, error)

If we need to list the queues that match a pattern. Not needed for the status queries as they (unlike the pub/sub resource stats) accept patterns in the PCF command

func InquireTopics

func InquireTopics(patterns string) ([]string, error)

If we need to list the topics that match a pattern. Not needed for the status queries as they (unlike the pub/sub resource stats) accept patterns in the PCF command

func Normalise

func Normalise(elem *MonElement, key string, value int64) float64

Normalise converts the value returned from MQ into the correct units such as converting MB to bytes.

func ProcessPublications

func ProcessPublications() error

ProcessPublications has to read all of the messages since the last scrape and update the values for every relevant gauge.

Because the generation of the messages by the qmgr, and being told to read them by the main loop, may not have identical frequencies, there may be cases where multiple pieces of data have to be collated for the same gauge. Conversely, there may be times when this is called but there are no metrics to update.

func QueueInitAttributes

func QueueInitAttributes()

Unlike the statistics produced via a topic, there is no discovery of the attributes available in object STATUS queries. There is also no discovery of descriptions for them. So this function hardcodes the attributes we are going to look for and gives the associated descriptive text. The elements can be expanded later; just trying to give a starting point for now.

func QueueManagerInitAttributes

func QueueManagerInitAttributes()

Unlike the statistics produced via a topic, there is no discovery of the attributes available in object STATUS queries. There is also no discovery of descriptions for them. So this function hardcodes the attributes we are going to look for and gives the associated descriptive text. The elements can be expanded later; just trying to give a starting point for now.

func QueueManagerNormalise

func QueueManagerNormalise(attr *StatusAttribute, v int64) float64

Return a standardised value. If the attribute indicates that something special has to be done, then do that. Otherwise just make sure it's a non-negative value of the correct datatype

func QueueNormalise

func QueueNormalise(attr *StatusAttribute, v int64) float64

Return a standardised value.

func ReadPatterns

func ReadPatterns(f string) (string, error)

ReadPatterns is called during the initial configuration step to read a file containing object name patterns if they are not explicitly given on the command line.

func RediscoverAndSubscribe

func RediscoverAndSubscribe(dc DiscoverConfig) error

func RediscoverAttributes

func RediscoverAttributes(objectType int32, objectPatterns string) error

func SetConnectionKey added in v5.2.0

func SetConnectionKey(key string)

func SetLocale

func SetLocale(l string)

* A collector can set the locale (eg "Fr_FR") before doing the discovery * process to get access to the MQ-translated strings

func SetLogger

func SetLogger(l *Logger)

func SubInitAttributes

func SubInitAttributes()

Unlike the statistics produced via a topic, there is no discovery of the attributes available in object STATUS queries. There is also no discovery of descriptions for them. So this function hardcodes the attributes we are going to look for and gives the associated descriptive text. The elements can be expanded later; just trying to give a starting point for now.

func SubNormalise

func SubNormalise(attr *StatusAttribute, v int64) float64

Return a standardised value. If the attribute indicates that something special has to be done, then do that. Otherwise just make sure it's a non-negative value of the correct datatype

func TopicInitAttributes

func TopicInitAttributes()

Unlike the statistics produced via a topic, there is no discovery of the attributes available in object STATUS queries. There is also no discovery of descriptions for them. So this function hardcodes the attributes we are going to look for and gives the associated descriptive text. The elements can be expanded later; just trying to give a starting point for now.

func TopicKey

func TopicKey(n string, t string) string

Return a combination of the topic name and the status query type so we get unique keys in the map. There might be valid data for the same topic name in TYPE(SUB) and TYPE(TOPIC).

func TopicNormalise

func TopicNormalise(attr *StatusAttribute, v int64) float64

Return a standardised value. If the attribute indicates that something special has to be done, then do that. Otherwise just make sure it's a non-negative value of the correct datatype

func UsageInitAttributes

func UsageInitAttributes()

func UsageNormalise

func UsageNormalise(attr *StatusAttribute, v int64) float64

Return a standardised value. If the attribute indicates that something special has to be done, then do that. Otherwise just make sure it's a non-negative value of the correct datatype

func VerifyConfig

func VerifyConfig() (int32, error)

* Check any important parameters - this must be called after DiscoverAndSubscribe * to maintain compatibility of the package's APIs. It also needs the list of queues to have been * populated first which is also done in DiscoverAndSubscribe. * Returns: an MQ CompCode, error string. CompCode can be MQCC_OK, WARNING or ERROR.

func VerifyPatterns

func VerifyPatterns(patternList string) error

func VerifyQueuePatterns

func VerifyQueuePatterns(patternList string) error

Types

type AllMetrics

type AllMetrics struct {
	Classes map[int]*MonClass
}

The AllMetrics structure is the top of the tree, holding the set of classes.

func GetPublishedMetrics added in v5.2.0

func GetPublishedMetrics(key string) *AllMetrics

type ConnectionConfig

type ConnectionConfig struct {
	ClientMode    bool
	UserId        string
	Password      string
	TZOffsetSecs  float64
	SingleConnect bool

	UsePublications      bool
	UseStatus            bool
	UseResetQStats       bool
	ShowInactiveChannels bool

	CcdtUrl  string
	ConnName string
	Channel  string
}

type DiscoverConfig

type DiscoverConfig struct {
	MetaPrefix      string // Root of all meta-data discovery
	MonitoredQueues DiscoverObject
}

For now, only queues are subscribable through this interface but there are now Application resources that might be relevant at some time.

type DiscoverObject

type DiscoverObject struct {
	ObjectNames          string
	UseWildcard          bool
	SubscriptionSelector string
}

type Logger

type Logger struct {
	Trace func(string, ...interface{})
	Debug func(string, ...interface{})
	Info  func(string, ...interface{})
	Warn  func(string, ...interface{})
	Error func(string, ...interface{})
	Fatal func(string, ...interface{})
	Panic func(string, ...interface{})
}

Setup for the 7 levels of logging that logrus allows, even if we don't intend to use all of them for now.

type MQMetricError

type MQMetricError struct {
	Err      string
	MQReturn *ibmmq.MQReturn
}

func (MQMetricError) Error

func (e MQMetricError) Error() string

func (MQMetricError) Unwrap

func (e MQMetricError) Unwrap() error

type MonClass

type MonClass struct {
	Parent      *AllMetrics
	Name        string
	Description string

	Types map[int]*MonType
	// contains filtered or unexported fields
}

MonClass described the "classes" of data generated by MQ, such as DISK and CPU

type MonElement

type MonElement struct {
	Parent         *MonType
	Description    string // An English phrase describing the element
	DescriptionNLS string // A translated phrase for the current locale
	MetricName     string // Reformatted description suitable as label
	Datatype       int32
	Values         map[string]int64
}

MonElement describes the real metric element generated by MQ

type MonType

type MonType struct {
	Parent      *MonClass
	Name        string
	Description string
	ObjectTopic string // topic for actual data responses

	Elements map[int]*MonElement
	// contains filtered or unexported fields
}

MonType describes the "types" of data generated by MQ. Each class generates one or more type of data such as OPENCLOSE (from STATMQI class) or LOG (from DISK class)

type ObjInfo

type ObjInfo struct {
	Description string
	// These are used for queue information
	AttrMaxDepth int64 // The queue attribute value. Not the max depth reported by RESET QSTATS
	AttrUsage    int64 // Normal or XMITQ
	// Some channel information
	AttrMaxInst  int64
	AttrMaxInstC int64
	AttrChlType  int64
	// contains filtered or unexported fields
}

This structure contains additional info about any object type that may need to be held. The first fields are used for all object types. Following fields will apply to different object types.

type StatusAttribute

type StatusAttribute struct {
	Description string
	MetricName  string
	Pseudo      bool

	Values map[string]*StatusValue
	// contains filtered or unexported fields
}

type StatusSet

type StatusSet struct {
	Attributes map[string]*StatusAttribute
}

func GetObjectStatus added in v5.2.0

func GetObjectStatus(key string, objectType int) *StatusSet

This will be the preferred interface in future to get at the values, at which point it will change to not use the global public variables

type StatusValue

type StatusValue struct {
	IsInt64     bool
	ValueInt64  int64
	ValueString string
}

All we care about for attributes are ints and strings. Other complex PCF datatypes are not currently going to be returned through this mechanism

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL