全部 新建

user:thomas 由使用者建立的 Gists

title:mygist Gists 的標題

filename:myfile.txt Gists 的檔案名稱

extension:yml Gists 的副檔名

language:go Gists 的程式語言

topic:homelab gists with given topic

登錄


全部 新建 登錄

All gists matching topic disk

倒序排序 創建
順序排序 創建
倒序排序 更新
順序排序 更新

timmy / 使用 psutil 監控系統資源

0 喜歡
0 分支
1 檔案
最後活躍 9 months ago
psutil 模組可用於獲取 CPU、記憶體、磁碟、網路、進程等系統資源資訊,適用於系統監控、效能分析與資源管理工具。
cpu disk memory network process psutil python system-monitoring
1 import psutil
2
3 # 獲取 CPU 使用率
4 cpu_usage = psutil.cpu_percent(interval=1)
5 print(f"CPU 使用率: {cpu_usage}%")
6
7 # 獲取記憶體資訊
8 memory_info = psutil.virtual_memory()
9 print(f"總記憶體: {memory_info.total / (1024**3):.2f} GB")
10 print(f"可用記憶體: {memory_info.available / (1024**3):.2f} GB")
上一頁 下一頁

由 Opengist 提供支持 ⋅ Load: 25ms⋅

繁體中文
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文