I recently wanted to monitor my home NAS with prometheus, which essentially means running node_exporter on it.
The NAS is running FreeNAS, which is, at time of writing, based on FreeBSD 10.3-STABLE, so I need to somehow get hold of node_exporter for FreeBSD.
Rather than installing
go and building node_exporter directly on the FreeNAS machine, I will build it on a Vagrant machine (running FreeBSD 10.3-STABLE) then copy it to the NAS. I will do this by creating a FreeBSD package which can be installed on the FreeNAS machine.
One final complication: I want to use an unreleased version of node_exporter that contains the fix for a bug I reported recently. So, I will need to build against an aribtrary github commit hash.
First, I created a simple Vagrant file as follows:
Vagrant.configure("2") do |config|
config.vm.guest = :freebsd
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
config.vm.box = "freebsd/FreeBSD-10.3-STABLE"
config.ssh.shell = "sh"
config.vm.base_mac = "080027D14C66"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
vb.customize ["modifyvm", :id, "--audio", "none"]
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
vagrant up and
vagrant ssh to start the machine and jump onto it.
I then ran the following commands to initialize the FreeBSD ports:
The port I want is in
/usr/ports/sysutils/node_exporter, so normally I would simply change into that directory and build the package:
This will create a
.txz file which is a FreeBSD pkg and can be installed on FreeNAS.
However, to build node_exporter from a specific github commit hash I need to make a couple of changes to the
First, I identify the short hash of the commit I want to build –
269ee7a, in this instance.
Then I modify the
GH_TAGNAME and modifying
PORTVERSION, something like this:
Finally, I generate
distinfo to match the modified version, and build the package:
I now copy
node_exporter-0.13.0.269ee7a.txz to my FreeNAS box, where I can install and run it.
On the FreeNAS box, I use the following commands to install, enable, and start the node_exporter service:
pkg add ./node_exporter-0.13.0.269ee7a.txz
cat <<EOT >> /etc/rc.conf
# enable prometheus node_exporter
service node_exporter start
I can now configure prometheus to scrape metrics from this machine.