influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.7k stars 5.59k forks source link

Fix (inputs.procstat) Collecting Swap via smaps #15926

Closed Paramadon closed 1 month ago

Paramadon commented 1 month ago

Currently proc.MemoryInfo() claims to collect rss, vms, as well as swap, data, stack, and locked information. This functions reads from /proc/$PID/statm. However the gopsutil function only returns two values, rss and vsm, the first and second value from that file. Additionally, the man page for proc says that instead of statm users should look to smaps or smaps_rollup:

If accurate values are required, use /proc/pid/smaps or /proc/pid/smaps_rollup instead This change will keep rss and vms from the /proc/$PID/statm file and introduce a call to /proc/$PID/smaps

size: total size pss: process's proportional share of this mapping shared_clean/shared_dirty: the number of clean and dirty shared pages in the mapping private_clean/private_dirty: the number of clean and dirty private pages in the mapping referenced: the amount of memory currently marked as referenced or accessed anonymous: the amount of memory that does not belong to any file swap: how much would-be-anonymous memory is also used, but out on swap As the previous values were always zero, users should not have any expectations on the data, stack, or locked fields. This does mean users can now get the swap field as well as the new fields.

fixes: https://github.com/influxdata/telegraf/issues/8557 pr that is similar fix to this: https://github.com/influxdata/telegraf/pull/13779

telegraf-tiger[bot] commented 1 month ago

Thanks so much for the pull request! :handshake: :black_nib: Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla