Skip to content

Add OPNsense by REST API - #807

Closed
Garfieldttt wants to merge 2 commits into
zabbix:mainfrom
Garfieldttt:opnsense-by-rest-api
Closed

Add OPNsense by REST API#807
Garfieldttt wants to merge 2 commits into
zabbix:mainfrom
Garfieldttt:opnsense-by-rest-api

Conversation

@Garfieldttt

Copy link
Copy Markdown
Contributor

OPNsense by REST API

A second OPNsense template next to OPNsense by HTTP-JSON, derived from it and considerably
wider. It carries its own name and its own uuids, so both can be linked to the same host and
importing one does not touch the other.

Everything below was measured against a live OPNsense 26.7 with a restricted monitoring key,
not taken from the documentation.

What it adds over the template it grew out of

  • processor utilisation split into user, system and interrupt, core count and load per core
  • the packet filter in depth: state and source tracking tables with their limits, pf counters,
    table entries against the configured ceiling, and the loaded ruleset with size, fingerprint,
    evaluation rate and unmatched rules
  • kernel network memory and mbuf clusters, netisr queue drops per protocol, IP and TCP
    protocol error rates
  • clock synchronisation with offset, stratum and reachable peers
  • service run state, swap per device and temperature per sensor, each discovered
  • inbound errors and link state per interface, and the blocked share of the firewall log
  • a dashboard of eight pages in place of three

107 items, 14 discovery rules with 70 item prototypes, 52 triggers, 36 macros.

Three defects of the original are fixed here rather than carried over

What Why it failed
diagnostics/firewall/pfStates and diagnostics/system/systemResources The privilege patterns are pf_states and system_resources, exact rather than wildcards, and ACL.php matches them with preg_match without the i modifier. An administrator key never notices, a monitoring key gets HTTP 403 on the firewall state items, the state table utilization and all memory items
IPsec phase 2 searchPhase2Action reads its connection from getPost('id') and the template asked with a plain GET, so phase 2 could only ever return an empty row set. It is an item prototype inside the phase 1 rule now, posting one request per connection
Gateway without a monitor address The API answers with a tilde for round trip time, loss and deviation, which was substituted with the literal 9999. That landed in history and made the gateway graphs unreadable. The reading is discarded instead, and the trigger that reports the disabled monitoring is Info rather than Average, since switching it off is a configuration decision

Compatibility

The export declares format 7.0 rather than 7.4, so it imports into Zabbix 7.0 and every
later release. Every widget type it uses (gauge, honeycomb, item, svggraph) exists in 7.0.

Privileges

The README lists the ten privileges the monitoring user needs with their internal ids. Eight
are read only. It also says what the other two permit and how to do without them.

Licensing

Derived from OPNsense by HTTP-JSON in this repository, MIT, Copyright (c) 2021 Zabbix. The
notice travels with it, in the template description and in the README.

Maintained at https://github.com/Garfieldttt/opnsense-zabbix-template.

A second OPNsense template next to OPNsense by HTTP-JSON, derived from it
and considerably wider. It carries its own name and its own uuids, so both
can be linked to the same host and importing one does not touch the other.

Compared with the template it grew out of it adds, measured against a live
OPNsense 26.7 with a restricted monitoring key:

  * processor utilisation split into user, system and interrupt, core count
    and load per core derived from it
  * the packet filter in depth: state and source tracking tables with their
    limits, pf counters, table entries against the configured ceiling, and
    the loaded ruleset with size, fingerprint, evaluation rate and unmatched
    rules
  * kernel network memory and mbuf clusters, netisr queue drops per
    protocol, IP and TCP protocol error rates
  * clock synchronisation with offset, stratum and reachable peers
  * service run state, swap per device and temperature per sensor, each
    discovered
  * inbound errors and link state per interface, and the blocked share of
    the firewall log
  * a dashboard of eight pages in place of three

Three defects of the original are fixed here rather than carried over. Two
urls used camelCase where the privilege pattern is exact and ACL.php matches
it case sensitively, so a monitoring key got HTTP 403 on the firewall state
and all memory items. IPsec phase 2 asked with a GET although
searchPhase2Action reads its connection from getPost('id'), so it could only
ever return an empty row set; it is an item prototype inside the phase 1
rule now, posting one request per connection. A gateway without a monitor
address had 9999 written into round trip time, loss and deviation, which
landed in history and made the gateway graphs unreadable; the reading is
discarded instead.

The export declares format 7.0 rather than 7.4, so it imports into Zabbix
7.0 and everything above. Every widget type it uses exists in 7.0.

The privileges the monitoring user needs are listed in the README with their
internal ids, measured with a restricted key. Eight of the ten are read
only, and the README says what the other two permit and how to do without
them.
Four areas read from a live OPNsense 26.7 with a restricted monitoring key,
none of which needs a privilege beyond the ten the README already lists.

Unbound, from `unbound/diagnostics/stats`: query, cache hit, cache miss,
prefetch and rate limited rates, average recursion time, the request queue
and its overflows, and a calculated cache hit ratio. On most installations
the firewall is also the resolver for the network behind it, which made this
the widest gap.

Certificates, from `trust/cert/search`: every row carries `valid_to` as a
Unix timestamp, so an expiring web interface, VPN or ACME certificate is
visible before it takes a service down. Discovered per certificate, expired
at average and expiring at warning, the second depending on the first.

System status, from `core/system/status`: the panel the web interface shows
about itself. A firewall with nothing pending answers 2 and "No pending
messages". The other codes were not observed, so the trigger fires on
anything other than 2 rather than claiming to know them, and the message is
carried next to it as text.

DHCP leases, from `kea/leases4/search` and `kea/leases6/search`, without a
trigger on purpose: a network that addresses everything statically runs at
zero leases forever, and the meaningful threshold is the size of the pool,
which is a local decision.

No JavaScript in any of it. Each master cuts its response down with a native
step and the dependent items read the result with plain JSONPath.

The trigger `Battey low` inherited from the template this one grew out of is
spelled `Battery low`, and trigger names carry no product prefix, following
the Zabbix guidelines: the host name is already in front of the trigger.

The dashboard gains a ninth page for the resolver, the certificates and the
leases.

127 items now, 15 discovery rules with 71 item prototypes, 58 triggers and
41 macros.
@Garfieldttt
Garfieldttt deleted the opnsense-by-rest-api branch August 23, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant