Ensure that unwanted tests are correctly excluded when various build
tags are specified, i.e. when the code that they test would be excluded
from compilation.
Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
Some systems have broken netlink messages due to patched kernels. Since
these messages can not be parsed, add a flag to fall back to parsing
from `/proc/net/dev`.
Fixes: https://github.com/prometheus/node_exporter/issues/2502
Signed-off-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Ben Kochie <superq@gmail.com>
On Linux, we get more detailed interface statistics from netlink than we did
from `/proc/net/dev`.
This commit adds a new flag (`--collector.netdev.enable-detailed-metrics`) to
expose those statistics under new (incompatible) metric names. When enabled,
the metric names are also changed on Darwin and BSD platforms to keep
everything consistent, but it doesn't provide more detailed statistics on those
platforms.
The old metrics can be derived from the new ones using the following rules
([dev_seq_printf_stats]):
- `receive_errs` = `receive_errors`
- `receive_drop` = `receive_dropped` + `receive_missed_errors`
- `receive_fifo` = `receive_fifo_errors`
- `receive_frame` = `receive_length_errors` + `receive_over_errors` + `receive_crc_errors` + `receive_frame_errors`
- `receive_multicast` = `multicast`
- `transmit_errs` = `transmit_errors`
- `transmit_drop` = `transmit_dropped`
- `transmit_fifo` = `transmit_fifo_errors`
- `transmit_colls` = `collisions`
- `transmit_carrier` = `transmit_aborted_errors` + `transmit_carrier_errors` + `transmit_heartbeat_errors` + `transmit_window_errors`
[dev_seq_printf_stats]: https://github.com/torvalds/linux/blob/master/net/core/net-procfs.c#L75-L97
Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
To prepare for the introduction of new metric names, add tests for the legacy
metric names and values. This will make it easier to ensure that the code that
converts the new metrics to the old ones (for compatibility) behaves correctly.
Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
Instead of parsing `/proc/net/dev` to get network interface statistics, get
them from a netlink call.
Internally, both come from the [rtnl_link_stats64] struct, but with
`/proc/net/dev`, some of the values are aggregated together in
[dev_seq_printf_stats], so we get less information out of them.
This commit maintains compatibility by aggregating those stats back into the
same metrics.
[rtnl_link_stats64]: https://github.com/torvalds/linux/blob/master/include/uapi/linux/if_link.h#L42-L246
[dev_seq_printf_stats]: https://github.com/torvalds/linux/blob/master/net/core/net-procfs.c#L75-L97
Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
Fix the error logging of the promhttp handler by connecting it to the
promlog setup.
* Switch to go-kit/log.
* Cleanup CHANGELOG.
Fixes: https://github.com/prometheus/node_exporter/issues/1886
Signed-off-by: Ben Kochie <superq@gmail.com>
* Check interface name before loading interface data
* Reduce indentation
* Optimize nested netdev map
This change avoids conversion to strings and back.
Signed-off-by: Julian Kornberger <jk+github@digineo.de>
* Add --collector.netdev.device-whitelist flag
Sometimes it is desired to monitor only one netdev. The golang regexp
does not support a negated regex, so the ignored-devices flag is too
cumbersome for this task.
This change introduces a new flag: accept-devices, which is mutually
exclusive to ignored-devices. This flag allows specifying ONLY the
netdev you'd like.
Signed-off-by: Noam Meltzer <noam@cynerio.co>