Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

A simple 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.

Note: Relicensed as LGPL v3 (or later).

Install

D:\> pip install winstats

Use

Setup:

import winstats

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

Memory Stats:

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

Performance Stats:

pinfo = winstats.get_perf_info()
print '    Cache: %s p' % fmt(pinfo.SystemCache)
print '    Cache: %s b' % fmt(pinfo.SystemCacheBytes)
print

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:', vinfo.name
print '        Type:', vinfo.fstype
print '        Total:', fmt(fsinfo.total)
print '        Used: ', fmt(fsinfo.used)
print '        Free: ', fmt(fsinfo.free)
print

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

Results

The examples above are built into the module, and double as a minimal test suite:

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
    C:\
        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 …

Download files

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

Source Distribution

winstats-0.80.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

winstats-0.80-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file winstats-0.80.tar.gz.

File metadata

  • Download URL: winstats-0.80.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for winstats-0.80.tar.gz
Algorithm Hash digest
SHA256 6076805d9a118b6dceff75f1ff49d04683da70884fb7392fa0a7583c42b3e6a4
MD5 84214500749bd851a3753850db01eb10
BLAKE2b-256 021c05a6b869347285ac1fa5f2985b0fb44e45d4c801b2e2e5436cfd1f236268

See more details on using hashes here.

File details

Details for the file winstats-0.80-py2.py3-none-any.whl.

File metadata

  • Download URL: winstats-0.80-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for winstats-0.80-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 75af791f5c2be22da52f20754ad1dbbdae6dc5469484ce0518997c6971f768ac
MD5 61962ec1750a6e587e20c704f408476c
BLAKE2b-256 4e2942cae658d30bd0254ec95bc2205b9d5dec51af5c80545499a4b67a00dc80

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.80 This release

2 files

0.70

1 file

0.65

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page