influxdata/telegraf

[[inputs.system]] /var/run/utmp: no such file... when using Alpine as base Image

Closed this issue · 5 comments

some informations to #5283 and the older issue #5031: and as asked by @danielnelson
here the Issue

Relevant telegraf.conf:

used the standard, did no changes. just ran the two commands provided in the readme of Dockerhub:
$ docker run -d --name influxdb -p 8083:8083 -p 8086:8086 influxdb
$ docker run --net=container:influxdb telegraf:alpine

System info:

Host MacOs, Docker Version 2.0.0.2

[Include Telegraf version, operating system name, and other relevant details]

DockerEnvironment$ docker run --net=container:influxdb telegraf:alpine
2019-02-08T21:54:40Z I! Starting Telegraf 1.9.4
2019-02-08T21:54:40Z I! Using config file: /etc/telegraf/telegraf.conf
2019-02-08T21:54:40Z I! Loaded inputs: inputs.mem inputs.processes inputs.swap inputs.system inputs.cpu inputs.disk inputs.diskio inpu
ts.kernel
2019-02-08T21:54:40Z I! Loaded aggregators: 
2019-02-08T21:54:40Z I! Loaded processors: 
2019-02-08T21:54:40Z I! Loaded outputs: influxdb
2019-02-08T21:54:40Z I! Tags enabled: host=9ab66945f415
2019-02-08T21:54:40Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"9ab66945f415", Flush Interval:10s
2019-02-08T21:54:50Z E! [inputs.system]: Error in plugin: open /var/run/utmp: no such file or directory
...
...

Steps to reproduce:

  1. ...$ docker run -d --name influxdb -p 8083:8083 -p 8086:8086 influxdb
  2. ...$ docker run --net=container:influxdb telegraf:alpine
    watch the command line output.

Expected behavior:

run without errors

Actual behavior:

2019-02-08T21:54:50Z E! [inputs.system]: Error in plugin: open /var/run/utmp: no such file or directory

Additional info:

I did dig deeper in this problem.
Alpine as being such a minimal image somehow does not provide the file, that [[inputs.system]] is looking for.
The command uptime is working.

bash-4.4# uptime
 22:11:56 up  6:36,  0 users,  load average: 0.44, 0.43, 0.30

I did not find a solution how to load the utmp corresponding program via apk.

So the workaround provided in other bugs #5031 has some deeper issue behind.
In my specific case I would like to use the container with alpine, without having to bind anything to the host. this behavior makes the container somehow dependent, what I would like to avoid.

[Include gist of relevant config, logs, etc.]

Based on running strace uptime, I believe uptime is using /proc/uptime and /proc/loadavg on alpine. However I cannot see how it is retrieving the users value, perhaps it is always hardcoded to 0?

The version of uptime on alpine:

# uptime -V
uptime from procps-ng UNKNOWN

I believe this is the source code:
https://gitlab.com/procps-ng/procps/blob/master/proc/whattime.c

There are 23 issues relating around this and i'm just wondering if anybody else is interested in this just having a flag to turn off "uptime" collection. Would maintainers take a merge that put in a config flag for that?

Made the PR for both n_users (which is what actually requires utmp http://man7.org/linux/man-pages/man5/utmp.5.html) and for uptime. Both of which i feel are not useful enough to keep fighting with this.

Also @evanphx the docs do say to mount /var/run/utmp:/var/run/utmp however this wont work on the mac and the latest docker CE.

Closed in #5742