[Linux] Get Linux resource information

This is a personal memo. It will be updated from time to time as it has not been organized yet. (Operation check is centos 7.6)

=======================================================================

● General

top

======================================================================= ●CPU

cat /proc/cpuinfo

(Excerpt) CPU model number model name : Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (Excerpt) Number of CPUs recognized by the OS (logical number) processor : 0 processor : 1

● Memory

The entire

○free

free -m

-m Display display results in megabytes. -s number of seconds Displayed every specified number of seconds. -t Also show total physical memory and snaps.

vmstat -n -S m
○ More detailed confirmation
cat /proc/meminfo

MemTotal: 8069288 kB All physical memory recognized by the kernel MemFree: 6269572 kB Memory not used for any purpose

---------------------------------------------
 |            Buffers / Cached               | 
---------------------------------------------
 | Active(file) / Inactive(file) |   Shmem   |
---------------------------------------------

Buffers + Cached = Active(file) + Inactive(file) + Shmem

--------------------------------------------------
 |           Active(anon) + Inactive(anon)        | 
--------------------------------------------------
 |   Shmem   |          AnonPages              |??|
--------------------------------------------------

Active(anon) + Inactive(anon) = Shmem + AnonPages

-----------------------------------------------------------------------------
 |            Buffers / Cached               |           AnonPages        |??|
-----------------------------------------------------------------------------
 | Active(file) + Inactive(file) |        Active(anon) + Inactive(anon)      | 
-----------------------------------------------------------------------------
 |                               |   Shmem   |                               |
-----------------------------------------------------------------------------

---------------------------------------------------------------------------------
 |            Buffers / Cached           |        AnonPages                   |??|
---------------------------------------------------------------------------------
 | Active(file) + Inactive(file)  | Unevictalbe |  Active(anon) + Inactive(anon) |
---------------------------------------------------------------------------------

For each process

○ ps (reference level?)

ps is not the actual memory usage of the process The amount of real memory that each process occupies when there is only one running process. (Usually dozens of processes run)

[How to measure actual memory usage of an application or process?][m1] [m1]:https://stackoverflow.com/questions/131303/how-to-measure-actual-memory-usage-of-an-application-or-process

ps aux
 ps aux | grep postgre | awk '{sum += $6}END{print sum}'

Name Meaning VSZ (virtual set size) virtual memory RSS (Resident set size) Physical memory consumption Memory that the PSS (proportional set size) process actually owns USS (unique set size) Memory occupied by one process

○pmap -x Address space mapping information and amount of memory allocation

pmap -x <PID>

pmap -x 7876 7876: python3 Address Kbytes RSS Dirty Mode Mapping 0000000000400000 4 0 0 r-x-- python3.6 0000000000601000 4 4 4 r---- python3.6 0000000000602000 4 4 4 rw--- python3.6

○cat /proc//smaps

 ps -ef | grep [process name you want to check]
cat /proc/<pid>/smaps

cat /proc/7876/smaps 00400000-00401000 r-xp 00000000 fd:00 55039406 /usr/bin/python3.6 Size: 4 kB Rss: 0 kB Pss: 0 kB Shared_Clean: 0 kB Shared_Dirty: 0 kB Private_Clean: 0 kB Private_Dirty: 0 kB Referenced: 0 kB Anonymous: 0 kB AnonHugePages: 0 kB Swap: 0 kB KernelPageSize: 4 kB MMUPageSize: 4 kB Locked: 0 kB

Shared_Clean and Shared_Dirty are values shared with other processes The total of Private_Clean and Private_Dirty is the memory area allocated by each process.

 cat /proc/<PID>/smaps | egrep 'Private_Clean|Private_Dirty' | awk '{sum += $2}END{print sum}'
cat /proc/1111/smaps | awk '/^Rss/{sum += $2}END{print sum}'
cat /proc/1111/smaps | awk '/^Pss/{sum += $2}END{print sum}'

======================================================================

● Storage (capacity)

⇒ Capacity Physical storage Check the recognized device and its capacity

fdisk -l

Check partition capacity and file system

df -Th

What and how much space is being consumed in the mount directory

du -k

File unit

ls -l

● Storage (I / O) ○ Total of all I / O to all devices

vmstat

○ I / O reporting for each device Checking IOPS

iostat
cat /proc/diskstats
Bandwidth
iotop

blktrace 

=======================================================================

● Network

○ IP address

ip -4 a

○ Routing table

route -rn
/proc/net/route

○ Communication

ping
nc -vz [ip] [port]

○ Number of bytes / packets sent / received, number of discarded packets, number of error packets

ifconfig
/proc/net/dev
/sys/class/net/$INTERFACE/statistics

○ Confirm in seconds iftop ifstat

○ Check network link-up status and recognition speed

ethtool
mii-tool

○ Confirmation of NIC used Check for each NIC and check which NIC is displayed

tcpdump -n -i eth0 dst port 9403 or src port 9403
tcpdump -n -i lo dst port 9403 or src port 9403

=======================================================================

● Device

lspci

● Environment variables

Confirmation of environment variables recognized by PID

/proc/<PID>/environ

Recommended Posts

[Linux] Get Linux resource information
[google-oauth] Get user information
Get information with zabbix api
Get GitHub information using PyGithub
Get Alembic information with Python
Get video file information with ffmpeg-python
Linux
Get weather information with Python & scraping
Get property information by scraping with python
Get delay information on Twitter and tweet
Recursively get FTP directory on UNIX / LINUX
Get BITCOIN LTP information with Raspberry PI
[Python] Get Python package information with PyPI API
How to get started with laravel (Linux)
Get coincheck virtual currency information with API ♪