Resign at home, while looking for work while learning python read a Python foundation after feeling far enough, and then in some East search to find a "python Automation Operations" book, write this want to leave some traces of learning, First of all, thank the Great God author Liu Tians,
No more talking about getting started.
python system basic Information module detailed
System basic information Acquisition module as an important part of monitoring module
System Performance Information module:psutil
This module can easily obtain the system running process and system utilization information, mainly used for system monitoring, analyzing and restricting system resources and process management.
First, download a psutil package
URL https://github.com/giampaolo/psutil/releases?after=release-2.1.3
i downloaded the 2.0.0 version written in the book.
Install the Psutil module: (This thing shows the units in bytes)
TAR-XF psutil-release-2.0.0.tar.gz
CD psutil-release-2.0.0
Python setup.py Install
You can then run the
Python
Get System Performance Information
Import Psutil
MEM = Psutil.virtual_memory ()
function to call psutil for variable mem assignment virtual_memory ()
650) this.width=650; "border=" 0 "width=" 554 "height=" "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/ >
Get individual information: ( two ways )
Psutil.virtual_memory (). percent
650) this.width=650; "border=" 0 "width=" 554 "height=" "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/ >
Mem.total,mem.used
650) this.width=650; "border=" 0 "width=" 554 "height=" "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/ >
Show CPU Information:
Psutil.cpu_times ()
650) this.width=650; "border=" 0 "width=" 554 "height=" "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/ >
Psutil.cpu_count () displays the number of logical CPUs
Psutil.cpu_count (Logical=false) gets The number of physical CPUs
Display disk information:
Psutil.disk_usage ('/') disk usage
650) this.width=650; "border=" 0 "width=" 554 "height=" "src=" "/e/u261/themes/default/images/spacer.gif" style= " Background:url ("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/ >
Psutil.disk_partitions () disk partitioning situation
Psuti.disk_io_counter () show total io
Psutil.disk_io_counter (perdisk=true) gets the number of IO for a single partition
Display Network information:
Psutil.net_io_counters () receive send bytes and other information
Psutil.net_io_counters (pernic=true) IO information for each network Oh interface
650) this.width=650; "border=" 0 "width=" 555 "height=" all src= "/e/u261/themes/default/images/spacer.gif" style= " Background:url ("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/ >
Show additional information:
Psutil.users () displays the currently logged on user
Psutil.boot_time () shows how long the boot has been
Get system Process Management methods
Psutil.process ()
Psutil.pids ()
p = psutil. Processes ( process numbers ) instantiate a process object with parameters
P.name () process name
P.exe () process bin Path
Absolute path of the P.CWD () process working directory
P.status () process State
P.create_time () process creation time, timestamp format
P.uids () process UID
P.gids () process GID
P.cpu_times () process CPU time includes USER and SYSTEM two time
P.cpu_affinity () 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
P.connections ()
This article is from the "11351281" blog, please be sure to keep this source http://11361281.blog.51cto.com/11351281/1931497
Python Operations Learning Note 1