Skip to content

Add tainted collector - #1567

Closed
coreywright wants to merge 1 commit into
prometheus:masterfrom
coreywright:add_tainted_collector
Closed

coreywright wants to merge 1 commit into
prometheus:masterfrom
coreywright:add_tainted_collector

Conversation

@coreywright

Copy link
Copy Markdown

Collect individual tainted flags as reported by the Linux kernel in
/proc/sys/kernel/tainted. For more information, see
https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html.

Tainted flags report the state of the system. This state is primarily
intended for identifying unsupported conditions related to the Linux
kernel, ie inclusion in stack traces attached to bug reports to
identify that the issue occurred while the system was in an
unsupported state. Some of the flags are useful to system operators
because of the undesired state they represent that needs remediation,
eg MCE, Oops, BUG. Collecting these flags allow system operators to
be alerted to flag changes and keep metrics on flag values.

Signed-off-by: Corey Wright [email protected]

Collect individual tainted flags as reported by the Linux kernel in
/proc/sys/kernel/tainted. For more information, see
https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html.

Tainted flags report the state of the system.  This state is primarily
intended for identifying unsupported conditions related to the Linux
kernel, ie inclusion in stack traces attached to bug reports to
identify that the issue occurred while the system was in an
unsupported state.  Some of the flags are useful to system operators
because of the undesired state they represent that needs remediation,
eg MCE, Oops, BUG.  Collecting these flags allow system operators to
be alerted to flag changes and keep metrics on flag values.

Signed-off-by: Corey Wright <[email protected]>
@coreywright

coreywright commented Dec 13, 2019 •

Copy link
Copy Markdown
Author

@coreywright

Copy link
Copy Markdown
Author

example metrics:

$ curl -s localhost:9108/metrics | grep node_tainted
# HELP node_tainted_A An ACPI table was overridden by user.
# TYPE node_tainted_A gauge
node_tainted_A 0
# HELP node_tainted_B Bad page referenced or some unexpected page flags.
# TYPE node_tainted_B gauge
node_tainted_B 0
# HELP node_tainted_C Staging driver was loaded.
# TYPE node_tainted_C gauge
node_tainted_C 0
# HELP node_tainted_D Kernel died recently, i.e. there was an OOPS or BUG.
# TYPE node_tainted_D gauge
node_tainted_D 0
# HELP node_tainted_E Unsigned module was loaded.
# TYPE node_tainted_E gauge
node_tainted_E 1
# HELP node_tainted_F Module was force loaded.
# TYPE node_tainted_F gauge
node_tainted_F 0
# HELP node_tainted_I Workaround for bug in platform firmware applied.
# TYPE node_tainted_I gauge
node_tainted_I 0
# HELP node_tainted_K Kernel has been live patched.
# TYPE node_tainted_K gauge
node_tainted_K 1
# HELP node_tainted_L Soft lockup occurred.
# TYPE node_tainted_L gauge
node_tainted_L 0
# HELP node_tainted_M Processor reported a Machine Check Exception (MCE).
# TYPE node_tainted_M gauge
node_tainted_M 0
# HELP node_tainted_O Externally-built ("out-of-tree") module was loaded.
# TYPE node_tainted_O gauge
node_tainted_O 1
# HELP node_tainted_P Proprietary module was loaded.
# TYPE node_tainted_P gauge
node_tainted_P 0
# HELP node_tainted_R Module was force unloaded.
# TYPE node_tainted_R gauge
node_tainted_R 0
# HELP node_tainted_S SMP kernel oops on an officially SMP incapable processor.
# TYPE node_tainted_S gauge
node_tainted_S 0
# HELP node_tainted_T The kernel was built with the struct randomization plugin.
# TYPE node_tainted_T gauge
node_tainted_T 0
# HELP node_tainted_U Taint requested by userspace application.
# TYPE node_tainted_U gauge
node_tainted_U 0
# HELP node_tainted_W Kernel issued warning.
# TYPE node_tainted_W gauge
node_tainted_W 0
# HELP node_tainted_X Auxiliary taint, defined and used by for distros.
# TYPE node_tainted_X gauge
node_tainted_X 0

example debug output:

$ ./node_exporter --collector.tainted --log.level=debug --web.listen-address=":9108" ...
INFO[0000] Starting node_exporter (version=0.18.1, branch=master, revision=2cae917bb7e0b6379221e8a24da012b16e63d661)  source="node_exporter.go:162"
INFO[0000] Build context (go=go1.13.5, user=user@localhost, date=20191213-19:07:41)  source="node_exporter.go:163"
INFO[0000] Enabled collectors:                           source="node_exporter.go:98"
INFO[0000]  - tainted                                    source="node_exporter.go:105"
INFO[0000] Listening on :9108                            source="node_exporter.go:176"
...
DEBU[3429] collect query: []                             source="node_exporter.go:66"
DEBU[3429] Set tainted bit 0: 0                          source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 1: 0                          source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 2: 0                          source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 3: 0                          source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 4: 0                          source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 5: 0                          source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 6: 0                          source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 7: 0                          source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 8: 0                          source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 9: 0                          source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 10: 0                         source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 11: 0                         source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 12: 1                         source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 13: 1                         source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 14: 0                         source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 15: 1                         source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 16: 0                         source="tainted_linux.go:178"
DEBU[3429] Set tainted bit 17: 0                         source="tainted_linux.go:178"
DEBU[3429] OK: tainted collector succeeded after 0.000537s.  source="collector.go:135"

@discordianfish

Copy link
Copy Markdown
Member

Hi, thanks for this. But two things:

  1. The parsing should be moved to https://github.com/prometheus/procfs
  2. Not sure about the metric format. Maybe thisshould be exposed as a single metric with labels. Or even the raw value.

@SuperQ wdyt?

@SuperQ

SuperQ commented Jan 31, 2020

Copy link
Copy Markdown
Member

Sorry, my inbox has been overflowing.

👍 to both points made by @discordianfish.

  • We first want to implement the parsing in the procfs library.
  • The flags should be a label, so node_linux_kernel_tainted{bit="A"}.

FYI, we have a new type in OpenMetrics called "bit set" that matches this kind of use case perfectly.

@SuperQ SuperQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is still interest in this, please address the requested changes:

#1567 (comment)

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.

3 participants