>>> import psutil 获取cpu信息>>> psutil.cpu_times()scputimes(user=128258.38, nice=12.29, system=88369.31, idle=6713420.33, iowait=3290.63, irq=1069.04, softirq=3368.56, steal=0.0, guest=0.0) >>> psutil.cpu_times().idle 6717807.87 获取cpu百分比信息>>> psutil.cpu_times_percent() scputimes(user=3.0, nice=0.0, system=2.0, idle=94.8, iowait=0.1, irq=0.0, softirq=0.1, steal=0.0, guest=0.0) 获取内存信息>>> psutil.virtual_memory() svmem(total=4019073024L, available=2577477632L, percent=35.9, used=2648985600L, free=1370087424L, active=1565192192, inactive=904339456, buffers=375177216L, cached=832212992)
更多api:https://pypi.python.org/pypi/psutil/
python使用psutil获取服务器信息,布布扣,bubuko.com
时间: 2024-10-29 02:43:34