sysutils/node_exporter: add textfile collector directory support

Expose --collector.textfile.directory via a new optional UI field so
users can drop .prom files into a local directory and have them scraped
alongside the built-in collectors. Useful for custom metrics (SSH
sessions, SMART data, gateway status, etc.) without patching the binary.

Bumps model version 0.2.0 -> 0.3.0.
This commit is contained in:
Steve Wolfe 2026-05-19 00:08:31 -04:00
parent 4b94d331ae
commit 40f726ddf8
3 changed files with 13 additions and 2 deletions

View file

@ -83,4 +83,10 @@
<type>checkbox</type>
<help>Enable the ZFS collector.</help>
</field>
<field>
<id>general.textfile_directory</id>
<label>Textfile Directory</label>
<type>text</type>
<help>Path to a directory read by the textfile collector. Files ending in .prom in this directory will be exposed as metrics. Leave empty to disable. Example: /var/db/node_exporter</help>
</field>
</form>

View file

@ -1,7 +1,7 @@
<model>
<mount>//OPNsense/NodeExporter</mount>
<description>node_exporter configuration</description>
<version>0.2.0</version>
<version>0.3.0</version>
<items>
<enabled type="BooleanField">
<Default>0</Default>
@ -29,5 +29,6 @@
<interrupts type="BooleanField"/>
<ntp type="BooleanField"/>
<zfs type="BooleanField"/>
<textfile_directory type="TextField"/>
</items>
</model>

View file

@ -46,13 +46,17 @@
{%- set zfs = no_collector + "zfs " -%}
{%- endif -%}
{%- if not helpers.empty('OPNsense.NodeExporter.textfile_directory') -%}
{%- set textfile_directory = "--collector.textfile.directory=" + OPNsense.NodeExporter.textfile_directory + " " -%}
{%- endif -%}
{%- if ':' in OPNsense.NodeExporter.listenaddress -%}
{%- set listenaddress = '[' + OPNsense.NodeExporter.listenaddress + ']' -%}
{%- else -%}
{%- set listenaddress = OPNsense.NodeExporter.listenaddress -%}
{%- endif -%}
node_exporter_args="{{ cpu }}{{ exec }}{{ filesystem }}{{ loadavg }}{{ meminfo }}{{ netdev }}{{ ntp }}{{ time }}{{ devstat }}{{ zfs }}"
node_exporter_args="{{ cpu }}{{ exec }}{{ filesystem }}{{ loadavg }}{{ meminfo }}{{ netdev }}{{ ntp }}{{ time }}{{ devstat }}{{ zfs }}{{ textfile_directory }}"
node_exporter_listen_address="{{ listenaddress }}:{{ OPNsense.NodeExporter.listenport }}"
node_exporter_enable="YES"