|
Project Information
Members
Featured
Downloads
Links
|
linux-metricsPython Package - System Metrics/Stats for Linux Copyright © 2010-2011 Corey Goldberg (http://goldb.org) Descriptionlinux-metrics is a Python package containing modules for getting OS metrics on systems running the Linux kernel. It is a pure python library with no external dependencies. Only basic stats for major subsystems are provided (Processor/CPU, Disk, Memory, Network). Hopefully, more are coming. Download
Installation
The linux-metrics package distribution ships with a Disutils setup script (setup.py) for installation:
The full set of command line steps to download/unarchive/install: Requirements
Example Usagescript: print number of processes running #!/usr/bin/env python from linux_metrics import cpu_stat print cpu_stat.procs_running() python shell: print CPU utilization every 5 secs >>> from linux_metrics import cpu_stat >>> >>> while True: ... cpu_pcts = cpu_stat.cpu_percents(5) ... print 'cpu utilization: %.2f%%' % (100 - cpu_pcts['idle']) ... cpu utilization: 0.70% cpu utilization: 0.50% cpu utilization: 24.80% cpu utilization: 20.89% cpu utilization: 40.04% Unit TestsThe linux-metrics package distribution ships with a suite of unit tests: tests.py You can run the tests and verify all cases pass in your environment: Note: you may need to adjust the configuration of the unit tests to match your environment. They are set by default to use:# configuration DISK_DEVICE = 'sda' NETWORK_INTERFACE = 'eth0' View Source Code (Git)
Modules / Functions
More ExamplesThe linux-metrics package distribution ships with a simple example script: example.py For more complete examples, see the module source files: Python Package Index (PyPI)
|