Monitoring OPNsense with Beszel
Beszel is a great system monitoring tool that’s simple, lightweight, and well-suited for homelab setups. I’m already using it to keep tabs on my Proxmox instance, my NAS, and several VMs. Naturally, I wanted to extend this monitoring to my OPNsense firewall running on a Protectli FW6B.
The challenge? Beszel doesn’t offer out-of-the-box support for FreeBSD, which OPNsense is based on. But with a bit of tweaking, there’s an unofficial way to get it up and running. Here’s what you need to do:
- Download beszel-agent to
/usr/local/bin
.
cd /usr/local/bin
fetch https://github.com/henrygd/beszel/releases/download/v0.12.1/beszel-agent_freebsd_amd64.tar.gz && tar -xzf beszel-agent_freebsd_amd64.tar.gz
rm beszel-agent_freebsd_amd64.tar.gz
- Create a file called
beszel_agent
in/usr/local/etc/rc.d/
.
cd /usr/local/etc/rc.d/
touch beszel_agent
and populate it with:
#!/bin/sh
#
# PROVIDE: beszel_agent
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# This script starts bezel-agent at system boot.
#
. /etc/rc.subr
name="beszel_agent"
rcvar=beszel_agent_enable
command="/usr/local/bin/beszel-agent"
command_args=""
pidfile="/var/run/${name}.pid"
load_rc_config $name
: ${beszel_agent_enable:="NO"}
# Ensure required environment variables are set.
if [ -z "${beszel_agent_key}" ] || [ -z "${beszel_agent_port}" ]; then
echo "ERROR: beszel_agent_key and beszel_agent_port must be set in /etc/rc.conf.d/beszel_agent"
exit 1
fi
beszel_agent_start() {
echo "Starting beszel-agent..."
# Launch the command with the required environment variables.
env KEY="${beszel_agent_key}" PORT="${beszel_agent_port}" ${command} ${command_args} &
echo $! > ${pidfile}
}
beszel_agent_stop() {
echo "Stopping beszel-agent..."
if [ -f ${pidfile} ]; then
kill "$(cat ${pidfile})" && rm -f ${pidfile}
fi
}
beszel_agent_status() {
if [ -f "${pidfile}" ]; then
pid=$(cat "${pidfile}")
if kill -0 "${pid}" 2>/dev/null; then
echo "beszel-agent is running (pid: ${pid})."
return 0
else
echo "beszel-agent is not running (stale pid file)."
return 1
fi
else
echo "beszel-agent is not running."
return 1
fi
}
start_cmd="beszel_agent_start"
stop_cmd="beszel_agent_stop"
status_cmd="beszel_agent_status"
run_rc_command "$1"
- Chmod the file you just created to make it executable:
chmod +x /usr/local/etc/rc.d/beszel_agent
- Then, create a file called
beszel_agent
in/etc/rc.conf.d/
.
cd /etc/rc.conf.d/
touch beszel_agent
And populate it with the following, ensuring to enter the port and the key that you get from Beszel:
beszel_agent_enable="YES"
beszel_agent_key="REPLACE WITH KEY"
beszel_agent_port="REPLACE WITH PORT"
- Enable the service:
service beszel_agent enable
- Start the service:
service beszel_agent start
Once everything is set up, you’ll be able to monitor your OPNsense alongside the rest of your infrastructure—all from the same clean Beszel interface. It’s a great way to unify system visibility without adding overhead or complexity.