Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

A simple pip-able Windows status retrieval module with no dependencies.

Project description

A simple pip-able Windows status retrieval module with no additional dependencies. Wraps common system status queries from Windows’ ugly C-API:

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

Supports Python 2.6 and above; WindowsXP and above.


D:\> pip install winstats



import winstats

# optional
import locale
locale.setlocale(locale.LC_ALL, '')
fmt = lambda x: locale.format('%d', x, True)

Memory Stats:

meminfo = winstats.get_mem_info()
print '    Total: %s b' % fmt(meminfo.TotalPhys)
print '    usage: %s%%' % fmt(meminfo.MemoryLoad)

Performance Stats:

pinfo = winstats.get_perf_info()
print '    Cache: %s p' % fmt(pinfo.SystemCache)
print '    Cache: %s b' % fmt(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:', ', '.join(drives)
print '    %s:\\' % drive
print '        Name:',
print '        Type:', vinfo.fstype
print '        Total:', fmt(
print '        Used: ', fmt(fsinfo.used)
print '        Free: ', fmt(

Perfmon - Performance Counters:

# take a second snapshot 100ms after the first:
usage = winstats.get_perf_data(r'\Processor(_Total)\% Processor Time',
                               fmt='double', delay=100)
print '    CPU Usage: %.02f %%' % usage

# query multiple at once:
counters = [ r'\Paging File(_Total)\% Usage', r'\Memory\Available MBytes']
results = winstats.get_perf_data(counters, fmts='double large'.split())
print '    Pagefile Usage: %.2f %%, Mem Avail: %s MB' % results


The examples above are built into the module:

D:\> python.exe -m winstats

Memory Stats:
    Total: 536,330,240 b
    usage: 31%

Performance Stats:
    Cache: 35,921 p
    Cache: 147,132,416 b

Disk Stats:
    Disks: C, D, O
        Name: System
        Type: NTFS
        Total: 10,725,732,352
        Used:  3,160,956,928
        Free:  7,564,775,424

PerfMon queries:
    CPU Usage: 10.00 %
    Pagefile Usage: 0.55 %, Mem Avail: 347 MB

And more …

Project details

Release history Release notifications

History Node


History Node


History Node


This version
History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
winstats-0.61.tar.gz (5.5 kB) Copy SHA256 hash SHA256 Source None Jan 24, 2013

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page