ps_mem (메모리 사용량 확인)

2023. 8. 29. 09:46·Linux

ps_mem

프로그램(프로세스)의  메모리 사용량을 확인하는 유틸리티(Python 스크립트)

 

 

설치

  • CentOS 7.9
# yum install ps_mem
  • Ubuntu 20.04 
# pip3 install ps_mem
Collecting ps_mem
  Downloading ps_mem-3.14-py2.py3-none-any.whl (19 kB)
Installing collected packages: ps-mem
Successfully installed ps-mem-3.14

apt 를 통한 설치는 안되며, pip3를 통한 설치 또는 GitHub 에서 스크립트 파일을 다운로드 받아 사용 가능

# wget -qO /usr/local/bin/ps_mem https://raw.githubusercontent.com/pixelb/ps_mem/master/ps_mem.py
# chmod a+x /usr/local/bin/ps_mem
# ln -s /usr/bin/python3 /usr/bin/python

 

사용법

# ps_mem
 Private  +   Shared  =  RAM used       Program

984.0 KiB + 782.5 KiB =   1.7 MiB       su
  2.4 MiB +   4.5 KiB =   2.4 MiB       agetty
  3.2 MiB +   0.5 KiB =   3.2 MiB       ip
  3.4 MiB +   0.5 KiB =   3.4 MiB       atd
  4.3 MiB +  32.5 KiB =   4.3 MiB       cron
  4.6 MiB +   1.0 KiB =   4.6 MiB       sh (2)
   ... 중략 ...
 30.3 MiB +  73.9 MiB = 104.1 MiB       apache2 (11)
 47.3 MiB +  59.9 MiB = 107.2 MiB       systemd-journald
124.8 MiB + 328.0 KiB = 125.1 MiB       zabbix_agentd (6)
179.8 MiB +  48.0 KiB = 179.9 MiB       klnagent (2)
439.9 MiB + 351.5 KiB = 440.3 MiB       kesl
---------------------------------
                          1.4 GiB
=================================

 

사용 프로그램 정보를 상세히 확인

# ps_mem -s
 Private  +   Shared  =  RAM used       Program

984.0 KiB + 818.5 KiB =   1.8 MiB       su -
  2.3 MiB +   0.5 KiB =   2.3 MiB       sh -c ip monitor address 2> /dev/null
  2.4 MiB +   4.5 KiB =   2.4 MiB       /sbin/agetty -o -p -- \u --noclear tty1 linux
  3.2 MiB +   0.5 KiB =   3.2 MiB       ip monitor address
  3.4 MiB +   0.5 KiB =   3.4 MiB       /usr/sbin/atd -f
 20.6 MiB +  63.5 KiB =  20.7 MiB       /usr/sbin/zabbix_agentd --foreground
 20.6 MiB +  62.5 KiB =  20.7 MiB       /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
 20.7 MiB +  50.5 KiB =  20.8 MiB       /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
 20.7 MiB +  50.5 KiB =  20.8 MiB       /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
 20.7 MiB +  50.5 KiB =  20.8 MiB       /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
... 생략 ...

 

w 옵션을 사용하여 자동 갱신 가능

# ps_mem -s -w 5

 

옵션 참고

# ps_mem --help
usage: ps_mem [-h] [--version] [-s] [-t] [-d] [-S] [-p <pid>[,pid2,...pidN]] [-w <N>]

Show program core memory usage.

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -s, --split-args      Show and separate by, all command line arguments
  -t, --total           Show only the total value
  -d, --discriminate-by-pid
                        Show by process rather than by program
  -S, --swap            Show swap information
  -p <pid>[,pid2,...pidN]
                        Only show memory usage PIDs in the specified list
  -w <N>                Measure and show process memory every N seconds
저작자표시 비영리 변경금지 (새창열림)
'Linux' 카테고리의 다른 글
  • Rocky Linux (CentOS 종료에 따른 대안)
  • hdparm (디스크 정보 확인 및 성능 테스트)
  • 메모리 캐시에 저장 된 파일 확인
  • 메모리 확인 - free
기억보다는 기록을...
기억보다는 기록을...
내가 보려고 정리하는 글..
  • 기억보다는 기록을...
    메모장
    기억보다는 기록을...
    • 분류 전체보기
      • 클라우드(Azure, AWS)
      • 모니터링(Zabbix,Grafana)
      • 가상화(VMWare, Hyper-V)
      • Docker
      • Ansible
      • Linux
      • Windows
      • 이것저것
      • SQL
      • -------------------------
      • 재테크
  • 전체
    오늘
    어제
  • hELLO· Designed By정상우.v4.10.2
기억보다는 기록을...
ps_mem (메모리 사용량 확인)
상단으로

티스토리툴바