Python automated Operations-system Performance Information module

Source: Internet
Author: User

Module: Psutil

Psutil is a cross-platform library that makes it easy for us to get information about the process and resource utilization of the system running.

Function: mainly for the 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

    1. User time, percentage of times to execute the process
    2. System time, percent execution of kernel processes and interrupts
    3. Wait io, percentage of time that the CPU is idle (idle) due to IO waiting
    4. Idle,cpu percentage of time in idle state

Psutil.cpu_times () How to use:

#import Psutil#psutil.cpu_times (percpu=true) # Use the Cpu_times method to obtain CPU complete information, need to display all logical CPU information, PERCPU = True Optional #psutil.cpu_ Times (). User # Gets the individual data information, such as the user's CPU time compared to #psutil.cpu_count () # Gets the logical number of CPUs, the default Logical=true#psytil.cpu_count (logical= False) # Gets the physical number of CPUs

Memory Information:

Memory information mainly includes the following parts:

    1. Total (amount of memory)
    2. Used (number of memory used)
    3. Free (number of idle memory)
    4. Buffers (number of buffers used)
    5. Cache (number of cached uses)
    6. Swap (Swap partition usage)

Psutil.virtual_memory () and Psutil.swap_memory () method of use:

#import psutil#mem=psutil.virtual_memory () # Get memory Full information #print (MEM) #mem. Total # Get memory totals #mem.free # Get free memory number #psutil.swap_ Memory () # Get swap partition information

Disk Information:

Disk information mainly includes the following sections:

    1. Read_count (read IO number)
    2. Write_time (write IO number)
    3. Read_bytes (io Read bytes)
    4. Read_time (disk read time)
    5. Write_time (disk write time)

Psutil.disk_io_counters () How to use:

#import psutil#psutil.disk_partitions () # Get disk full information #psutil.disk_usage ('/') # Get partition (parameter) usage #psutil.disk_io_counters () # Get the total IO number, read and write Information #psutil.disk_io_counters (perdisk=true) # ' perdisk=true ' parameter to get a single partition IO number, read and write information

Network information:

The network information mainly includes the following parts:

    1. Bytes_sent (number of bytes sent)
    2. Bytes_recv (number of bytes received)
    3. Packets_sent (number of packets sent)
    4. PACKETS_RECV (number of packets received)

Psutil.net_io_counters () How to use:

#import psutil#psutil.net_io_counters () # Get network total IO information, default pernic=false#psutil.net_io_counters (pernic=true) # Output IO information for each network interface

Additional System Information:

#import psutil,datetime#psutil.users () # Returns the user information for the currently logged on System #psutil.boot_time () # Gets the boot time, returned in the Linux timestamp format # Datetime.datetime.formtimestamp (Psutil.boot_time ()). Strftime ('%y-%m-%d%h:%m:%s ') # Convert to Natural time format

  

Python automated Operations-system Performance Information module

Related Article

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.