---
title: "How to monitor FreeBSD using NRPE"
description: "Monitoring FreeBSD 13 servers using NRPEv3 with OP5 Monitor 8.4.0 involves installing and configuring NRPE3 and custom check plugins. The guide provides step-by-step instructions for setup, configuration, and creating services in the Monitor GUI."
url: "https://docs.itrsgroup.com/docs/faq/op5/360020252733-op5-monitor-how-to-monitor-freebsd-using-nrpe/index.html"
---
## 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:

1. Install *net-mgmt/nrpe3* from the ports collection, using your preferred method. We will use the binary package in this example.
   1. **Installing net-mgmt/nrpe3**

      ```
      # pkg install net-mgmt/nrpe3
      ```

2. Edit the nrpe configurations file */usr/local/etc/nrpe.cfg* and modify the following line:
   1. **/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:

   2. **/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
      ```

3. Add a custom configuration file to include:

   1. **/usr/local/etc/nrpe.cfg**

      ```
      include=/usr/local/etc/op5/nrpe.cfg
      ```

4. Create the directory:

   1. ```
      # mkdir -p /usr/local/etc/op5

      ```
5. Create the configuration file with the following contents, modified to your needs:

   1. **/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

      ```
6. Create a directory for custom nrpe check commands:

   1. **/usr/local/libexec/nagios/custom/**
      ```

      # mkdir -p /usr/local/libexec/nagios/custom

      ```
7. Download a few custom open-source check plugins and put the in the previously created folder /usr/local/libexec/nagios/custom:

   1. **/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

      ```
8. Enable and start the NRPE3 service:

   1. **nrpe3**
      ```

      # service nrpe3 enable
      # service nrpe3 start

      ```
9. 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:

![OP5 Monitor - How to monitor FreeBSD using NRPE](https://docscdn.itrsgroup.com/faq/images/op5/360020252733-32408267-freebsd_service_example.PNG)

## 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.


