Python automated O & M-system performance information module, python system performance

Source: Internet
Author: User

Python automated O & M-system performance information module, python system performance

Module: psutil

Psutil is a cross-platform database that allows you to easily obtain information about processes and resource utilization of the system.

Function: mainly for System Monitoring

Installation:

wget https://pypi.python.org/packages/source/p/psutil/psutil-2.0.0.tar.gz --no-check-certificatetar -zxvf psutil-2.0.0.tar.gzcd psutil-2.0.0python setup.py install

CPU information:

CPU utilization mainly includes the following parts:

Psutil. cpu_times () usage:

# Import psutil # psutil. cpu_times (percpu = True) # Use the cpu_times method to obtain complete CPU information. All logical CPU information must be displayed. percpu = True (optional) # psutil. cpu_times (). user # obtain individual data information, such as the CPU time ratio of the user # psutil. cpu_count () # obtain the number of CPU logic. The default value is logical = True # psytil. cpu_count (logical = False) # obtain the physical number of CPUs

Memory information:

The memory information mainly includes the following parts:

Psutil. virtual_memory () and psutil. swap_memory () usage:

# Import psutil # mem = psutil. virtual_memory () # obtain the complete memory information # print (mem) # mem. total # retrieve the total memory # mem. free # obtain the number of idle memory # psutil. swap_memory () # obtain swap partition information

Disk information:

The disk information mainly includes the following parts:

Psutil. disk_io_counters () usage:

# Import psutil # psutil. disk_partitions () # obtain the complete disk information # psutil. disk_usage ('/') # obtain partition (parameter) usage # psutil. disk_io_counters () # obtain the total I/O count and read/write information of the hard disk # psutil. disk_io_counters (perdisk = True) # The 'perdisk = true' parameter obtains the IO count and read/write information of a single partition.

Network Information:

The network information mainly includes the following parts:

Psutil.net _ io_counters () usage:

# Import psutil # psutil.net _ io_counters () # obtain the total IO information of the network. The default value is pernic = False # psutil.net _ io_counters (pernic = True) # output the IO information of each network interface

Other System Information:

# Import psutil, datetime # psutil. users () # Return the user information of the current logon system # psutil. boot_time () # obtain the boot time, which is returned in the Linux timestamp format # datetime. datetime. formtimestamp (psutil. boot_time ()). strftime ('% Y-% m-% d % H: % M: % s') # convert to natural time format

  

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.