Introduction
This HOWTO will give you the tools you need to monitor a FreeBSD 13 server using NRPEv3. The following has been tested on FreeBSD 13, using OP5 Monitor 8.4.0, but could work on newer versions too.
Note that not all the example checks will be of use in all cases. Adapt to your needs.
Step-by-step guide
Using FreeBSD 12 or 13, do the following:
- Install net-mgmt/nrpe3 from the ports collection, using your preferred method. We will use the binary package in this example.
-
Installing net-mgmt/nrpe3
# pkg install net-mgmt/nrpe3
-
- Edit the nrpe configurations file /usr/local/etc/nrpe.cfg and modify the following line:
-
/usr/local/etc/nrpe.cfg
allowed_hosts=127.0.0.1,::1
Add any IP that will be connecting. If you are running a single Monitor node, then use that IP. If you are using a distributed system, make sure to add the IP:s of all nodes that will connect. In my case, it looks like this:
-
/usr/local/etc/nrpe.cfg
allowed_hosts=127.0.0.1,::1,172.27.86.228,172.27.86.229,172.27.86.230,172.27.86.231
-
-
Add a custom configuration file to include:
-
/usr/local/etc/nrpe.cfg
include=/usr/local/etc/op5/nrpe.cfg
-
-
Create the directory:
-
# mkdir -p /usr/local/etc/op5
-
-
Create the configuration file with the following contents, modified to your needs:
-
/usr/local/etc/op5/nrpe.cfg
# op5-nrpe command configuration file
command[users]=/usr/local/libexec/nagios/check_users -w 3 -c 6
command[check_load]=/usr/local/libexec/nagios/check_load -w 6,5,4 -c 12,10,8
command[swap]=/usr/local/libexec/nagios/check_swap -w 20% -c 10%
command[root_disk]=/usr/local/libexec/nagios/check_disk -w 20% -c 10% -p / -m
command[usr_disk]=/usr/local/libexec/nagios/check_disk -w 20% -c 10% -p /usr -m
command[var_disk]=/usr/local/libexec/nagios/check_disk -w 20% -c 10% -p /var -m
command[zombie_procs]=/usr/local/libexec/nagios/check_procs -w 5 -c 10 -s Z
command[total_procs]=/usr/local/libexec/nagios/check_procs -w 150 -c 200
command[proc_cron]=/usr/local/libexec/nagios/check_procs -w 1: -c 1:5 -C cron
command[proc_syslogd]=/usr/local/libexec/nagios/check_procs -w 1: -c 1:2 -C syslogd
command[mem]=/usr/local/bin/perl /usr/local/libexec/nagios/custom/check_mem.pl -u -w 85 -c 95
command[updates]=/usr/local/libexec/nagios/custom/check_freebsd_version
command[zfs_zroot]=/usr/local/libexec/nagios/custom/check_zfs --nosudo zroot
-
-
Create a directory for custom nrpe check commands:
-
/usr/local/libexec/nagios/custom/
# mkdir -p /usr/local/libexec/nagios/custom
-
-
Download a few custom open-source check plugins and put the in the previously created folder /usr/local/libexec/nagios/custom:
-
/usr/local/libexec/nagios/custom/
# fetch --no-verify-peer -o /usr/local/libexec/nagios/custom/check_freebsd_version https://raw.githubusercontent.com/frlen/nagios-plugins/master/check_freebsd_version
# fetch --no-verify-peer -o /usr/local/libexec/nagios/custom/check_mem.pl https://raw.githubusercontent.com/justintime/nagios-plugins/master/check_mem/check_mem.pl
# fetch --no-verify-peer -o /usr/local/libexec/nagios/custom/check_zfs https://raw.githubusercontent.com/zlacelle/nagios_check_zfs_linux/master/check_zfs.py
# chmod +x /usr/local/libexec/nagios/custom/check*
# pkg install -y python sudo
# sed -i.bak 's/usr\/bin/usr\/local\/bin/' /usr/local/libexec/nagios/custom/check_zfs
# rm /usr/local/libexec/nagios/custom/check_zfs.bak
# echo "nagios ALL=NOPASSWD: /sbin/zfs" > /usr/local/etc/sudoers.d/check_zfs
-
-
Enable and start the NRPE3 service:
-
nrpe3
# service nrpe3 enable
# service nrpe3 start
-
-
Now you can create your own services in the Monitor GUI using the pre-defined checks above! Use check_nrpe as the check_command, and put the name of the commands as arguments. An example below:
Security Hardening
Note that the current configuration will not work with systems where security.bsd.see_other_uids OR security.bsd.see_other_gids is set to 0. This is valid for all tests that include checking the status of a process.
Comments
0 comments
Please sign in to leave a comment.