psutil is a cross-platform library (System utilization (including CPU, memory, disk, network, etc.) information. It is mainly used for system monitoring, analyzing and restricting the management of system resources and processes. It implements the functions provided by equivalent command line tools such as PS, top, lsof, Netstat, ifconfig, who, DF, kill, free, nice, Ionice, Iostat, Iotop, uptime, pidof, TTY, Taskset, Pmap and so on. Currently supports 32-bit and 64-bit operating systems for Linux, Windows, Os x, FreeBSD, and Sun solaris, linux wget https ://pypi.python.org/packages/source/p/psutil/psutil-2.0.0.tar.gzwindows psutil-5.2.2.win-amd64-py2.7.exe#! /usr/bin/env python#coding:utf-8import timeimport sysimport psutilcpu_user = Psutil.cpu_times (). Usercpu_number=psutil.cpu_count () mem = psutil.virtual_memory () cpu_physics = psutil.cpu_count (Logical=false) system_pid = psutil.pids () disk_type = psutil.disk_ Partitions () network_type = psutil.net_io_counters () Print cpu_userprint cpu_numberprint memprint cpu_physicsprint disk_typeprint system_pidprint network_type
This article is from a "glass of water" blog, please be sure to keep this source http://6528161.blog.51cto.com/6518161/1928879
Python's Psutil module using notes