Python Ops plugin--psutil

Source: Internet
Author: User

The first contact with Psutil is the "Python automated operations-technology and best practices" that Liu Tians the great God.

Website address: Https://github.com/giampaolo/psutil

1, Psutil Introduction

psutil (python system and process utilities) is a cross-platform the library for retrieving information onRunning Processes andSystem Utilization(CPU, memory, disks, network) in Python. It's useful mainly forSystem Monitoring, profiling and limiting process resources andmanagement of running processes. It implements many functionalities offered by command line tools such as:ps, top, lsof, Netstat, ifconfig, who, DF, kill, Free, nice, Ionice, Iostat, Iotop, uptime, pidof, TTY, Taskset, Pmap. It currently supportsLinux, Windows, OSX, FreeBSD andSun Solaris, both32-bit and64-bitarchitectures, with Python versions from2.6 to 3.5(Users of Python 2.4 and 2.52.1.3version). PyPyIs also known to work.

Chinese translation:

The Psutil (Python system and process Utilities,python systems and processes toolkit) is a Python-based library of cross-platform access to information about running programs and system utilization (CPU, memory, disk, network). It is mainly helpful for system monitoring, analyzing and reducing process resources and managing shipping procedures. It implements many command line functions such as PS, top, lsof, Netstat, ifconfig, who, DF, kill, free, nice, Ionice, Iostat, Iotop, uptime, pidof, TTY, Taskset , Pmap. Currently supports Linux, Windows, Osx,freebsd, and Sun Solaris, supporting both 32-bit and 64-bit architectures, 2.6 to 3.5 versions of Python (using Python2.4 and 2.5 versions of the software 2.1.3 version). PyPy is known to run.

Psutil has its own reference document: http://pythonhosted.org/psutil/, if you encounter some problems and do not have a ready-made scheme reference, please consult the official reference documentation.

2. Installation

Psutil is not integrated in any version of the Python library and needs to be installed on its own.

The following is an example of installing Lcentos

2, 1 preparation before installation

First make sure the system is installed with GCC and python-devel, and if not, you can install it via Yum


$ sudo yum install gcc python-devel

2, 2 through the source installation

After installing gcc and python-devel, download the source package for installation

$ wget https://pypi.python.org/packages/source/p/psutil/psutil-3.2.1.tar.gz$ tar-zxf psutil-3.2.1.tar.gz$ CD psutil-3.2.1$ python setup.py Install

2, 3 verification

Once the installation is complete, enter Python and import the Psutil library to use its component features.

$ Pythonpython 2.6.6 (r266:84292, Jan, 09:42:36) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on Linux2type "help", "Cop Yright "," credits "or" license "for more information.>>> import psutil>>> psutil.cpu_times () scputimes (user=3961.46, nice=169.729, system=2150.659, idle=16900.540, iowait=629.59, irq=0.0, softirq=19.42, steal=0.0, guest= 0, nice=0.0)

3, Psutil each component introduction (time is urgent to perfect)

3, 1 System Information class

Cpu

Memory

Disk

Internet

Other System Information

3, 2 Process information class


Because Psutil function is very rich, the role of each function is not described in detail, if you want to learn more, want to apply psutil to your actual work, please refer to the official Reference document:http://pythonhosted.org/psutil/

Due to my ability to limit, some places may not be accurate and rigorous, please criticize the advice.

This article is from the "Small Chau Bridge" blog, please be sure to keep this source http://kingliu19.blog.51cto.com/9123938/1693032

Python Ops plugin--psutil

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.