5 min,  Information,  Python

5 Min Python WMI perfmon

winstats · PyPI

Memory stats
Performance stats
Disk info, types, and stats
Performance Data Counters (aka PerfMon)

Sample code:

# https://pypi.org/project/winstats/
# pip intsall winstats
import winstats

# Memory Stats:
meminfo = winstats.get_mem_info()
total= meminfo.TotalPhys
total_gb = total / (1024 *1024 *1024) # bytes to GB
usage_per = meminfo.MemoryLoad
print(“GB RAM : ” + str(total_gb))
print(“% Usage RAM: “+ str(usage_per))

# Performance Stats:
pinfo = winstats.get_perf_info()
print(pinfo.SystemCache)
print(pinfo.SystemCacheBytes)

# Disk Stats:
drives = winstats.get_drives()
drive = drives[0]
fsinfo = winstats.get_fs_usage(drive)
vinfo = winstats.get_vol_info(drive)
print(“Disks: ” + str(drives))
print(“Disks: ” + str(drive))
print(“Name:” + str(vinfo.name))
print(“Type:” + str(vinfo.fstype))
fs_t_gb = fsinfo.total / (1024*1024*1024)
fs_u_gb = fsinfo.used / (1024*1024*1024)
fs_f_gb = fsinfo.free / (1024*1024*1024)
print(“Total:” + str(fs_t_gb))
print(“Used:” + str(fs_u_gb))
print(“Free:” + str(fs_f_gb))

# Perfmon – Performance Counters:
usage = winstats.get_perf_data(r’\Processor(_Total\% Processor Time’, delay=100)
print(usage)

Comments Off on 5 Min Python WMI perfmon