(轉)Python運維自動化psutil 模塊詳解(超級詳細)


原文:https://cxybb.com/article/sj349781478/117815765

psutil 模塊
參考官方文檔:https://pypi.org/project/psutil/

一、psutil簡介
psutil是一個開源且跨平台(http://code.google.com/p/psutil/)的庫,能夠輕松實現**獲取系統運行的進程和系統利用率(包括CPU、內存、磁盤、網絡等)信息。它主要應用於系統監控,分析和限制系統資源及進程的管理。它實現了同等命令行工具提供的功能,**如ps、top、lsof、netstat、ifconfig、who、df、kill、free、nice、ionice、iostat、iotop、uptime、pidof、tty、taskset、pmap等。

在Python中獲取系統信息的另一個好辦法是使用psutil這個第三方模塊。還可以跨平台使用,支持Linux/UNIX/OSX/Windows等,是系統管理員和運維小伙伴不可或缺的必備模塊。

Works with Python versions from 2.4 to 3.X.

二、安裝psutil模塊
CentOS安裝psutil模塊:
psutil版本:5.8
 wget https://pypi.python.org/packages/source/p/psutil/psutil-5.8.0.tar.gz
tar zxvf psutil-5.8.0.tar.gz  
cd psutil-5.8.0
yum -y install python-devel  (如果提示缺少python.h頭文件,執行此命令。)
python setup.py install
 
Windos安裝psutil模塊:
 
root@shawn:~# pip3 install psutil
Collecting psutil
  Downloading psutil-5.8.0-cp38-cp38-manylinux2010_x86_64.whl (296 kB)
     |████████████████████████████████| 296 kB 20 kB/s 
Installing collected packages: psutil
Successfully installed psutil-5.8.0


三、使用psutil模塊
1.獲取CPU信息:
1.1使用psutil.cpu_times()方法
使用psutil.cpu_times()獲取CPU的完整信息
>>> import psutil
>>> psutil.cpu_times()
scputimes(user=733.23, nice=2.62, system=122.87, idle=19414.35, iowait=29.46, irq=0.0, softirq=34.18, steal=0.0, guest=0.0, guest_nice=0.0)

獲取單個數據,如cpu分配在用戶程序上的執行時間(時間片)或io等待時間。
>>> psutil.cpu_times().user
793.19
>>> psutil.cpu_times().iowait
31.79

時間片的概念詳解百度百科:https://baike.baidu.com/item/%E6%97%B6%E9%97%B4%E7%89%87/6525414?fr=aladdin

psutil.cpu_times(percpu=False)解釋說明:
以元組的形式返回系統CPU時間。每個屬性代表CPU在給定模式下花費的秒數。屬性可用性取決於平台:

user: 從系統啟動開始累積到當前時刻,處於用戶態的運行時間,不包含 nice 值為負的進程。
system: 從系統啟動開始累積到當前時刻,處於核心態的運行時間。
idle: 從系統啟動開始累積到當前時刻,除 IO 等待時間以外的其他等待時間(空閑時間)。
特定於平台的字段:

nice (UNIX): 系統啟動開始累積到當前時刻,nice 值為負的進程所占用的 CPU 時間。Nice值是類UNIX操作系統中表示靜態優先級的數值。 每個進程都有自己的靜態優先級,優先級高的進程得以優先運行。
iowait (Linux): 從系統啟動開始累積到當前時刻,IO 等待時間。
irq (Linux, BSD): 從系統啟動開始累積到當前時刻,服務中斷時間
softirq (Linux): 從系統啟動開始累積到當前時刻,軟中斷時間
steal (Linux 2.6.11+): 從系統啟動開始累積到當前時刻,在虛擬環境運行時花費在其他操作系統的時間
guest (Linux 2.6.24+):從系統啟動開始累積到當前時刻,在Linux內核控制下的操作系統虛擬cpu花費的時間。
guest_nice (Linux 3.2.0+): 從系統啟動開始累積到當前時刻,在Linux內核控制下的操作系統虛擬cpu花費在nice進程上的時間。
interrupt (Windows):從系統啟動開始累積到當前時刻,服務硬件中斷所花費的時間(類似於UNIX上的“ irq”)
dpc (Windows): 為延遲過程調用(DPC)提供服務所花費的時間;DPC是以低於標准中斷的優先級運行的中斷。
參考文檔:

Return system CPU times as a named tuple. Every attribute represents the seconds the CPU has spent in the given mode. The attributes availability varies depending on the platform:

user: time spent by normal processes executing in user mode; on Linux this also includes guest time
system: time spent by processes executing in kernel mode
idle: time spent doing nothing
Platform-specific fields:

nice (UNIX): time spent by niced (prioritized) processes executing in user mode; on Linux this also includes guest_nice time
iowait (Linux): time spent waiting for I/O to complete
irq (Linux, BSD): time spent for servicing hardware interrupts
softirq (Linux): time spent for servicing software interrupts
steal (Linux 2.6.11+): time spent by other operating systems running in a virtualized environment
guest (Linux 2.6.24+): time spent running a virtual CPU for guest operating systems under the control of the Linux kernel
guest_nice (Linux 3.2.0+): time spent running a niced guest (virtual CPU for guest operating systems under the control of the Linux kernel)
interrupt (Windows): time spent for servicing hardware interrupts ( similar to “irq” on UNIX)
dpc (Windows): time spent servicing deferred procedure calls (DPCs); DPCs are interrupts that run at a lower priority than standard interrupts.

1.2psutil.cpu_count()獲取CPU個數
使用psutil.cpu_count()獲取CPU邏輯個數
#cpu_count(,[logical]):默認返回邏輯CPU的個數,當設置logical的參數為False時,返回物理CPU的個數。

>>> psutil.cpu_count()

使用psutil.cpu_count(logical=False)獲取CPU的物理個數,默認logical值為True

>>> psutil.cpu_count(logical=False)
8

1.3psutil.getloadavg()獲取平均系統負載
使用psutil.getloadavg()可以獲取平均系統負載,會以元組的形式返回最近1、5和15分鍾內的平均系統負載。
 在Windows上,這是通過使用Windows API模擬的,該API產生一個線程,該線程保持在后台運行,並每5秒更新一次結果,從而模仿UNIX行為。 因此,在Windows上,第一次調用此方法,在接下來的5秒鍾內,它將返回無意義的(0.0,0.0,0.0)元組。

>>> psutil.getloadavg()
(1.22, 1.41, 1.38)


1.4、psutil.cpu_percent()獲取CPU使用率
cpu_percent(,[percpu],[interval]):返回CPU的利用率
interval:指定的是計算cpu使用率的時間間隔,interval不為0時,則阻塞時顯示interval執行的時間內的平均利用率

percpu:指定是選擇總的使用率或者每個cpu的使用率,percpu為True時顯示所有物理核心的利用率

1.指定的是計算cpu使用率的時間間隔
>>> for x in range(10):
...     psutil.cpu_percent(interval=1)
... 
2.4
2.5
2.7
2.3
2.5
2.2
2.0
2.2
2.4
2.2

2.實現類似top命令的CPU使用率,每秒刷新一次,累計10次:
>>> for x in range(10):
...     psutil.cpu_percent(interval=1,percpu=True)
... 
[1.0, 3.1, 5.0, 4.0, 0.0, 4.0, 3.0, 2.0]
...
[1.0, 1.0, 6.1, 3.1, 2.0, 2.1, 0.0, 0.0]
[2.0, 1.0, 6.0, 4.9, 1.0, 5.1, 1.0, 1.0]

1.5psutil.cpu_stats()獲取CPU的統計信息
cpu_stats()以命名元組的形式返回CPU的統計信息,包括上下文切換,中斷,軟中斷和系統調用次數。

>>> psutil.cpu_stats()
scpustats(ctx_switches=3928927, interrupts=2319133, soft_interrupts=1974116, syscalls=0)


1.6、psutil.cpu_freq()獲取CPU頻率
cpu_freq([percpu]):返回cpu頻率
>>> psutil.cpu_freq()
scpufreq(current=1799.999, min=0.0, max=0.0)


1.7、psutil.cpu_times_percent()獲取耗時比例
cpu_times_percent(,[percpu]):功能和cpu_times大致相同,看字面意思就能知道,該函數返回的是耗時比例。
>>> psutil.cpu_times_percent()
scputimes(user=0.1, nice=0.0, system=0.0, idle=99.9, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)


2.獲取內存信息
2.1psutil.virtual_memory()內存使用情況
psutil.virtual_memory():獲取系統內存的使用情況,以命名元組的形式返回內存使用情況,包括總內存,可用內存,內存利用率,buffer和cache等。單位為字節。
獲取內存的完整信息
>>> psutil.virtual_memory()
svmem(total=2028425216, available=982532096, percent=51.6, used=861827072, free=810414080, active=401735680, inactive=431902720, buffers=4096, cached=356179968, shared=9203712, slab=236351488)
'''
返回的是字節Byte為單位的整數
重點關注的參數是:
    1.total表示內存總的大小
    2.percent表示實際已經使用的內存占比。
    3.available表示還可以使用的內存。
    4.uused表示已經使用的內存
'''

使用total獲取內存總大小
>>> psutil.virtual_memory().total
2028425216

使用獲取已經使用的內存
>>> psutil.virtual_memory().used
865882112

使用free獲取剩余的內存
>>> psutil.virtual_memory().free
805871616




2.2 psutil.swap_memory()獲取系統交換內存(swap)的統計信息
psutil.swap_memory():獲取系統交換內存的統計信息,以命名元組的形式返回swap/memory使用情況,包含swap中頁的換入和換出。
獲取交換分區相關
>>> psutil.swap_memory()
sswap(total=4091539456, used=173793280, free=3917746176, percent=4.2, sin=23683072, sout=188874752)


3.獲取磁盤相關
磁盤信息主要兩部分,一個是磁盤的利用率,一個是io。

3.1、psutil.disk_partitions()獲取磁盤分區信息
disk_partitions([all=False]):以命名元組的形式返回所有已掛載的磁盤,包含磁盤名稱,掛載點,文件系統類型等信息。

當all等於True時,返回包含/proc等特殊文件系統的掛載信息

獲取磁盤分區的信息
>>> psutil.disk_partitions()
[sdiskpart(device='/dev/sda3', mountpoint='/', fstype='xfs', opts='rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota', maxfile=255, maxpath=4096), sdiskpart(device='/dev/loop1', mountpoint='/snap/core18/1944', fstype='squashfs', opts='ro,nodev,relatime', maxfile=256, maxpath=4096),。...sdiskpart(device='/dev/loop6', mountpoint='/snap/snap-store/467', fstype='squashfs', opts='ro,nodev,relatime', maxfile=256, maxpath=4096), sdiskpart(device='/dev/sda1', mountpoint='/boot', fstype='xfs', opts='rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota', maxfile=255, maxpath=4096)]


>>> io = psutil.disk_partitions()
>>> print(io[-1])
sdiskpart(device='/dev/sr0', mountpoint='/media/shawn/Ubuntu 20.04.1 LTS amd64', fstype='iso9660', opts='ro,nosuid,nodev,relatime,nojoliet,check=s,map=n,blocksize=2048,uid=1000,gid=1000,dmode=500,fmode=400', maxfile=255, maxpath=4096)
>>> 

3.2、psutil.disk_usage()獲取路徑所在磁盤的使用情況
disk_usage(path):以命名元組的形式返回path所在磁盤的使用情況,包括磁盤的容量、已經使用的磁盤容量、磁盤的空間利用率等。
獲取根分區的使用情況
>>> psutil.disk_usage('/')
sdiskusage(total=101184290816, used=8805330944, free=92378959872, percent=8.7)
>>> 

3.3、disk_io_counters獲取io統計信息
disk_io_counters([perdisk]):以命名元組的形式返回磁盤io統計信息(匯總的),包括讀、寫的次數,讀、寫的字節數等。
當perdisk的值為True,則分別列出單個磁盤的統計信息(字典:key為磁盤名稱,value為統計的namedtuple)。
獲取磁盤總的io個數,讀寫信息
>>> psutil.disk_io_counters()
sdiskio(read_count=60919, write_count=448417, read_bytes=1582292480, write_bytes=31438750208, read_time=50157, write_time=259374, read_merged_count=2527, write_merged_count=44226, busy_time=1096900)

'''補充說明
read_count(讀IO數)
write_count(寫IO數)
read_bytes(讀IO字節數)
write_bytes(寫IO字節數)
read_time(磁盤讀時間)
write_time(磁盤寫時間)
'''

獲取單個分區的IO和讀寫信息
>>> psutil.disk_io_counters(perdisk=True)
{'loop0': sdiskio(read_count=43, write_count=0, read_bytes=358400, write_bytes=0, read_time=28, write_time=0, read_merged_count=0, write_merged_count=0, busy_time=44), 'loop1': sdiskio(read_count=424, write_count=0, read_bytes=6236160, write_bytes=0, read_time=277, write_time=0, read_merged_count=0, write_merged_count=0, busy_time=956),... write_merged_count=985, busy_time=1132488)}



4.獲取網絡信息
4.1、psutil.net_io_counter([pernic])獲取網卡io統計信息
psutil.net_io_counter([pernic]):以命名元組的形式返回當前系統中每塊網卡的網絡io統計信息,包括收發字節數,收發包的數量、出錯的情況和刪包情況。當pernic為True時,則列出所有網卡的統計信息。
 獲取網絡讀寫字節/包的個數
>>> psutil.net_io_counters()
snetio(bytes_sent=242309, bytes_recv=6775236, packets_sent=2563, packets_recv=44703, errin=0, errout=0, dropin=9301, dropout=0)


列出所有網卡的統計信息
>>> psutil.net_io_counters(pernic=True)
{'lo': snetio(bytes_sent=38379, bytes_recv=38379, packets_sent=413, packets_recv=413, errin=0, errout=0, dropin=0, dropout=0), 'ens32': snetio(bytes_sent=203930, bytes_recv=6756079, packets_sent=2150, packets_recv=44430, errin=0, errout=0, dropin=9334, dropout=0)}


4.2、psutil.net_if_addrs()獲取網絡接口信息
psutil.net_if_addrs():以字典的形式返回網卡的配置信息,包括IP地址和mac地址、子網掩碼和廣播地址。
>>> psutil.net_if_addrs()
{'lo': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='127.0.0.1', netmask='255.0.0.0', broadcast=None, ptp=None), snicaddr(family=<AddressFamily.AF_INET6: 10>, address='::1', netmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', broadcast=None, ptp=None), snicaddr(family=<AddressFamily.AF_PACKET: 17>, address='00:00:00:00:00:00', netmask=None, broadcast=None, ptp=None)], 'ens32': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='192.168.12.154', netmask='255.255.255.0', broadcast='192.168.12.255', ptp=None), snicaddr(family=<AddressFamily.AF_INET6: 10>, address='fe80::1c00:63d1:f5bf:1cec%ens32', netmask='ffff:ffff:ffff:ffff::', broadcast=None, ptp=None), snicaddr(family=<AddressFamily.AF_PACKET: 17>, address='00:0c:29:7a:81:66', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)]}


4.3、psutil.net_if_stats()獲取網絡接口狀態信息
psutil.net_if_stats():返回網卡的詳細信息,包括是否啟動、通信類型、傳輸速度與mtu。
>>> psutil.net_if_stats()
{'lo': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=0, mtu=65536), 'ens32': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_FULL: 2>, speed=1000, mtu=1500)}


4、4、psutil.net_connections():獲取當前網絡連接信息
psutil.net_connections():以列表的形式返回,獲取當前網絡連接信息
>>> psutil.net_connections()
Traceback (most recent call last):
  ...
PermissionError: [Errno 1] Operation not permitted
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  ...
psutil.AccessDenied: psutil.AccessDenied (pid=3847)
    
你可能會得到一個AccessDenied錯誤,原因是psutil獲取信息也是要走系統接口,而獲取網絡連接信息需要root權限,這種情況下,可以退出Python交互環境,用sudo重新啟動:

$ sudo python3
Password: ******
Python 3.6.3 ... on darwin
Type "help", ... for more information.
>>> import psutil
>>> psutil.net_connections()
[
    sconn(fd=83, family=<AddressFamily.AF_INET6: 30>, type=1, laddr=addr(ip='::127.0.0.1', port=62911), raddr=addr(ip='::127.0.0.1', port=3306), status='ESTABLISHED', pid=3725),
    sconn(fd=84, family=<AddressFamily.AF_INET6: 30>, type=1, laddr=addr(ip='::127.0.0.1', port=62905), raddr=addr(ip='::127.0.0.1', port=3306), status='ESTABLISHED', pid=3725),
    sconn(fd=93, family=<AddressFamily.AF_INET6: 30>, type=1, laddr=addr(ip='::', port=8080), raddr=(), status='LISTEN', pid=3725),
    sconn(fd=103, family=<AddressFamily.AF_INET6: 30>, type=1, laddr=addr(ip='::127.0.0.1', port=62918), raddr=addr(ip='::127.0.0.1', port=3306), status='ESTABLISHED', pid=3725),
    sconn(fd=105, family=<AddressFamily.AF_INET6: 30>, type=1, ..., pid=3725),
    sconn(fd=106, family=<AddressFamily.AF_INET6: 30>, type=1, ..., pid=3725),
    sconn(fd=107, family=<AddressFamily.AF_INET6: 30>, type=1, ..., pid=3725),
    ...
    sconn(fd=27, family=<AddressFamily.AF_INET: 2>, type=2, ..., pid=1)
]



4.5psutil.net_connections()網絡連接的詳細信息
psutil.net_connections([kind]):以列表的形式返回每個網絡連接的詳細信息(namedtuple)。命名元組包含fd, family, type, laddr, raddr, status, pid等信息。kind表示過濾的連接類型,支持的值如下:(默認為inet)
inet 代表 IPv4 and IPv6
>>> psutil.net_connections(kind='inet')
[sconn(fd=-1, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='192.168.12.154', port=58478)...sconn(fd=-1, family=<AddressFamily.AF_INET6: 10>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='::1', port=631), raddr=(), status='LISTEN', pid=None)]
>>> 


'/dev/pts/1'

>>> p.open_files() # 進程打開的文件
[]

>>> p.environ() # 進程環境變量
{'SHELL': '/bin/bash', 'PATH': '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:...', 'PWD': '/Users/michael', 'LANG': 'zh_CN.UTF-8', ...}

>>> p.terminate() # 發送SIGTEAM信號結束進程
Terminated: 15 
    
>>> p.kill()    #發送SIGKILL信號結束進程
>>> 已殺死

>>> p.is_running() #進程是否在運行
True

>>> p.num_fds()    #進程打開的文件個數
4

>>> p.is_running()    #判斷進程是否正在運行
True



popen方法的使用:獲取(跟蹤)用戶啟動的應用程序進程信息

>>> import psutil
>>> from subprocess import PIPE
>>> p = psutil.Popen(["/usr/bin/python3", "-c", "print('hello')"],stdout=PIPE)
>>> p.name()
'python3'
>>> p.username()
'shawn'
>>> p.communicate()
(b'hello\n', None)
>>> p.wait(timeout=2)
0


7.其他進程相關的操作
1.psutil.pid_exists判斷給點定的pid是否存在
>>> psutil.pid_exists(1)
True

2.psutil.process_iter迭代當前正在運行的進程,返回的是每個進程的Process對象

>>> psutil.process_iter(8216)
<generator object process_iter at 0x7f48a7275040>


8.psutil模塊的其他補充:
psutil還提供了一個test()方法,可以模擬出ps命令的效果:

>>> import psutil
>>> psutil.test()
USER         PID  %MEM     VSZ     RSS  NICE STATUS  START   TIME  CMDLINE
root           1   0.6  164.9M   11.4M        sleep  18:15  01:01  /sbin/init s
root           2   0.0    0.0B    0.0B        sleep  18:15  00:00  kthreadd
 ...
root        7896   0.0    0.0B    0.0B         idle  21:55  00:00  kworker/u256
shawn       7904   1.5   49.2M   29.1M        runni  21:58  00:00  python3
>>> 



Windows services:獲取windows的服務

>>> list(psutil.win_service_iter())
[<WindowsService(name='AeLookupSvc', display_name='Application Experience') at 38850096>,
 <WindowsService(name='ALG', display_name='Application Layer Gateway Service') at 38850128>,
 <WindowsService(name='APNMCP', display_name='Ask Update Service') at 38850160>,
 <WindowsService(name='AppIDSvc', display_name='Application Identity') at 38850192>,
 ...]

>>> psutil.win_service_get('alg')
<WindowsService(name='alg', display_name='Application Layer Gateway Service') at 2325310212128>

>>> s = psutil.win_service_get('alg')
>>> s.as_dict()
{'binpath': 'C:\\Windows\\System32\\alg.exe',
 'description': 'Provides support for 3rd party protocol plug-ins for Internet Connection Sharing',
 'display_name': 'Application Layer Gateway Service',
 'name': 'alg',
 'pid': None,
 'start_type': 'manual',
 'status': 'stopped',
 'username': 'NT AUTHORITY\\LocalService'}


四、編寫獲取系統硬件腳本
'''
script_info:檢測系統硬件腳本
Edition:v0.0.1
'''
# !/usr/bin/env python
# coding:utf-8

import psutil
import datetime
import time

# 當前時間
now_time = time.strftime('%Y-%m-%d-%H:%M:%S', time.localtime(time.time()))
print(now_time)

# 查看cpu物理個數的信息
print(u"物理CPU個數: %s" % psutil.cpu_count(logical=False))

# cpu的使用率
cpu = (str(psutil.cpu_percent(1))) + '%'
print("cup使用率: %s" % cpu)

# 查看內存信息,剩余內存.free  總共.total
# round()函數方法為返回浮點數x的四舍五入值。
free = str(round(psutil.virtual_memory().free / (1024.0 * 1024.0 * 1024.0), 2))
total = str(round(psutil.virtual_memory().total / (1024.0 * 1024.0 * 1024.0), 2))
memory = int(psutil.virtual_memory().total - psutil.virtual_memory().free) / float(psutil.virtual_memory().total)
print("物理內存: %s G" % total)
print("剩余物理內存: %s G" % free)
print("物理內存使用率: %s %%" % int(memory * 100))

# 獲取系統啟動時間
print("系統啟動時間: %s" % datetime.datetime.fromtimestamp(psutil.boot_time()).strftime("%Y-%m-%d %H:%M:%S"))

# 獲取系統用戶
users_count = len(psutil.users())
users_list = ",".join([u.name for u in psutil.users()])
print("當前有%s個用戶,分別是 %s" % (users_count, users_list))

# 獲取網卡信息,可以得到得到網卡屬性,連接數,當前數據等信息
net = psutil.net_io_counters()
bytes_sent = '{0:.2f} Mb'.format(net.bytes_recv / 1024 / 1024)
bytes_rcvd = '{0:.2f} Mb'.format(net.bytes_sent / 1024 / 1024)
print("網卡接收數據 %s 網卡發送數據 %s" % (bytes_rcvd, bytes_sent))

# 獲取磁盤數據信息
io = psutil.disk_partitions()
print('-----------------------------磁盤信息---------------------------------------')


for i in io:
    try:
        o = psutil.disk_usage(i.device)
        print("總容量:" + str(int(o.total / (1024.0 * 1024.0 * 1024.0))) + "G")
        print("已用容量:" + str(int(o.used / (1024.0 * 1024.0 * 1024.0))) + "G")
        print("可用容量:" + str(int(o.free / (1024.0 * 1024.0 * 1024.0))) + "G")
    except PermissionError:
        continue
print('-----------------------------進程信息-------------------------------------')

# 查看系統全部進程
for pnum in psutil.pids():
    p = psutil.Process(pnum)
    print(
        "進程名 %-20s  內存利用率 %-18s 進程狀態 %-10s 創建時間 %-10s " % (p.name(), p.memory_percent(), p.status(), p.create_time()))



五、參考資料
https://www.liaoxuefeng.com/wiki/1016959663602400/1183565811281984
https://pypi.org/project/psutil/
https://www.cnblogs.com/billie52707/p/12468740.html
https://www.zhihu.com/question/278027418/answer/397277169
https://psutil.readthedocs.io/en/latest/
————————————————


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM