System Metrics/Stats Library for Linux
2010-2013 Corey Goldberg
Free Open Source : MIT License
Description
linux-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.
Basic stats for major subsystems are provided (Processor/CPU, Disk, Memory, Network).
Install from PyPI
pip install linux-metrics
Requirements
Python 2.6/2.7/3.1/3.2/3.3/PyPy
Linux 2.6+
Example Usage
print number of processes running:
from linux_metrics import cpu_stat print cpu_stat.procs_running()
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%
API
* linux_metrics
* cpu_stat
* cpu_times()
* cpu_percents(sample_duration=1)
* procs_running()
* procs_blocked()
* load_avg()
* cpu_info()
* disk_stat
* disk_busy(device, sample_duration=1)
* disk_reads_writes(device)
* disk_usage(path)
* disk_reads_writes_persec(device, sample_duration=1)
* mem_stat
* mem_stats()
* net_stat
* rx_tx_bytes(interface)
* rx_tx_bits(interface)
* rx_tx_dump(interface)
Example
linux-metrics package contains an example script:
Unit Tests
You can run the included unit tests and verify all cases pass in your environment:
$ nosetests
Note: you may need to adjust the configuration of the unit tests to match your environment. They are set by default to use:
DISK_DEVICE = 'sda1' NETWORK_INTERFACE = 'eth0'
Metadata
Release files for linux-metrics 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| linux-metrics-0.1.4.tar.gz | 5.9 kB | Without provenance | Details for linux-metrics-0.1.4.tar.gz |
Release files / linux-metrics-0.1.4.tar.gz
| Download URL | linux-metrics-0.1.4.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc952dcd919447ccdf03b8024ddac750ff7bbf69d246137c4081b015e10c1e86
|
|
BLAKE2b-256 checksum How to use checksums |
e5da93ef218532c0ce0e72f99ae819af6b8e0ec277c5ce9267c4061b07cde254
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for linux-metrics 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.