I really like that go can produce static executables which do not require any dynamic libraries; this is especially useful for sysadmin tools.
Metrix is one such tool — it is a single executable which is able to gather a variety of metrics and send them to different aggregators (by default it is sent to STDOUT):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
pi@raspberrypi ~ $ bin/metrix --help USAGE: bin/metrix --cpu Collect cpu metrics --df Collect disk free space metrics --disk Collect disk usage metrics --elasticsearch Collect ElasticSearch metrics DEFAULT: http://127.0.0.1:9200/_status --files Collect open files --free Collect free metrics --loadavg Collect loadvg metrics --help Print this usage page --keys Only list all known keys --opentsdb Report metrics to OpenTSDB host. EXAMPLE: opentsdb.host:4242 --amqp Report metrics to AMQP host. EXAMPLE: amqp.host:5672 --graphite Report metrics to Graphite host. EXAMPLE: graphite.host:2003 --hostname Hostname to be used for tagging. If blank the local hostname is used --memory Collect memory metrics --net Collect network metrics --nginx Collect nginx metrics DEFAULT: http://127.0.0.1:8080 --pgbouncer Collect pgbouncer metrics DEFAULT: 127.0.0.1:6432 --postgres Collect postgres metrics. EXAMPLE: psql://user:pwd@host/db --processes Collect metrics for processes --redis Collect redis metrics DEFAULT: 127.0.0.1:6379 --riak Collect riak metrics DEFAULT: http://127.0.0.1:8098/stats |
I compiled the binary using hypriot’s rpi-golang container; and followed the directions in Metrix’ Github repo, adding in commands as needed. I will likely create a container to automate these steps. One quirk, if anyone wishes to try building — I used the last “release” version of metrix; there were issues doing a git clone
and trying to build.
This has been tested on both HypriotOS and Raspbian, on a Pi B+ and Pi 2B.
If you try to run this within a Docker container your results will be mixed at best due to Docker’s isolation.
To use, download from the link below and place on a Pi, then do the following:
1 2 3 |
bzip2 -d metrix.bz2 chmod +x metrix |
Download: metrix.bz2