Skip to content

Support process shared memory monitoring - #353

Open
SilenceAdele wants to merge 1 commit into
ncabatoff:masterfrom
SilenceAdele:321
Open

Support process shared memory monitoring#353
SilenceAdele wants to merge 1 commit into
ncabatoff:masterfrom
SilenceAdele:321

Conversation

@SilenceAdele

@SilenceAdele SilenceAdele commented Jun 18, 2025

Copy link
Copy Markdown
  • Upgrade procfs from v0.14.0 to v0.17.0 to support shared memory collection for process.
  • Implement process shared memory monitoring logic.

@SilenceAdele

Copy link
Copy Markdown
Author

/cc @SuperQ @ncabatoff

* Upgrade procfs from v0.14.0 to v0.17.0 to support
  shared memory collection for process.
* Implement process shared memory monitoring logic.

Signed-off-by: zhiyuan.zhou <zhiyuan.zhou@easystack.cn>
@SilenceAdele

SilenceAdele commented Jan 13, 2026

Copy link
Copy Markdown
Author

Hi, long time no see @SuperQ @ncabatoff
The PR adding support for process shared memory monitoring in process-exporter has been submitted for quite some time. Below is a summary of my investigation and testing results for this PR. I’d appreciate it if you could help review it. If there are any questions or further concerns, please feel free to reach out to me at any time.

  • Summary of Process Memory Metrics in the master branch of process-exporter(Excluding shared memory
Serial Number Related Linux process memory parameters The corresponding file in Linux
1 RSS /proc/[pid]/stat
2 VSize /proc/[pid]/stat
3 VmSwap /proc/[pid]/status
4 Pss /proc/[pid]/smaps_rollup
5 SwapPss /proc/[pid]/smaps_rollup
  • Data sources for process shared memory: /proc/[pid]/status vs /proc/[pid]/statm
image
  1. The proc_pid_statm(5) documentation defines the shared field as the number of shared memory pages.
  2. It further indicates that shared memory can be approximated using RssFile + RssShmem from /proc/[pid]/status, while explicitly warning that these values are not accurate.
  3. If an accurate calculation of process shared memory size is required, it should be derived from the shared field in /proc/[pid]/statm.
Serial Number Related Linux process memory parameters Remark
1 Size  
2 Resident  
3 Shared Used to monitor process shared memory.
4 Text  
5 Lib  
6 Data  
7 Dt  
  • Upgrading procfs from v0.14.0 to v0.17.0 is theoretically assessed to have no impact on the functionality implemented on the process-exporter. The related procfs module changes mainly include bug fixes, new features, and code optimizations.
procfs patch process-exporter refer procfs module Remark
v0.15.0 bugfix: s/TrimRight/TrimSuffix for certain cases by rexagod · Pull Request #618 · prometheus/procfs · GitHub cmdline bugfix
v0.17.0 Parse StartCode, EndCode, and StartStack in Proc.Stat() by pgimalac · Pull Request #659 · prometheus/procfs · GitHub proc_stat feature
v0.16.0 Fix parsing NSpids field in /proc/{PID}/status by timuralp · Pull Request #648 · prometheus/procfs · GitHub proc_status bugfix
  proc_cgroup  
  proc_io  
v0.17.0 Supports collection of process shared memory by SilenceAdele · Pull Request #719 · prometheus/procfs · GitHub proc_statm feature
  proc_limits  
v0.16.0 Forbid print statements by SuperQ · Pull Request #668 · prometheus/procfs · GitHub proc_smaps perf
  fileDescriptors  
  Wchan  
  • A comparison of the metrics output between the master branch and the 321 branch(My PR) of process-exporter shows that the only difference lies in the namedprocess_namegroup_memory_bytes metric, where the 321 branch introduces an additional entry that includes process shared memory. This is consistent with the expected behavior.
# matcher config
process_names:
  - name: "{{.Comm}}-{{.PID}}"
    comm:
      - node

# start command
 go run cmd/process-exporter/main.go -config.path=../conf  --children=false
image
  • The process shared memory reported by process-exporter matches the values reported by the top command, as expected.
image image
  • Based on the above analysis and testing, process-exporter was upgraded to use procfs from v0.14.0 to v0.17.0:
  1. Process-exporter did not exhibit any compatibility issues in its use of procfs after the upgrade.
  2. The newly introduced Shared field from /proc/[pid]/statm in procfs can be used to implement process shared memory metrics.

@SilenceAdele

Copy link
Copy Markdown
Author

ping......

@SilenceAdele SilenceAdele mentioned this pull request Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant