Percona Monitoring and Management (PMM) is an invaluable tool for performance troubleshooting, but it’s availability has a major shortcoming – binaries are only available for amd64, and the source packages don’t include actual sources but precompiled binaries that only get repackaged into a rpm package when rebuilt, which means they won’t work on anything other than an amd64 system.

Source code is available, but the build process is poorly documented which makes it near impossible for somebody unfamiliar with it to successfully complete. Having managed to make it work and produced real source packages that result in building pmm-client from source, I will share here the detailed build process and the packages. With this, you will be able to run pmm-client on your Raspberry Pi, or any other reasonably recent Linux system.

For the most part, the process is reasonably straightforward. Download the sources from here. Extract it, and you will find tarballs for the individual components:


$ tar -ztvf pmm-client-1.17.4.tar.gz
drwxrwxr-x ec2-user/docker 0 2020-07-08 14:04 pmm-client-1.17.4/
-rw-rw-r-- ec2-user/docker 1816536 2020-07-08 14:03 pmm-client-1.17.4/pmm-client-38b8313.tar.gz
-rw-rw-r-- ec2-user/docker 1145679 2020-07-08 14:03 pmm-client-1.17.4/postgres_exporter-3017fce.tar.gz
-rw-rw-r-- ec2-user/docker 2361627 2020-07-08 14:03 pmm-client-1.17.4/proxysql_exporter-bbd1471.tar.gz
-rw-rw-r-- ec2-user/docker 2405889 2020-07-08 14:03 pmm-client-1.17.4/qan-agent-9399e1f.tar.gz
-rw-rw-r-- ec2-user/docker 1327002 2020-07-08 14:03 pmm-client-1.17.4/mysqld_exporter-491e5e4.tar.gz
-rw-rw-r-- ec2-user/docker 76448822 2020-07-08 14:04 pmm-client-1.17.4/percona-toolkit-a4db86e0.tar.gz
-rw-rw-r-- ec2-user/docker 1296480 2020-07-08 14:03 pmm-client-1.17.4/mongodb_exporter-9fd6f88.tar.gz
-rw-rw-r-- ec2-user/docker 1470353 2020-07-08 14:03 pmm-client-1.17.4/node_exporter-fe47433.tar.gz
-rw-rw-r-- ec2-user/docker 8106798 2020-07-08 14:03 pmm-client-1.17.4/pid-watchdog-2a86cf7.tar.gz

Create the GOPATH, set the environment variable, and extract the individual tarballs:


export GOPATH=~/go
mkdir -p $GOPATH/src/github.com/percona
mkdir -p $GOPATH/src/github.com/prometheus


tar -C $GOPATH/src/github.com/percona -zxf mongodb_exporter-9fd6f88.tar.gz
tar -C $GOPATH/src/github.com/percona -zxf mysqld_exporter-491e5e4.tar.gz
tar -C $GOPATH/src/github.com/percona -zxf node_exporter-fe47433.tar.gz
tar -C $GOPATH/src/github.com/percona -zxf percona-toolkit-a4db86e0.tar.gz
tar -C $GOPATH/src/github.com/percona -zxf pid-watchdog-2a86cf7.tar.gz
tar -C $GOPATH/src/github.com/percona -zxf pmm-client-38b8313.tar.gz
tar -C $GOPATH/src/github.com/percona -zxf postgres_exporter-3017fce.tar.gz
tar -C $GOPATH/src/github.com/percona -zxf proxysql_exporter-bbd1471.tar.gz
tar -C $GOPATH/src/github.com/percona -zxf qan-agent-9399e1f.tar.gz

Remove the git commit tags from the directory names:


pushd $GOPATH/src/github.com/percona
mv mongodb_exporter-9fd6f88 mongodb_exporter
mv postgres_exporter-3017fce postgres_exporter
mv proxysql_exporter-bbd1471 proxysql_exporter
mv node_exporter-fe47433 node_exporter
mv pmm-client-38b8313 pmm-client
mv mysqld_exporter-491e5e4 mysqld_exporter
mv percona-toolkit-a4db86e0 percona-toolkit
mv pid-watchdog-2a86cf7 pid-watchdog
mv qan-agent-9399e1f qan-agent

This next part is super-critical, and is what had me chasing my tail for quite a while. PMM’s modified node_exporter has a dependency on prometheus/node_exporter, but it will not work properly if built against any upstream version of Prometheus node_exporter! It is intended to be built against itself masquerading as prometheus/node_exporter. I have pointed out that this seems like a bug. The following is necessary until that bug is fixed:


cd $GOPATH/src/github.com/prometheus
ln -s ../percona/node_exporter node_exporter
popd

The rest of the process is reasonably straightforward, at least if you are familiar with building go binaries:


pushd $GOPATH/src/github.com/percona/node_exporter
make build
mv node_exporter $GOPATH/bin
cd $GOPATH/src/github.com/percona/postgres_exporter
make build
mv postgres_exporter $GOPATH/bin
cd $GOPATH/src/github.com/percona/percona-toolkit
perl Makefile.PL
make
go get -u github.com/golang/dep/cmd/dep
../../../../bin/dep ensure -v
go build ./src/go/pt-mongodb-summary
cp pt-mongodb-summary $GOPATH/bin
cp bin/pt-mysql-summary $GOPATH/bin
cp bin/pt-summary $GOPATH/bin
popd


go install github.com/percona/mongodb_exporter
go install github.com/percona/proxysql_exporter
go install github.com/percona/pmm-client
go install github.com/percona/mysqld_exporter
go install github.com/percona/pid-watchdog
go install github.com/percona/qan-agent/bin/…

You should now have all of the binaries in $GOPATH/bin

To make your life easier, I have put together a pmm-client source rpm package, which you can download and build in the usual way, using rpmbuild or mock.

You can now easily use pmm-client to monitor your Raspberry Pi, or in fact any ARM (and non-ARM) Linux device with a reasonably recent version of golang (I seem to recall 1.10 or newer is required).

This article has been brought to you by the database specialists at Shattered Silicon.