This HOWTO will give you the tools you need to monitor a FreeBSD 12 server using NRPEv3. The following has only been tested on FreeBSD 12, using OP5 Monitor 7.4.1, but it could work on other versions as well.
Step-by-step guide
Using FreeBSD 12, 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/op5nrpe.cfg
-
Create the directory:
-
# mkdir -p /usr/local/etc/op5
-
Create the configuration file with the following contents:
-
/usr/local/etc/op5/op5nrpe.cfg
################################################################################## op5-nrpe command configuration file## COMMAND DEFINITIONS# Syntax:# command[<command_name>]=<command_line>#command[users]=/usr/local/libexec/nagios/check_users -w 3 -c 6command[check_load]=/usr/local/libexec/nagios/check_load -w 6,5,4 -c 12,10,8command[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 / -mcommand[usr_disk]=/usr/local/libexec/nagios/check_disk -w 20% -c 10% -p /usr -mcommand[var_disk]=/usr/local/libexec/nagios/check_disk -w 20% -c 10% -p /var -mcommand[zombie_procs]=/usr/local/libexec/nagios/check_procs -w 5 -c 10 -s Zcommand[total_procs]=/usr/local/libexec/nagios/check_procs -w 150 -c 200command[proc_cron]=/usr/local/libexec/nagios/check_procs -w 1: -c 1:5 -C croncommand[proc_syslogd]=/usr/local/libexec/nagios/check_procs -w 1: -c 1:2 -C syslogdcommand[mem]=/usr/local/bin/perl /usr/local/libexec/nagios/custom/check_mem.pl -u -w 85 -c 95command[updates]=/usr/local/libexec/nagios/custom/check_freebsd_version
-
Create a directory for custom nrpe check commands:
-
/usr/local/libexec/nagios/custom/
# mkdir -p /usr/local/libexec/nagios/custom
-
Download a couple of 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# chmod +x /usr/local/libexec/nagios/custom/check*
-
Enable and start the NRPE3 service:
-
nrpe3
# service enable nrpe3# service start nrpe3
-
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:
System 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 includes checking the status of a process.
-
Tags:
- nrpe
- FreeBSD
- nrpe.cfg
Comments
0 comments
Please sign in to leave a comment.