System Basic Information Module
Psutil Module https://pypi.python.org/pypi/psutil/
System Performance Section
1.CPU Info
Psutil.cpu_times () # get full CPU information Note: Different versions display different content
includes:User # Users account for CPU time system # CPU time idle #cpu idle time
Interrupt # can interrupt sleep time DPC #
Psutil.cpu_count () # gets the number of CPUlogic = = = Logical = False gets The number of CPU physical
2.Memory Info
Psutil.virtual_memory () # get complete information on memory
includes:Total # gross available used free buffers ( buffer count ) cacheActive inactive
Psutil.swap_memory () # get swap partition information
3.Disk Info:
Psutil.disk.usage (") # View the usage of a partition , need a parameter
Psutil.disk_partiotions () # gets disk information that shows which disks and partitions
Psutil.disk_io_counters () # get the total number of Io perdisk=true get the number of IO per partition
includes: Read and write times Number of bytes Time
4.Network Info:
Psutil.net_io_counters () # get the total IO information of the network pernic=true output io per network interface
includes: Bytes sent, Bytes received, datagrams sent, number of packets received, number of error IO discarded
5. Other info:
Psutil.users () # returns information for the current user
Psutil.boot_time () # Get boot time, return in Linux timestamp format
System processes:
1. Process information:
Psutil.pids () # list all process PID
Psutil.process () returns a process object with the parameter pid
instantiate an object:p = psutil. Process (PID)
P.name () # process name
P.exe () # process bin Path
P.CWD () # process working directory absolute path
P.status () # process status
P.create_time () # process creation time, timestamp format
P.cpu_times () # process CPU time Information
P.cpu_affinity () #get CPU affinity of the process
P.memory_percent () # Process Memory Utilization
P.memory_info () # Process Memory RSS , VMS Information
P.io_counters () # process io information, including read/write io number and number of bytes
P.connections () # Returns the Namedutples list of open process sockets
P.num_threads () # number of threads opened by the process
p.io_counters () # Process IO Information
P.connections () # Returns the Namedutples list of open process sockets
use of the Popen class: Used to obtain user-initiated application process information and to track the running state of the program process.
Example:psutil. Popen (["/usr/bin/python", "-C", "Print (' Hello ')"],stdout=pipe)
This article is from the "True Water No Fragrance" blog, please be sure to keep this source http://chengyanli.blog.51cto.com/11399167/1846728
Python's Psutil module