The script is as follows:
#!/usr/bin/Env Python#coding:utf-8Import Win32com.clientimport timedef disk_status ():Try: while 1: StrComputer="."objWMIService= Win32com.client.Dispatch ("WbemScripting.SWbemLocator") objSWbemServices= Objwmiservice.connectserver (StrComputer,"root\cimv2") Colitems= objSWbemServices.ExecQuery ("SELECT * from Win32_perfformatteddata_perfdisk_logicaldisk") Print"Time :"+ Time.strftime ("%y-%m-%d%h:%m:%s") Print"Device:"+'\ t'+"TPS"+'\ t'+"kb_read/s"+'\ t'+"KB_WRTN/S"+'\ t'+"Kb_read"+'\ t'+"Kb_wrtn"+'\ t'+"Disk_free" forObjiteminchcolitems:ifobjItem.Name! ='_total': Print objItem.Name+'\ t'+ STR (OBJITEM.DISKTRANSFERSPERSEC) +'\ t'+"%0.1f"% (float(OBJITEM.DISKREADBYTESPERSEC)/1024x768) +'\ t'+'\ t'+"%0.1f"% (float(OBJITEM.DISKWRITEBYTESPERSEC)/1024x768) +'\ t'+'\ t'+"%0.1f"% (float(OBJITEM.DISKREADSPERSEC)/1024x768) +'\ t'+"%0.1f"% (float(OBJITEM.DISKWRITESPERSEC)/1024x768) +'\ t'+"%0.0f%%"%objitem.percentfreespace #Device: Displays the disk name #tps: Indicates the number of transfers per second that are output to the physical disk. A single transfer is a physical disk of I/O request. Multiple logical requests can be and are a single I/O request to disk. The transport has a medium size. #kB_read/S: The amount of data read from disk per second, in kilobytes. #kB_wrtn/S: The amount of data written to disk per second, in kilobytes. #Kb_read: The total number of kilobytes read. #Kb_wrtn: The total number of kilobytes written. #DiskTransfersPerSec: Number of disk transfers per second. #DiskReadBytesPerSec: The amount of data read from disk per second, in bytes. #DiskWriteBytesPerSec: The amount of data written per second from disk, in bytes. #PercentFreeSpace: Percentage of free disk print"'Time.sleep (2) except (eoferror,keyboardinterrupt): Passif__name__ = ='__main__': Disk_status ()
Execution Result:
Time2018- to- . A:Geneva: +Device:tps Kb_read/s kb_wrtn/s Kb_read kb_wrtn DISK_FREEC:171 437.6 700.2 0.1 0.1 -%D:0 0.0 0.0 0.0 0.0 4%E:0 0.0 0.0 0.0 0.0 -%F:0 0.0 0.0 0.0 0.0 -%G:0 0.0 0.0 0.0 0.0 to%H:0 0.0 0.0 0.0 0.0 to%HarddiskVolume10 0.0 0.0 0.0 0.0 the%HarddiskVolume140 0.0 0.0 0.0 0.0 -%HarddiskVolume150 0.0 0.0 0.0 0.0 the%HarddiskVolume170 0.0 0.0 0.0 0.0 the%HarddiskVolume190 0.0 0.0 0.0 0.0 the%HarddiskVolume210 0.0 0.0 0.0 0.0 the%HarddiskVolume230 0.0 0.0 0.0 0.0 the%HarddiskVolume50 0.0 0.0 0.0 0.0 A%HarddiskVolume60 0.0 0.0 0.0 0.0 -%
Reference: http://blog.51cto.com/wangwei007/741083
Install win32com.client:
Https://github.com/mhammond/pywin32/releases
Display of Windows emulation Linux command Iostat