代碼
import psutil print(dir(psutil)) # 查看邏輯cpu的個(gè)數(shù) print(psutil.cpu_count()) # 查看物理cpu的個(gè)數(shù) print(psutil.cpu_count(logical=False)) # 查看cpu的用戶時(shí)間,系統(tǒng)時(shí)間,空閑時(shí)間,中斷時(shí)間 print(psutil.cpu_times()) # 統(tǒng)計(jì)每個(gè)cpu的使用率 print(psutil.cpu_percent(interval=2,percpu=True)) # 統(tǒng)計(jì)真?zhèn)€cpu的使用率 print(psutil.cpu_percent(interval=2,percpu=False)) # 統(tǒng)計(jì)內(nèi)存的使用情況 print(psutil.virtual_memory()) # 統(tǒng)計(jì)某個(gè)磁盤的使用情況 print(psutil.disk_usage(path="d:")) # 統(tǒng)計(jì)磁盤的io情況 print(psutil.disk_io_counters()) # 統(tǒng)計(jì)系統(tǒng)的根目錄的信息,包括device,掛載點(diǎn),文件系統(tǒng)類型 print(psutil.disk_partitions()) # 網(wǎng)卡的io情況 print(psutil.net_io_counters()) # 網(wǎng)卡信息 print(psutil.net_if_addrs()) # 網(wǎng)卡狀態(tài) print(psutil.net_if_stats()) # 網(wǎng)卡的連接情況 print(psutil.net_connections()) # 系統(tǒng)中所有的進(jìn)程 print(psutil.pids()) # 判斷某個(gè)進(jìn)程是否存在 print(psutil.pid_exists(0)) # 獲取某個(gè)進(jìn)程的對(duì)象 p = psutil.Process(436) # 打印該進(jìn)程的名字 print(p.name()) # 打印該進(jìn)程一些信息,比如進(jìn)程名字,id,啟動(dòng)時(shí)間 print(p.cpu_times) # 打印這個(gè)進(jìn)程的占用cpu的使用時(shí)間 print(p.cpu_times()) # 打印這個(gè)進(jìn)程的內(nèi)存使用情況 print(p.memory_info()) # 打印這個(gè)進(jìn)程啟動(dòng)的線程的數(shù)量 print(p.num_threads()) # 打印這個(gè)進(jìn)程開(kāi)啟的線程的信息 print(p.threads())
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
