没有合适的资源?快使用搜索试试~ 我知道了~
获得进程内存使用量的python脚本.pdf
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 6 浏览量
2022-01-25
06:55:51
上传
评论
收藏 20KB PDF 举报
温馨提示
试读
19页
获得进程内存使用量的python脚本.pdf
资源推荐
资源详情
资源评论
获得进程内存使用量的 python 脚本
获得进程内存使用量的 Python 脚本
# Try to determine how much RAM is currently being used per program.
# Note per _program_, not per process. So for example this script
# will report RAM used by all httpd process together. In detail it
reports:
# sum(private RAM for program processes) + sum(Shared RAM for
program processes)
# The shared RAM is problematic to calculate, and this script
automatically
# selects the most accurate method available for your kernel.
# Licence: LGPLv2
# Author: P@draigBrady.com
# Source:
# V1.0 06 Jul 2005 Initial release
# V1.1 11 Aug 2006 root permission required for accuracy
# V1.2 08 Nov 2006 Add total to output
# Use KiB,MiB,... for units rather than K,M,...
# V1.3 22 Nov 2006 Ignore shared col from /proc/$pid/statm for
# 2.6 kernels up to and including 2.6.9.
# There it represented the total file backed extent
# V1.4 23 Nov 2006 Remove total from output as it ’s meaningless
# (the shared values overlap with other programs).
# Display the shared column. This extra info is
# useful, especially as it overlaps between programs.
# V1.5 26 Mar 2007 Remove redundant recursion from human()
# V1.6 05 Jun 2007 Also report number of processes with a given name.
# Patch from riccardo.murri@gmail.com
# V1.7 20 Sep 2007 Use PSS from /proc/$pid/smaps if available, which
# fixes some over-estimation and allows totalling.
# Enumerate the PIDs directly rather than using ps,
# which fixes the possible race between reading
# RSS with ps, and shared memory with this program.
# Also we can show non truncated command names.
# V1.8 28 Sep 2007 More accurate matching for stats in
/proc/$pid/smaps
# as otherwise could match libraries causing a crash.
# Patch from patrice.bouchand.fedora@gmail.com
# V1.9 20 Feb 2008 Fix invalid values reported when PSS is available.
# Reported by Andrey Borzenkov arvidjaar@mail.ru
# V3.3 24 Jun 2014
#
# Notes:
# All interpreted programs where the interpreter is started
# by the shell or with env, will be merged to the interpreter
# (as that ’s what ’s given to exec). For e.g. all python programs
# starting with #!/usr/bin/env python will be grouped under python.
# You can change this by using the full command line but that will
# have the undesirable affect of splitting up programs started with
# differing parameters (for e.g. mingetty tty[1-6]).
# For 2.6 kernels up to and including 2.6.13 and later 2.4 redhat
kernels
# (rmap vm without smaps) it can not be accurately determined how
many pages
# are shared between processes in general or within a program in our
case:
#
# A warning is printed if overestimation is possible.
# In addition for 2.6 kernels up to 2.6.9 inclusive, the shared
# value in /proc/$pid/statm is the total file-backed extent of a
process.
# We ignore that, introducing more overestimation, again printing a
warning.
# Since kernel 2.6.23-rc8-mm1 PSS is available in smaps, which
allows
# us to calculate a more accurate value for the total RAM used by
programs.
# Programs that use CLONE_VM without CLONE_THREAD are discounted by
assuming
# they ’re the only programs that have the same /proc/$PID/smaps
file for
剩余18页未读,继续阅读
资源评论
qq_35291562
- 粉丝: 3
- 资源: 9万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功