influxdata / influxdata/telegraf

inputs.linux_cpu fails on startup inside a virtual machine

Open
#17,111 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
17.8k
Forks
5.8k
Avg merge
1d 20h
Merged PRs (30d)
161

Description

### Relevant telegraf.conf

```toml
# Provides Linux CPU metrics
# This plugin ONLY supports Linux
[[inputs.linux_cpu]]
## Path for sysfs filesystem.
## See https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
## Defaults:
# host_sys = "/sys"

## CPU metrics collected by the plugin.
## Supported options:
## "cpufreq", "thermal"
## Defaults:
# metrics = ["cpufreq"]
```

### Logs from Telegraf

```text
2025-06-05T08:50:29Z D! [agent] Initializing plugins
2025-06-05T08:50:29Z W! [inputs.linux_cpu] Failed to load property /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: file with CPU property does not exist: "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"
2025-06-05T08:50:29Z W! [inputs.linux_cpu] No properties enabled/loaded for CPU 0
2025-06-05T08:50:29Z W! [inputs.linux_cpu] Failed to load property /sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq: file with CPU property does not exist: "/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq"
2025-06-05T08:50:29Z W! [inputs.linux_cpu] No properties enabled/loaded for CPU 1
2025-06-05T08:50:29Z W! [inputs.linux_cpu] Failed to load property /sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq: file with CPU property does not exist: "/sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq"
2025-06-05T08:50:29Z W! [inputs.linux_cpu] No properties enabled/loaded for CPU 2
2025-06-05T08:50:29Z W! [inputs.linux_cpu] Failed to load property /sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq: file with CPU property does not exist: "/sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq"
2025-06-05T08:50:29Z W! [inputs.linux_cpu] No properties enabled/loaded for CPU 3
2025-06-05T08:50:29Z E! [telegraf] Error running agent: could not initialize input inputs.linux_cpu: no CPUs detected to track
```

### System info

Ubuntu 22.04, telegraf 1.34.4, inside qemu

### Docker

_No response_

### Steps to reproduce

1. Add inputs.linux_cpu to a telegraf config
2. Run inside a virtual machine
3. Error
...

### Expected behavior

Expected behavior: Even if it can't monitor all CPUs, it won't stop the initialization of telegraf. I'd expect an error to be logged at most. A bit related to this PR: https://github.com/influxdata/telegraf/pull/11313. If there are sensors or kernel modules missing, I still want monitoring. Our hardware and software is diverse, I can't generate configurations for all of them.

### Actual behavior

Telegraf initialisation is stopped

### Additional info

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the inputs.linux_cpu initialization path and reproduce the failure in an Ubuntu 22.04 virtual machine under qemu. Inspect how missing CPU properties are handled when no CPUs can be tracked, then run the plugin's existing tests or a VM reproduction. Done means missing properties do not stop Telegraf initialization and the condition is logged appropriately.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.