Skip to content

Commit 86148ed

Browse files
committed
Update for V9.1.2
Add Docker build scripts
1 parent eb77243 commit 86148ed

File tree

321 files changed

+37853
-6113
lines changed

Some content is hidden

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

321 files changed

+37853
-6113
lines changed

CHANGELOG.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# Changelog
2-
## November 2018
2+
Newest updates are at the top of this file.
33

4-
* Added "platform" as a tag/label in Prometheus and JSON exporters
4+
## February 2019
5+
* Update to use v4.0.1 of the mq-golang repository
6+
* Update READMEs for all the monitor agent programs
7+
* Add a Dockerfile and scripts to build the agent binaries in a container
58

69
## November 2018
10+
* Added "platform" as a tag/label in Prometheus and JSON exporters
711

12+
## November 2018
813
* Updated the JSON monitor sample to support channel status reporting
914
* Updated Prometheus and JSON monitors to deal with DISPLAY QSTATUS commands
1015
* Updated to permit access to z/OS status data.
1116

1217
## October 2018
13-
1418
* Updated the Prometheus monitor program to support channel status reporting
1519
* Updated the README for Prometheus for newer build instructions
1620
* Updated dependencies
1721

18-
1922
## July 2018
20-
2123
* Updated repo to use 2.0.0 version of mq-golang repo
2224

2325
## July 2018
24-
2526
* Added templates for PR and Issues
2627

2728
## May 2018
28-
2929
* Initial commit
3030
* Added Golang dependency management using [dep](https://golang.github.io/dep/)

Dockerfile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# © Copyright IBM Corporation 2019
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG BASE_IMAGE=ubuntu:18.10
16+
FROM $BASE_IMAGE
17+
18+
ARG GOPATH_ARG="/go"
19+
20+
ENV GOVERSION=1.10 \
21+
GOPATH=$GOPATH_ARG \
22+
ORG="github.com/ibm-messaging" \
23+
REPO="mq-metric-samples"
24+
25+
# Location of the downloadable MQ client package \
26+
ENV RDURL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist" \
27+
RDTAR="IBM-MQC-Redist-LinuxX64.tar.gz" \
28+
VRMF=9.1.2.0
29+
30+
# Install the Go compiler and Git
31+
RUN export DEBIAN_FRONTEND=noninteractive \
32+
&& bash -c 'source /etc/os-release; \
33+
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME} main restricted" > /etc/apt/sources.list; \
34+
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME}-updates main restricted" >> /etc/apt/sources.list; \
35+
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME}-backports main restricted universe" >> /etc/apt/sources.list; \
36+
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME} universe" >> /etc/apt/sources.list; \
37+
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_CODENAME}-updates universe" >> /etc/apt/sources.list;' \
38+
&& apt-get update \
39+
&& apt-get install -y --no-install-recommends \
40+
golang-${GOVERSION} \
41+
git \
42+
ca-certificates \
43+
curl \
44+
tar \
45+
bash \
46+
go-dep \
47+
build-essential \
48+
&& rm -rf /var/lib/apt/lists/*
49+
50+
# Create location for the git clone and MQ installation
51+
RUN mkdir -p $GOPATH/src $GOPATH/bin $GOPATH/pkg \
52+
&& chmod -R 777 $GOPATH \
53+
&& mkdir -p $GOPATH/src/$ORG \
54+
&& mkdir -p /opt/mqm \
55+
&& chmod a+rx /opt/mqm
56+
57+
# Install the MQ client from the Redistributable package. This also contains the
58+
# header files we need to compile against.
59+
RUN cd /opt/mqm \
60+
&& curl -LO "$RDURL/$VRMF-$RDTAR" \
61+
&& tar -zxf ./*.tar.gz \
62+
&& rm -f ./*.tar.gz
63+
64+
# Insert the script that will do the build
65+
COPY buildMonitors.sh $GOPATH
66+
RUN chmod 777 $GOPATH/buildMonitors.sh
67+
68+
# Copy the rest of the source tree from this directory into the container
69+
COPY . $GOPATH/src/$ORG/$REPO
70+
71+
# Set the entrypoint to the script that will do the compilation
72+
ENTRYPOINT $GOPATH/buildMonitors.sh

Gopkg.lock

Lines changed: 22 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[constraint]]
22
name = "github.com/ibm-messaging/mq-golang"
3-
version = "3.3.3"
3+
version = "4.0.1"
44

55
[prune]
66
go-tests = true

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ to provide a program that can be used with existing monitoring technologies
66
such as Prometheus, AWS CloudWatch, etc.
77

88
These samples were moved to this repository from
9-
the [IBM® MQ golang metric packages repository](https://github.com/ibm-messaging/mq-golang).
9+
the [IBM MQ golang metric packages repository](https://github.com/ibm-messaging/mq-golang).
1010

1111
## Health Warning
1212

@@ -15,7 +15,8 @@ There are also no guarantees of compatibility with any future versions of the pa
1515
interfaces and functions are subject to change based on any feedback.
1616

1717
These samples use a specific version of the `mqmetric` and `ibmmq` golang packages.
18-
Those packages are in the [mq-golang repository](https://github.com/ibm-messaging/mq-golang).
18+
Those packages are in the [mq-golang repository](https://github.com/ibm-messaging/mq-golang)
19+
and are also included in the `vendor` tree of this repository.
1920

2021
## Getting started
2122

@@ -25,7 +26,8 @@ You will require the following programs:
2526

2627
* [dep](https://golang.github.io/dep/) - Golang dependency management tool
2728

28-
If using a version of Go from after 2017, you must set environment variables to permit some compile/link flags. This is due to a security fix in the compiler.
29+
If using a version of Go from after 2017, you must set environment variables to permit some compile/link flags.
30+
This is due to a security fix in the compiler.
2931

3032
```
3133
export CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"
@@ -41,22 +43,22 @@ git clone https://github.com/ibm-messaging/mq-metric-samples.git src/github.com/
4143
```
4244

4345
* Navigate to the mq-metric-samples root directory (`$GOPATH/src/github.com/ibm-messaging/mq-metric-samples`)
44-
* Run dep to ensure that you have the correct dependencies downloaded:
46+
* Run `dep` to ensure that you have the correct dependencies downloaded:
4547

4648
```
4749
dep ensure
4850
```
4951

50-
* Compile the sample program you wish to use. For example to build the mq_prometheus sample:
51-
52-
```
53-
go install cmd/mq_prometheus
54-
```
52+
* Compile the sample program you wish to use. See the README in each directory for more information.
5553

5654
At this point, you should have a compiled copy of the code in `$GOPATH/bin`. Each
5755
monitor agent directory also has sample scripts, configuration files etc to help
5856
with getting the agent running in your specific environment.
5957

58+
## Using a Docker container to build the programs
59+
You can use the `buildMain.sh` script in this directory to build a Docker container that
60+
in turn will build the binary programs and copy them to a local directory.
61+
6062
## More information
6163
Each of the sample monitor programs has its own README file describing the
6264
capabilities in more detail. In general, the Prometheus monitor program is
@@ -68,12 +70,12 @@ See [CHANGELOG](CHANGELOG.md) in this directory.
6870

6971
## Issues and Contributions
7072

71-
For feedback and issues relating specifically to this package, please use the [GitHub issue tracker](https://github.com/ibm-messaging/mq-golang/issues).
73+
For feedback and issues relating specifically to this package, please use the [GitHub issue tracker](https://github.com/ibm-messaging/mq-metric-samples/issues).
7274

7375
Contributions to this package can be accepted under the terms of the IBM Contributor License
7476
Agreement, found in the [CLA file](CLA.md) of this repository. When submitting a pull request, you
7577
must include a statement stating you accept the terms in the CLA.
7678

7779
## Copyright
7880

79-
© Copyright IBM Corporation 2016, 2018
81+
© Copyright IBM Corporation 2016, 2019

buildMain.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# © Copyright IBM Corporation 2019
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This simple script builds a Docker container whose purpose is simply
16+
# to compile the binary components of the monitoring programs, and then to copy those
17+
# programs to a local temporary directory.
18+
GOPATH="/go"
19+
20+
TAG="mq-metric-samples-gobuild"
21+
# Assume repo tags have been created in a sensible order
22+
VER=`git tag -l | sort | tail -1 | sed "s/^v//g"`
23+
if [ -z "$VER" ]
24+
then
25+
VER="latest"
26+
fi
27+
echo "Building container $TAG:$VER"
28+
29+
# Build a container that has all the pieces needed to compile the Go programs for MQ
30+
docker build --build-arg GOPATH_ARG=$GOPATH -t $TAG:$VER .
31+
rc=$?
32+
33+
if [ $rc -eq 0 ]
34+
then
35+
# Run the image to do the compilation and extract the files
36+
# from it into a local directory mounted into the container.
37+
OUTDIR=$HOME/tmp/mq-metric-samples/bin
38+
rm -rf $OUTDIR
39+
mkdir -p $OUTDIR
40+
41+
# Get some variables to pass the build information into the compile steps
42+
buildStamp=`date +%Y%m%d-%H%M%S`
43+
gitCommit=`git rev-list -1 HEAD --abbrev-commit`
44+
45+
# Set this for any special status
46+
extraInfo=""
47+
48+
# Add "-e MONITORS=..." to only compile a subset of the monitor programs
49+
# Mount an output directory
50+
# Delete the container once it's done its job
51+
docker run --rm \
52+
-v $OUTDIR:$GOPATH/bin:z \
53+
-e BUILD_EXTRA_INJECT="-X \"main.BuildStamp=$buildStamp $extraInfo\" -X \"main.GitCommit=$gitCommit\"" \
54+
$TAG:$VER
55+
echo "Compiled programs should now be in $OUTDIR"
56+
fi

0 commit comments

Comments
 (0)