Skip to content

pfSense

A pfSense firewall through the community REST API package (pfSense-pkg-RESTAPI, version 2): gateways that are down, lose packets or answer slowly, enabled interfaces without link, enabled services that stopped, and CPU, memory, disk and temperature.

DumbMonit sends an API key in the X-API-Key header. A key carries exactly the privileges of the pfSense user it belongs to: the dumbmonit user below holds only the GET privileges of the five pages DumbMonit reads, so the key can read those pages and change nothing. Every minute DumbMonit reads, in parallel, /api/v2/status/system, /api/v2/status/gateways, /api/v2/status/interfaces, /api/v2/status/services and /api/v2/system/version, and, if the privilege was given, /api/v2/system/restapi/version.

From the DumbMonit server (or its relay agent) to the device:

PortProtocolPurpose
443TCPAPI (HTTPS, default)
80TCPOnly with the HTTP protocol option

All metrics are prefixed dumbmonit_pfsense_.

MetricLabelsMeaning
cpu_usage_percent, memory_used_percent, swap_used_percent, disk_used_percent, mbuf_used_percentAs the dashboard shows them, in percent. The CPU figure is pfSense’s own estimate from the load average.
temperature_celsiusWhen pfSense can read a sensor.
load_averageperiod: 1m, 5m, 15mLoad average.
cpu_countProcessor cores.
version_infoversionValue 1: the pfSense version, 2.7.2-RELEASE.
gateway_upgateway0 when pfSense marks the gateway down, 1 otherwise.
gateway_status_infogateway, statusValue 1: pfSense’s own word (none when all is well, down, loss, delay).
gateway_loss_percentgatewayPacket loss to the monitor address.
gateway_delay_milliseconds, gateway_stddev_millisecondsgatewayRound trip to the monitor address and its deviation; absent while the gateway is down.
gateways, gateways_downCounts.
interface_enabled, interface_upinterface, descrEnabled in the configuration; link up.
interface_downinterface, descr1 when the interface is enabled and has no link. A disabled interface is never down.
interface_bytes_in_total, interface_bytes_out_total, interface_errors_in_total, interface_errors_out_totalinterface, descrCounters.
interfaces_downCount.
service_running, service_enabledservice, descriptionAs Status > Services shows them.
service_stoppedservice, description1 when the service is enabled and not running.
services_stoppedCount.
restapi_update_availableWith the /api/v2/system/restapi/version privilege: 1 when the REST API package has a newer release.
restapi_version_infoversion, latestValue 1: installed and latest release of the package.

pfSense does not say through this API whether a pfSense update is available: the only route that touches system updates (/api/v2/system/update) starts one. DumbMonit reports the package’s own updates only.

The built-in rules that apply:

  • pfSense gateway down: a gateway is marked down for three minutes (Warning).
  • pfSense gateway losing packets: more than 10 % loss for ten minutes, on a gateway that is not already down (Advisory).
  • pfSense gateway slow: round trip above 500 ms for fifteen minutes (Advisory). Raise it for a satellite link.
  • pfSense interface without link: an enabled interface without link for five minutes (Advisory).
  • pfSense service stopped: an enabled service not running for five minutes (Advisory).
  • pfSense disk nearly full: more than 90 % for thirty minutes (Advisory).

The Firewall panel says what is wrong in a sentence, shows CPU, memory, disk and temperature, then lists every gateway with its latency and loss, the interfaces without link, the stopped services, and an available update of the REST API package.

Create a read-only REST API key for DumbMonit

Section titled “Create a read-only REST API key for DumbMonit”
  1. Install the pfSense-pkg-RESTAPI package (version 2) from Diagnostics → Command Prompt, with the file matching your pfSense version (2.7.2 below).

    pkg-static add https://github.com/pfrest/pfSense-pkg-RESTAPI/releases/latest/download/pfSense-2.7.2-pkg-RESTAPI.pkg
  2. System → REST API → Settings: tick both BasicAuth and Key among the authentication methods.

  3. System → User Manager → Users → Add: create the user dumbmonit with a long random password.

  4. Edit the user and, under Assigned Privileges, add the privileges listed below.

  5. Create the key as dumbmonit, copy the key value of the answer, then remove the POST privilege again.

    curl -k -u dumbmonit -X POST -H 'Content-Type: application/json' -d '{"descr":"DumbMonit"}' https://pfsense.lan/api/v2/auth/key
  6. In DumbMonit, enter the pfSense address (pfsense.lan) and paste the key as API key.

  • /api/v2/status/system GET — CPU, memory, disk, temperature
  • /api/v2/status/gateways GET — Gateway state, delay and loss
  • /api/v2/status/interfaces GET — Interface link and counters
  • /api/v2/status/services GET — Stopped services
  • /api/v2/system/version GET — pfSense version
  • /api/v2/system/restapi/version GET — Optional: updates of the REST API package
  • /api/v2/auth/key POST — Only while creating the key, then remove it

Vendor documentation: https://pfrest.org/AUTHENTICATION_AND_AUTHORIZATION/

A key carries exactly the privileges of the pfSense user it belongs to, so the dumbmonit user holds only the GET privileges of the pages DumbMonit reads: the key can read those pages and change nothing. The package has no menu to create a key for another user, which is why the key is created with one POST call made as dumbmonit (the extra privilege is removed right after). The package is installed from a shell command because pfSense’s Package Manager only lists official packages.

The REST API does not say whether a pfSense update is available, only whether the package itself has one.

CredentialFields
REST API keyThe key created for dumbmonit in step 3, sent as X-API-Key.

Address: the host name or IP of pfSense, host:port, or a URL. Options:

  • Protocol (https) and Port (443): the webConfigurator’s, set under System > Advanced > Admin Access.
  • Accept an unverifiable certificate: pfSense’s own certificate is self-signed.
  • Timeout per request (15 s).

“pfSense refused the API key (401)”: the key is wrong, or Key is not ticked among the authentication methods under System > REST API > Settings.

“pfSense accepted the API key but refused … (403)”: the dumbmonit user lacks the privilege of that page; the message names it.

”… not found: is the REST API package installed?”: the package is missing, typically after a pfSense upgrade, which removes it. Reinstall it as in step 1.