Install Nagios NRPE on FreeNAS
Read through the preamble to see what I tried first and why it didn’t work. Or jump ahead to the working install method.
I’ve been using FreeNAS for a couple of months now, starting with version 9 and later upgrading to version 11. While the experience so far has been great there are a few glaring omissions. First and foremost “monitoring”. There is just no convenient way to monitor the system externally.
Like many others, I use Nagios to monitor my systems, it is a fairly well known, mature and feature rich monitoring solution. Nagios is a straight forward client/server model. The Nagios server schedules checks, connects to the client server running NRPE. NRPE runs the scheduled check and responds with the result. Nagios also has a wide assortment of plugins available which can be downloaded as needed to monitor just about anything. It is a pretty good solution, except…
FreeNAS has NO, NONE, NADDA, ZILCH, ZERO means to install the NRPE client. Go ahead, search google, I’ll wait. Maybe try their forums or even the r/freenas subreddit. No luck eh? I know the frustration.
Maybe we missed something obvious? Lets check FreeNAS for an available plugin.
Nope, nothing about Nagios or NRPE there. FreeNAS is based on FreeBSD, so perhaps we can install using pkg instead.
root@freenas:~ # pkg search nrpe
pkg: Repository local missing. 'pkg update' required
pkg: file:///usr/ports/packages/meta.txz: No such file or directory
pkg: file:///usr/ports/packages/packagesite.txz: No such file or directory
pkg: Repository local cannot be opened. 'pkg update' required
Hrm, okay, that didn’t work. But lets try the pkg update command as suggested.
root@freenas:~ # pkg update
Updating local repository catalogue...
pkg: file:///usr/ports/packages/meta.txz: No such file or directory
repository local has no meta file, using default settings
pkg: file:///usr/ports/packages/packagesite.txz: No such file or directory
Unable to update repository local
No luck either. It seems they just don’t want anyone using the pkg system. Thats annoying, but fair as they don’t want people messing with the system. I can understand that.
Besides there is another option available to us, we can build from source! And luckily Nagios has some excellent documentation available on doing just that. Lets get started by grabbing the source code.
root@freenas:~ # cd /tmp
root@freenas:/tmp # wget --no-check-certificate -O nrpe.tar.gz https://github.com/NagiosEnterprises/nrpe/archive/nrpe-3.2.0.tar.gz
--2017-08-06 12:06:05-- https://github.com/NagiosEnterprises/nrpe/archive/nrpe-3.2.0.tar.gz
Resolving github.com (github.com)... 192.30.253.113, 192.30.253.112
Connecting to github.com (github.com)|192.30.253.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/NagiosEnterprises/nrpe/tar.gz/nrpe-3.2.0 [following]
--2017-08-06 12:06:06-- https://codeload.github.com/NagiosEnterprises/nrpe/tar.gz/nrpe-3.2.0
Resolving codeload.github.com (codeload.github.com)... 192.30.253.120, 192.30.253.121
Connecting to codeload.github.com (codeload.github.com)|192.30.253.120|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘nrpe.tar.gz’
nrpe.tar.gz [ <=> ] 505.64K 1.01MB/s in 0.5s
2017-08-06 12:06:07 (1.01 MB/s) - ‘nrpe.tar.gz’ saved [517774]
Now we can extract it and change into the new directory.
root@freenas:/tmp # tar zxf nrpe.tar.gz
root@freenas:/tmp # cd /tmp/nrpe-nrpe-3.2.0/
So far so good, now lets run configure.
root@freenas:/tmp/nrpe-nrpe-3.2.0 # ./configure --enable-command-args
checking for a BSD-compatible install... /usr/bin/install -c
checking what the operating system is ... bsd
checking what the distribution type is ... freebsd
checking what init system is being used ... newbsd
checking what inetd is being used ... inetd (Not running)
checking for which paths to use ... default
checking for which init file to use ... newbsd-init
checking for which inetd files to use ... default-inetd
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in '/tmp/nrpe-nrpe-3.2.0':
configure: error: no acceptable C compiler found in $PATH
See 'config.log' for more details
…and no compiler, no gcc, no cc, nothing. Thanks FreeNAS! At this point we’ve exhausted all available options. Except one.
That’s right, you read that right. To make this work, we’ll use a jail to compile and build Nagios NRPE and the Plugins from source. Then scp the resulting files to the FreeNAS server. It sounds complex, but its not, so lets get started.
Login to the UI of your FreeNAS system. Under Jails, click Add Jail, give it a name and click OK.
List the available jails on your FreeNAS system, then connect to the jail you created in step 1.
root@freenas:~ # jls
JID IP Address Hostname Path
1 plex /mnt/vol1/jails/plex
2 build /mnt/vol1/jails/build
root@freenas:~ # jexec 2 tcsh
root@build:/ #
root@build:/ # pkg update
root@build:/ # pkg upgrade
root@build:/ # pkg install wget
Follow the Nagios build from source instructions documented here: https://support.nagios.com/kb/article.php?id=515#FreeBSD
pkg install -y wget autoconf automake gettext gcc openssl openssl-devel libmcrypt
cd ~/
wget --no-check-certificate -O nrpe.tar.gz https://github.com/NagiosEnterprises/nrpe/archive/nrpe-3.2.0.tar.gz
tar xzf nrpe.tar.gz
cd ~/nrpe-nrpe-3.2.0/
./configure --enable-command-args
make all
make install-groups-users
make install
make install-config
make install-init
Follow the Nagios Plugins build from source instructions documented here: https://support.nagios.com/kb/article.php?id=569#FreeBSD
pkg install -y wget autoconf automake gettext gcc openssl-devel net-snmp p5-Net-SNMP-Util
cd ~/
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar zxf nagios-plugins.tar.gz
cd ~/nagios-plugins-release-2.2.1/
./tools/setup
./configure
make
make install
mkdir -p ~/nrpe3-pkg/etc/rc.d
mkdir -p ~/nrpe3-pkg/usr/local/nagios/
cp /etc/rc.d/nrpe ~/nrpe3-pkg/etc/rc.d/
cp -R /usr/local/nagios/* ~/nrpe3-pkg/usr/local/nagios/
cd ~/
tar zcvf nrpe3.tar.gz nrpe3-pkg/
scp ~/nrpe3.tar.gz root@freenas:~/
ssh -l root freenas
cd ~/
tar zxf nrpe3.tar.gz
Configure and install NRPE files and plugins, with the below install.sh script.
cd ~/nrpe3-pkg
wget https://gist.github.com/mikejsutherland/41cccb888a7936c7c0fed95ae7fbfb20/raw/4bce902ea6dde4c8d35bfe8f08e341f8676f4e07/install.sh
chmod 755 install.sh
~/nrpe3-pkg/install.sh
service nrpe start
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
NRPE v3.2.0
Thats it, NRPE should now be running on FreeNAS. Configure as necessary by editing “/usr/local/nagios/etc/nrpe.cfg”.
With a little extra work, Nagios NRPE can be made to run on FreeNAS.