psutil 模块
scputimes( user= 306.98, nice= 2.01, system= 337.34, idle= 410414.39, iowait= 78.37, irq= 0.0, softirq= 17.42, steal= 0.0, guest= 0.0, guest_nice= 0.0)
scpustats( ctx_switches= 9838934 , interrupts= 10572621 , soft_interrupts= 5582125 , syscalls= 0 )
svmem( total= 2078892032 , available= 1508818944 , percent= 27.4 , used= 367063040 , free= 135192576 , active= 874614784 , inactive= 694231040 , buffers= 122880 , cached= 1576513536 , shared= 10444800 , slab= 255148032 )
sswap( total= 2148528128 , used= 270336 , free= 2148257792 , percent= 0.0 , sin= 0 , sout= 12288 )
[ sdiskpart( device= '/dev/sda3' , mountpoint= '/' , fstype= 'xfs' , opts= 'rw,seclabel,relatime,attr2,inode64,noquota' ) ,
sdiskpart( device= '/dev/sda5' , mountpoint= '/home' , fstype= 'xfs' , opts= 'rw,seclabel,relatime,attr2,inode64,noquota' ) ,
sdiskpart( device= '/dev/sda1' , mountpoint= '/boot' , fstype= 'xfs' , opts= 'rw,seclabel,relatime,attr2,inode64,noquota' ) ]
sdiskusage( total= 53660876800, used= 3662462976, free= 49998413824, percent= 6.8)
sdiskio( read_count= 20173 , write_count= 196206 , read_bytes= 777824768 , write_bytes= 2732865536 , read_time= 207425 , write_time= 363200 , read_merged_count= 57 , write_merged_count= 6063 , busy_time= 277196 )
In [ 6 ] : import psutil, time
In [ 7 ] : psutil. boot_time( )
Out[ 7 ] : 1567342872.0
In [ 9 ] : time. strftime( '%Y-%m-%d %H:%M:%S' , time. localtime( psutil. boot_time( ) ) )
Out[ 9 ] : '2019-09-01 21:01:12'
In [ 10 ] : psutil. users( )
Out[ 10 ] :
[ suser( name= 'root' , terminal= 'tty1' , host= '' , started= 1567070080.0 , pid= 6547 ) ,
suser( name= 'root' , terminal= 'pts/0' , host= '192.168.252.1' , started= 1567433088.0 , pid= 82270 ) ,
suser( name= 'root' , terminal= 'pts/1' , host= '192.168.252.1' , started= 1567433088.0 , pid= 82287 ) ,
suser( name= 'root' , terminal= 'pts/2' , host= '192.168.252.1' , started= 1567436416.0 , pid= 11672 ) ,
suser( name= 'root' , terminal= 'pts/3' , host= '192.168.252.1' , started= 1567436416.0 , pid= 11673 ) ,
suser( name= 'root' , terminal= 'pts/4' , host= '192.168.252.1' , started= 1567436416.0 , pid= 16554 ) ,
suser( name= 'root' , terminal= 'pts/5' , host= '192.168.252.1' , started= 1567436416.0 , pid= 16559 ) ]