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

Processes plugin fails to parse output of /proc/[pid]/stat if command contains '-' or '(' #968

Closed
acherunilam opened this issue Apr 5, 2016 · 2 comments · Fixed by #975
Labels
bug unexpected problem or unintended behavior

Comments

@acherunilam
Copy link

https://github.com/influxdata/telegraf/blob/master/plugins/inputs/system/processes.go#L151 is how the Processes plugin parses the output of /proc/[pid]/stat.

$ sudo tail -f /var/log/telegraf/telegraf.log
2016/04/05 11:42:38 processes: Unknown state [ - ] in file /proc/377073/stat
2016/04/05 11:42:38 processes: Unknown state [ ( ] in file /proc/376490/stat
2016/04/05 11:42:40 Gathered metrics, (10s interval), from 11 inputs in 2.19493059s

$ sudo cat /proc/377073/stat /proc/376490/stat
377073 (cpanellogd - sl) S 1 377072 375534 0 -1 4202560 338436 274264341 0 1107 124 401 3207359 159570 38 18 1 0 377307744 21835776 417 18446744073709551615 4194304 4198540 140724696323552 140724696322472 139912685945296 0 0 128 20995 18446744071579506811 0 0 17 17 0 0 110 0 0 0 0 0 0 0 377073 0 0 0
376490 (cpsrvd (SSL) - ) S 1 376490 375534 0 -1 4202752 46501576 5925121575 66 132435 13148 69570 9319189 2678793 20 0 1 0 377306098 107266048 3540 536870912 4194304 10290876 140727794619072 140727794618200 139820002159065 0 0 128 29187 18446744071580840381 0 0 17 0 0 0 346 0 0 0 0 0 0 0 376490 0 0 0

$ sudo ps aux | egrep "cpanellogd|cpsrvd"
root      376490  0.0  0.0 104752 14160 ?        S    Mar21  13:47 cpsrvd (SSL) - waiting f --llu=1458644101 --listen=10,11,4,5,6,7,8,9
root      377073  0.0  0.0  21324  1668 ?        SN   Mar21   0:05 cpanellogd - sleeping for logs
@sparrc
Copy link
Contributor

sparrc commented Apr 5, 2016

what OS are you on?

@sparrc sparrc added the bug unexpected problem or unintended behavior label Apr 5, 2016
@sparrc
Copy link
Contributor

sparrc commented Apr 5, 2016

it's actually the spaces that are the problem, I didn't realize those were possible. I will need to change the way we parse the stat file.

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

Successfully merging a pull request may close this issue.

2 participants