You can get various information about your PC such as CPU, memory, network, and disk.
psutil.py
# -*- coding: utf-8 -*-
import psutil
#######################################################
# CPU
print psutil.cpu_times()
# scputimes(user=6047.15625, system=2177.09375, idle=41990.640625, interrupt=209.78125, dpc=189.81250381469727)
for x in range(3):
print psutil.cpu_percent(interval=1)
'''
23.0
11.4
3.9
'''
#######################################################
# Memory
print psutil.virtual_memory()
# svmem(total=8506089472L, available=3694571520L, percent=56.6, used=4811517952L, free=3694571520L)
print psutil.swap_memory()
# sswap(total=9848266752L, used=5868003328L, free=3980263424L, percent=59.6, sin=0, sout=0)
#######################################################
# Disks
print psutil.disk_partitions()
# [sdiskpart(device='C:\\', mountpoint='C:\\', fstype='NTFS', opts='rw,fixed')]
print psutil.disk_usage('/')
# sdiskusage(total=249182547968L, used=204373192704L, free=44809355264L, percent=82.0)
print psutil.disk_io_counters(perdisk=False)
# sdiskio(read_count=2375955, write_count=2540319, read_bytes=45541818368L, write_bytes=45088102400L, read_time=10428518880L, write_time=2957835750L)
#######################################################
# Network
print psutil.net_io_counters(pernic=True)
#######################################################
# Windows services
print list(psutil.win_service_iter())
Recommended Posts