Sysctl as a Service, or: making sysctl(3) more friendly for monitoring systems

Ed Schouten ed at nuxi.nl
Tue Dec 13 15:08:47 UTC 2016


Hi Warner,

2016-12-13 1:57 GMT+01:00 Warner Losh <imp at bsdimp.com>:
> While we're here... there's one thing I'd love to see from  a
> hypothetical /dev/sysctl... When a sysctl value changes (or some
> subset), I'd like it to appear on a read-channel. That way, I could
> monitor temperature w/o needing to constantly poll for changes, for
> example.

Yes, that would be nice to have. Unfortunately, Prometheus is mostly
pull-based, so I guess such a feature wouldn't be needed in this case.

Anyway, I just finished implementing support for attaching labels to
sysctl nodes:

https://reviews.freebsd.org/D8775

This patch is slightly different from what I had envisioned. For
example, to translate this sysctl:

hw.acpi.thermal.tz1.temperature

to:

sysctl_hw_acpi_thermal_temperature_celcius{thermal_zone="tz1"}

my idea was to attach a "thermal_zone" label to the hw.acpi.thermal
node, indicating that the names of its children should be interpreted
a value for that label. Unfortunately, hw.acpi.thermal also has some
children that should not have that label attached:

hw.acpi.thermal.user_override
hw.acpi.thermal.polling_rate
hw.acpi.thermal.min_runtime

That's why I went for an approach where the label is attached to
hw.acpi.thermal.tz1, so that labelling can be controlled more
granularly.

Note that this change does not affect existing use of sysctl at all.
It's merely the case that they now have additional metadata that is
only used by the Prometheus exporter.

-- 
Ed Schouten <ed at nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717


More information about the freebsd-hackers mailing list