GithubHelp home page GithubHelp logo

markmarine / linux-metrics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cgoldberg/linux-metrics

0.0 1.0 0.0 568 KB

System Metrics/Stats Library for Linux

Home Page: http://cgoldberg.github.com/linux-metrics/

License: Other

Python 100.00%

linux-metrics's Introduction

linux-metrics

System Metrics/Stats Library for Linux


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'

linux-metrics's People

Contributors

cgoldberg avatar wojons avatar jcbsv avatar akiradeveloper avatar markmarine avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.