Drop superfluous and overly pedantic typecasting for values that fit
within 32 bits or where type comparison is already hinted.
Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
Ensure identical factory function name across arch-specific files so
that the common init() function in zfs.go works.
Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
Avoid Linux-specific code scattered in two places by moving it to the
already-existing zfs_linux.go.
Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
We already support reading from multiple directories though only using globs. Now we can specify them outright.
Example use case is exporting both static info on a RO FS generated during image building and traditional uses of textfiles (e.g. for R/W service metrics files) without scripting a file copy.
* keep flag name for compatibility
* clarify flag help text
* add test case (replicating the glob one)
Signed-off-by: eduarrrd <eduarrrd@users.noreply.github.com>
In order to reduce cardinality of the interrupts collector add
filtering options
* Add include/exclude regexp filter flags.
* Add boolean flag to include zero values, enabled by default.
Signed-off-by: Ben Kochie <superq@gmail.com>
* collector/zfs: Prevent `procfs` integer underflow
Prevent integer underflow when parsing the `procfs` file as it used a
`ParseUint` to parse signed values.
Fixes: #2766
---------
Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* ref!: convert linux meminfo implementation to use procfs lib
Part of #2957
Prometheus' procfs lib supports collecting memory info and we're using a
new enough version of the lib that has it available, so this converts
the meminfo collector for Linux to use data from procfs lib instead. The
bits I've touched for darwin/openbsd/netbsd are with intent to preserve
the original struct implementation/backwards compatibility.
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
* fix: meminfo debug log unsupported value
Fixes:
```
ts=2024-06-11T19:04:55.591Z caller=meminfo.go:44 level=debug collector=meminfo msg="Set node_mem" memInfo="unsupported value type"
```
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
* fix: don't coerce nil Meminfo entries to 0, leave out if nil
Nil entries in procfs.Meminfo fields indicate that the value isn't
present on the system. Coercing those nil values to `0` introduces new
metrics on systems that should not be present and can break some
queries.
Addresses PR feedback:
https://github.com/prometheus/node_exporter/pull/3049#discussion_r1637581536https://github.com/prometheus/node_exporter/pull/3049#discussion_r1637584482
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
---------
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
* Add include and exclude filter for sensors in hwmon collector
Fixes#2242
This commit adds two new flags (`collector.hwmon.sensor-include` and `collector.hwmon.sensor-exclude`) to the `hwmon` collector to allow inclusion or exclusion of specific sensors.
Some devices export nonsensical values for certain sensors. Here is an example:
```
node_hwmon_temp_celsius{chip="platform_nct6775_656",sensor="temp13"} 49.75
node_hwmon_temp_celsius{chip="platform_nct6775_656",sensor="temp15"} 3.892313987e+06
node_hwmon_temp_celsius{chip="platform_nct6775_656",sensor="temp16"} 3.892313987e+06
```
As a user I would like to only exclude these sensors, not necessarily the complete device (as is currently possible with the `--collector.hwmon.chip-exclude` flag) as other sensor values might be sensical or desired.
The new option filters based both on device name and sensor name, separated by a semicolon. For example, to exclude the two sensors above, the following regex can be used:
~~~
--collector.hwmon.sensor-exclude="platform_nct6775_656;temp1[5,6]"
~~~
---------
Signed-off-by: Simon Krenger <skrenger@redhat.com>
Running "go test" in the collector directory, without the fixtures
available, results in multiple panics, including `SIGSEGV`. Most of
these are due to incorrect error handling. This cleans them up.
Signed-off-by: Benny Siegert <bsiegert@gmail.com>
Check that the PSI metrics are returned in order to avoid nil pointer
dereference.
* Update fixutre to match real-world samples.
Fixes: https://github.com/prometheus/node_exporter/issues/3015
Signed-off-by: Ben Kochie <superq@gmail.com>
Replace all cpu_ticks_* with cpu_nsec_*, since the former was off my a
magnitude of 10e6, and showed incorrect values for
node_cpu_seconds_total.
Fixes: #1837
Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
* Update Go to 1.22.
* Update Go modules.
* Use new version collector.
* Use standard library slices package.
Signed-off-by: Ben Kochie <superq@gmail.com>
When the zfs collector fails on FreeBSD it doesn't log which `mib` triggered the issue. This makes diagnostics hard.
Incompatibilities in the list of supported mibs is not uncommon with major os updates. By adding this change, it'll be easier for users to report the specific mib that is triggering the failure.
Related to #2847
Signed-off-by: Daniel Kimsey <90741+dekimsey@users.noreply.github.com>