Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inputs.disks reading /proc/1/mountinfo instead of /proc/self/mountinfo #10388

Closed
hvisage opened this issue Jan 5, 2022 · 5 comments
Closed
Labels
area/influxdb bug unexpected problem or unintended behavior waiting for response waiting for response from contributor

Comments

@hvisage
Copy link

hvisage commented Jan 5, 2022

Relevent telegraf.conf

[[inputs.disk]]
  mount points.
  ignore_fs = [ "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]

[[inputs.diskio]]

Logs from Telegraf

telegraf@adebv2mx01:/root$ /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d --once --input-filter disk --debug
2022-01-05T23:36:44Z I! Starting Telegraf 1.21.1
2022-01-05T23:36:44Z I! Loaded inputs: disk
2022-01-05T23:36:44Z I! Loaded aggregators:
2022-01-05T23:36:44Z I! Loaded processors:
2022-01-05T23:36:44Z I! Loaded outputs: influxdb_v2
2022-01-05T23:36:44Z I! Tags enabled: client=AGW_AD client_env=EBV2 host=adebv2mx01 service_type=Mendix
2022-01-05T23:36:44Z D! [agent] Initializing plugins
2022-01-05T23:36:44Z D! [agent] Connecting outputs
2022-01-05T23:36:44Z D! [agent] Attempting connection to [outputs.influxdb_v2]
2022-01-05T23:36:44Z D! [agent] Successfully connected to outputs.influxdb_v2
2022-01-05T23:36:44Z D! [agent] Starting service inputs
2022-01-05T23:36:44Z E! [inputs.disk] Error in plugin: error getting disk usage info: open /proc/1/mounts: no such file or directory
2022-01-05T23:36:44Z D! [agent] Stopping service inputs
2022-01-05T23:36:44Z D! [agent] Input channel closed
2022-01-05T23:36:44Z I! [agent] Hang on, flushing any cached metrics before shutdown
2022-01-05T23:36:44Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
2022-01-05T23:36:44Z I! [agent] Stopping running outputs
2022-01-05T23:36:44Z D! [agent] Stopped Successfully
2022-01-05T23:36:44Z E! [telegraf] Error running agent: input plugins recorded 1 errors

System info

Debian 10.7 (Linux adebv2mx01 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux)

Docker

No response

Steps to reproduce

  1. Secure system to prevent users from seeing other user's processes and process information
  2. Test with a "normal" telegraf user (in Debian 10, telegraf that was created by deb pkg)
  3. Notice the errors is about /proc/1/mountinfo, instasd of /proc/self/mountinfo

Expected behavior

Reading deta from /proc/self/mountinfo (or /proc/mounts) instead of /proc/1/mountingo or /

Actual behavior

reading from /proc/1/mountinfo

Additional info

root@adebv2mx01:# strace -fff /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d --once --input-filter disk 2>&1 | grep -i proc/
[pid 23995] readlinkat(AT_FDCWD, "/proc/self/exe", <unfinished ...>
[pid 23995] openat(AT_FDCWD, "/proc/stat", O_RDONLY|O_CLOEXEC) = 7
[pid 23995] openat(AT_FDCWD, "/proc/stat", O_RDONLY|O_CLOEXEC) = 7
[pid 23995] openat(AT_FDCWD, "/proc/23995/stat", O_RDONLY|O_CLOEXEC) = 7
[pid 23995] openat(AT_FDCWD, "/proc/1/mountinfo", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 23995] openat(AT_FDCWD, "/proc/filesystems", O_RDONLY|O_CLOEXEC) = 7
root@adebv2mx01:
# sudo -u telegraf -s /bin/bash
telegraf@adebv2mx01:/root$ strace -fff /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d --once --input-filter disk 2>&1 | grep -i proc/
[pid 24040] readlinkat(AT_FDCWD, "/proc/self/exe", <unfinished ...>
[pid 24040] openat(AT_FDCWD, "/proc/stat", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 24040] openat(AT_FDCWD, "/proc/stat", O_RDONLY|O_CLOEXEC) = 7
[pid 24040] openat(AT_FDCWD, "/proc/24040/stat", O_RDONLY|O_CLOEXEC) = 7
[pid 24045] openat(AT_FDCWD, "/proc/1/mountinfo", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 24045] openat(AT_FDCWD, "/proc/1/mounts", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 24045] write(2, "2022-01-05T23:33:11Z E! [inputs."..., 1332022-01-05T23:33:11Z E! [inputs.disk] Error in plugin: error getting disk usage info: open /proc/1/mounts: no such file or directory
telegraf@adebv2mx01:/root$ telegraf --version
Telegraf 1.21.1 (git: HEAD 7c9a9c1)
telegraf@adebv2mx01:/root$ head /proc/self/mountinfo
19 24 0:18 / /sys rw,nosuid,nodev,noexec,relatime shared:7 - sysfs sysfs rw
20 24 0:4 / /proc rw,relatime shared:14 - proc proc rw,gid=70,hidepid=2
21 24 0:6 / /dev rw,nosuid,relatime shared:2 - devtmpfs udev rw,size=4068460k,nr_inodes=1017115,mode=755
22 21 0:19 / /dev/pts rw,nosuid,noexec,relatime shared:3 - devpts devpts rw,gid=5,mode=620,ptmxmode=000
23 24 0:20 / /run rw,nosuid,noexec,relatime shared:5 - tmpfs tmpfs rw,size=816988k,mode=755
24 0 8:1 / / rw,relatime shared:1 - ext4 /dev/sda1 rw,errors=remount-ro
25 19 0:7 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:8 - securityfs securityfs rw
26 21 0:21 / /dev/shm rw,nosuid,nodev shared:4 - tmpfs tmpfs rw
27 23 0:22 / /run/lock rw,nosuid,nodev,noexec,relatime shared:6 - tmpfs tmpfs rw,size=5120k
28 19 0:23 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:9 - tmpfs tmpfs ro,mode=755
telegraf@adebv2mx01:/root$ head /proc/filesystems
nodev sysfs
nodev rootfs
nodev ramfs
nodev bdev
nodev proc
nodev cpuset
nodev cgroup
nodev cgroup2
nodev tmpfs
nodev devtmpfs

@hvisage hvisage added the bug unexpected problem or unintended behavior label Jan 5, 2022
@powersj
Copy link
Contributor

powersj commented Jan 5, 2022

This is a bug in gopsutil here. We put in a fix with #10297, could you please update to v1.21.2 and try that?

Thanks

@hvisage
Copy link
Author

hvisage commented Jan 6, 2022

This is a bug in gopsutil here.

Yes, that hidepid=2

We put in a fix with #10297, could you please update to v1.21.2 and try that?

Sorry, same problem, updated from deb http://https///repos.influxdata.com/debian buster stable

telegraf@adebv2mx01:~$ id -a
uid=996(telegraf) gid=993(telegraf) groups=993(telegraf)
telegraf@adebv2mx01:~$ /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d --once --input-filter disk
2022-01-06T05:53:02Z I! Starting Telegraf 1.21.2
2022-01-06T05:53:02Z I! Loaded inputs: disk
2022-01-06T05:53:02Z I! Loaded aggregators:
2022-01-06T05:53:02Z I! Loaded processors:
2022-01-06T05:53:02Z I! Loaded outputs: influxdb_v2
2022-01-06T05:53:02Z I! Tags enabled: client=AGW_AD client_env=EBV2 host=adebv2mx01 service_type=Mendix
2022-01-06T05:53:02Z E! [inputs.disk] Error in plugin: error getting disk usage info: open /proc/1/mounts: no such file or directory
2022-01-06T05:53:02Z I! [agent] Hang on, flushing any cached metrics before shutdown
2022-01-06T05:53:02Z I! [agent] Stopping running outputs
2022-01-06T05:53:02Z E! [telegraf] Error running agent: input plugins recorded 1 errors
telegraf@adebv2mx01:~$

@P4sca1
Copy link
Contributor

P4sca1 commented Apr 4, 2022

gopsutil implemented a fix for this issue by falling back to /proc/self/mountinfo if /proc/1/mountinfo does not work.
Also, the default can be changed by using the env variable HOST_PROC_MOUNTINFO=/proc/self.

gopsutil has already been updated in #10931

@MyaLongmire
Copy link
Contributor

Because #10931 has been merged into master, @hvisage can you please try with a nightly build to see if that fixes the issue?

Nightly builds: https://github.com/influxdata/telegraf/blob/master/docs/NIGHTLIES.md

@powersj powersj added the waiting for response waiting for response from contributor label Sep 13, 2022
@telegraf-tiger
Copy link
Contributor

Hello! I am closing this issue due to inactivity. I hope you were able to resolve your problem, if not please try posting this question in our Community Slack or Community Page. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/influxdb bug unexpected problem or unintended behavior waiting for response waiting for response from contributor
Projects
None yet
Development

No branches or pull requests

4 participants