Skip to content

Commit bb39631

Browse files
committed
Update for MQ 9.3.3
1 parent 49942d5 commit bb39631

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+355
-610
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
Newest updates are at the top of this file.
33

4+
### Jun 20 2023 (v5.5.0)
5+
* Update to MQ 9.3.3
6+
* Update Dockerfile to support platforms without Redist client (#209)
7+
* Update all vendored dependencies
8+
49
### Feb 17 2023 (v5.4.0)
510
* Update to MQ 9.3.2
611
* Add hostname tag for qmgrs running 9.3.2

Dockerfile

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# syntax=docker/dockerfile:1
22

3+
# This Dockerfile shows how you can both build and run a container with
4+
# a specific exporter/collector program. It uses two stages, copying the relevant
5+
# material from the build step into the runtime container.
6+
#
7+
# It can cope with both platforms where a Redistributable Client is available, and platforms
8+
# where it is not - copy the .deb install images for such platforms into the MQDEB
9+
# subdirectory of this repository first.
10+
311
# Global ARG. To be used in all stages.
12+
# Override with "--build-arg EXPORTER=mq_xxxxx" when building.
413
ARG EXPORTER=mq_prometheus
514

615
# --- --- --- --- --- --- --- --- --- --- --- --- --- --- #
@@ -9,15 +18,10 @@ ARG EXPORTER=mq_prometheus
918
FROM golang:1.19 AS builder
1019

1120
ARG EXPORTER
12-
ARG GOARCH=amd64
13-
ARG MQARCH=X64
14-
1521
ENV EXPORTER=${EXPORTER} \
1622
ORG="github.com/ibm-messaging" \
1723
REPO="mq-metric-samples" \
18-
RDURL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist" \
19-
RDTAR="IBM-MQC-Redist-Linux${MQARCH}.tar.gz" \
20-
VRMF=9.3.2.0 \
24+
VRMF=9.3.3.0 \
2125
CGO_CFLAGS="-I/opt/mqm/inc/" \
2226
CGO_LDFLAGS_ALLOW="-Wl,-rpath.*" \
2327
genmqpkg_incnls=1 \
@@ -35,40 +39,62 @@ RUN mkdir -p /go/src /go/bin /go/pkg \
3539
&& chmod -R 777 /go \
3640
&& mkdir -p /go/src/$ORG \
3741
&& mkdir -p /opt/mqm \
42+
&& mkdir -p /MQDEB \
3843
&& chmod a+rx /opt/mqm
3944

40-
# Install MQ client
41-
WORKDIR /opt/mqm
42-
RUN curl -LO "$RDURL/$VRMF-$RDTAR" \
43-
&& tar -zxf ./*.tar.gz \
44-
&& rm -f ./*.tar.gz \
45-
&& bin/genmqpkg.sh -b /opt/mqm
45+
# Install MQ client and SDK
46+
# For platforms with a Redistributable client, we can use curl to pull it in and unpack it.
47+
# For other platforms, we assume that you have the deb files available under the current directory
48+
# and we then copy them into the container image. Use dpkg to install from them; these have to be
49+
# done in the right order.
50+
#
51+
# If additional Redistributable Client platforms appear, then this block can be altered, including the MQARCH setting.
52+
#
53+
# The copy of the README is so that at least one file always gets copied, even if you don't have the deb files locally.
54+
# Using a wildcard in the directory name also helps to ensure that this part of the build should always succeed.
55+
COPY README.md MQDEB*/*deb /MQDEB
56+
57+
# This is a value always set by the "docker build" process
58+
ARG TARGETPLATFORM
59+
RUN echo "Target arch is $TARGETPLATFORM"
60+
# Might need to refer to TARGETPLATFORM a few times in this block, so define something shorter.
61+
RUN T="$TARGETPLATFORM"; \
62+
if [ "$T" = "linux/amd64" ]; \
63+
then \
64+
MQARCH=X64;\
65+
RDURL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist";\
66+
RDTAR="IBM-MQC-Redist-Linux${MQARCH}.tar.gz"; \
67+
cd /opt/mqm \
68+
&& curl -LO "$RDURL/$VRMF-$RDTAR" \
69+
&& tar -zxf ./*.tar.gz \
70+
&& rm -f ./*.tar.gz \
71+
&& bin/genmqpkg.sh -b /opt/mqm;\
72+
elif [ "$T" = "linux/ppc64le" -o "$T" = "linux/s390x" ];\
73+
then \
74+
cd /MQDEB; \
75+
c=`ls ibmmq-*$VRMF*.deb| wc -l`; if [ $c -lt 4 ]; then echo "MQ installation files do not exist in MQDEB subdirectory";exit 1;fi; \
76+
for f in ibmmq-runtime_$VRMF*.deb ibmmq-gskit_$VRMF*.deb ibmmq-client_$VRMF*.deb ibmmq-sdk_$VRMF*.deb; do dpkg -i $f;done; \
77+
else \
78+
echo "Unsupported platform $T";\
79+
exit 1;\
80+
fi
4681

4782
# Build Go application
4883
WORKDIR /go/src/$ORG/$REPO
4984
COPY go.mod .
5085
COPY go.sum .
5186
COPY --chmod=777 ./cmd/${EXPORTER} .
52-
COPY vendor ./vendor
53-
COPY pkg ./pkg
87+
COPY --chmod=777 vendor ./vendor
88+
COPY --chmod=777 pkg ./pkg
5489
RUN go build -mod=vendor -o /go/bin/${EXPORTER} ./*.go
5590

5691
# --- --- --- --- --- --- --- --- --- --- --- --- --- --- #
5792
### ### ### ### ### ### ### RUN ### ### ### ### ### ### ###
5893
# --- --- --- --- --- --- --- --- --- --- --- --- --- --- #
59-
FROM golang:1.19
94+
FROM golang:1.19 AS runtime
6095

6196
ARG EXPORTER
62-
ARG GOARCH=amd64
63-
ARG MQARCH=X64
64-
6597
ENV EXPORTER=${EXPORTER} \
66-
RDURL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist" \
67-
RDTAR="IBM-MQC-Redist-Linux${MQARCH}.tar.gz" \
68-
VRMF=9.3.2.0 \
69-
genmqpkg_incnls=1 \
70-
genmqpkg_incsdk=1 \
71-
genmqpkg_inctls=1 \
7298
LD_LIBRARY_PATH="/opt/mqm/lib64:/usr/lib64" \
7399
MQ_CONNECT_TYPE=CLIENT \
74100
IBMMQ_GLOBAL_CONFIGURATIONFILE=/opt/config/${EXPORTER}.yaml

Dockerfile.build

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# © Copyright IBM Corporation 2019
1+
# © Copyright IBM Corporation 2019, 2023
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,15 +12,17 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
ARG BASE_IMAGE=ubuntu:18.04
15+
ARG BASE_IMAGE=ubuntu:20.04
1616
FROM $BASE_IMAGE
1717

1818
ARG GOPATH_ARG="/go"
1919
ARG GOVERSION=1.17
20+
ARG GOARCH=amd64
21+
ARG MQARCH=X64
2022

2123
ENV GOVERSION=${GOVERSION} \
2224
GOPATH=$GOPATH_ARG \
23-
GOTAR=go${GOVERSION}.linux-amd64.tar.gz \
25+
GOTAR=go${GOVERSION}.linux-${GOARCH}.tar.gz \
2426
ORG="github.com/ibm-messaging"
2527

2628

@@ -58,8 +60,8 @@ RUN mkdir -p $GOPATH/src $GOPATH/bin $GOPATH/pkg \
5860

5961
# Location of the downloadable MQ client package \
6062
ENV RDURL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist" \
61-
RDTAR="IBM-MQC-Redist-LinuxX64.tar.gz" \
62-
VRMF=9.3.2.0
63+
RDTAR="IBM-MQC-Redist-Linux${MQARCH}.tar.gz" \
64+
VRMF=9.3.3.0
6365

6466
# Install the MQ client from the Redistributable package. This also contains the
6567
# header files we need to compile against. Setup the subset of the package

Dockerfile.run

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# © Copyright IBM Corporation 2020
1+
# © Copyright IBM Corporation 2020,2023
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,9 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
ARG BASE_IMAGE=ubuntu:18.04
15+
ARG BASE_IMAGE=ubuntu:20.04
1616
FROM $BASE_IMAGE
1717

18+
ARG GOARCH=amd64
19+
ARG MQARCH=X64
20+
1821
# Create location for the git clone and MQ installation
1922
RUN mkdir -p /opt/bin \
2023
&& chmod -R 777 /opt/bin \
@@ -30,8 +33,8 @@ RUN apt-get update \
3033

3134
# Location of the downloadable MQ client package \
3235
ENV RDURL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist" \
33-
RDTAR="IBM-MQC-Redist-LinuxX64.tar.gz" \
34-
VRMF=9.3.2.0
36+
RDTAR="IBM-MQC-Redist-Linux${MQARCH}.tar.gz" \
37+
VRMF=9.3.3.0
3538

3639
# Install the MQ client from the Redistributable package. This also contains the
3740
# header files we need to compile against. Setup the subset of the package

MQDEB/README

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
If you are using the Dockerfile in the root of this repository
2+
to build and run an exporter/collector program:
3+
4+
For Linux platforms without a Redistributable Client package, copy
5+
the .deb installation files into this directory.

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You will require the following programs:
3636

3737

3838
### MQ Client SDK
39-
The MQ Client SDK for C programs is required in order to compile and run Go programs. You may have this from an MQ Client installation image (eg rpm, dep formats for Linux, msi for Windows).
39+
The MQ Client SDK for C programs is required in order to compile and run Go programs. You may have this from an MQ Client installation image (eg rpm, deb formats for Linux, msi for Windows).
4040

4141
For Linux x64 and Windows systems, you may also choose to use the
4242
MQ Redistributable Client package which is a simple zip/tar file that does not need
@@ -84,9 +84,17 @@ containers. You still need to provide the configuration file at runtime, perhaps
8484

8585
```
8686
docker build -t mqprom:1.0 .
87-
docker run -v <directory>/mq_prometheus.yaml:/opt/config/mq_prometheus.yaml mqprom:1.0
87+
docker run -p 9157:9157 -v <directory>/mq_prometheus.yaml:/opt/config/mq_prometheus.yaml mqprom:1.0
8888
```
8989

90+
### Platform support
91+
This Dockerfile should work for a variety of platforms. For those with a Redistributable client, it uses
92+
`curl` to automatically download and unpack the required MQ files. For other platforms, it assumes that
93+
you have an `MQDEB` subdirectory under this root, and then copied the `.deb` files from your
94+
real MQ installation tree into it.
95+
96+
### Additional container scripts
97+
9098
As a more flexible example, you can use the `buildMonitors.sh` script in the `scripts` subdirectory to
9199
build a Docker container that in turn will build all the binary programs and copy them to a local directory.
92100
That script also sets some extra version-related flags that will be shown when the program starts. The container will

cmd/mq_aws/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# MQ Exporter for Amazon CloudWatch monitoring
22

3+
This README should be read in conjunction with the repository-wide
4+
[README](https://github.com/ibm-messaging/mq-metric-samples/blob/master/README.md)
5+
that covers features common to all of the collectors in this repository.
6+
37
This directory contains the code for a monitoring solution
48
that exports queue manager data to a CloudWatch data collection
59
system. It also contains configuration files to run the monitor program

cmd/mq_aws/exporter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import (
3636
"github.com/ibm-messaging/mq-golang/v5/ibmmq"
3737
"github.com/ibm-messaging/mq-golang/v5/mqmetric"
3838

39+
errors "github.com/ibm-messaging/mq-metric-samples/v5/pkg/errors"
40+
3941
log "github.com/sirupsen/logrus"
4042
)
4143

@@ -192,9 +194,7 @@ func Collect() error {
192194
err = pollError
193195
}
194196

195-
if err != nil {
196-
log.Fatalf("Error collecting status: %v", err)
197-
}
197+
errors.HandleStatus(err)
198198

199199
thisDiscovery := time.Now()
200200
elapsed = thisDiscovery.Sub(lastQueueDiscovery)

cmd/mq_coll/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# MQ Exporter for Collectd monitoring
22

3+
This README should be read in conjunction with the repository-wide
4+
[README](https://github.com/ibm-messaging/mq-metric-samples/blob/master/README.md)
5+
that covers features common to all of the collectors in this repository.
6+
37
This directory contains the code for a monitoring solution
48
that sends queue manager data to the collectd system.
59
It also contains configuration files to run the monitor program

cmd/mq_coll/exporter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import (
3434
"time"
3535

3636
"github.com/ibm-messaging/mq-golang/v5/mqmetric"
37+
errors "github.com/ibm-messaging/mq-metric-samples/v5/pkg/errors"
38+
3739
log "github.com/sirupsen/logrus"
3840
)
3941

@@ -156,9 +158,7 @@ func Collect() error {
156158
err = pollError
157159
}
158160

159-
if err != nil {
160-
log.Fatalf("Error collecting status: %v", err)
161-
}
161+
errors.HandleStatus(err)
162162

163163
thisDiscovery := time.Now()
164164
elapsed = thisDiscovery.Sub(lastQueueDiscovery)

0 commit comments

Comments
 (0)