In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to monitor the performance of disk IO, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
How to check the size of disk space under the windows command line
Article classification: the operating system views all
Wmic DiskDrive get Size / value
:: view disk C
Wmic LogicalDisk where "Caption='C:'" get FreeSpace,Size / value
:: view D disk
Wmic LogicalDisk where "Caption='D:'" get FreeSpace,Size / value
The IO performance of the disk is an important index to measure the overall performance of the computer. Linux provides iostat commands to obtain disk input / output (that is, IO) statistics, while Windows provides a WMI interface that allows you to write a simple script to get the equivalent of iostat.
1. Iostat command under Linux
Iostat-d-k-t 2
The disk IO information is counted every 2 seconds until the program is terminated by Ctrl+C, the-d option indicates the statistical disk information,-k indicates that it is displayed in the form of KB per second,-t requires that the time information be printed, and 2 means that it is output every 2 seconds. The disk IO load status of the first output provides statistics since the system was started. Each subsequent output is the average IO load between each interval.
After running the command, output:
Linux 2.6.9-67.0.7.ELsmp (localhost.localdomain) 11 Universe 19 Universe 2008
Time: 03:15:25 PM
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
Sda 3.53 26.66 54.76 30122033 61864280
Sda1 0.51 1.07 1.73 1207649 1949740
Sda2 0.00 0.00 0.00 538 256
Sda3 13.84 25.59 53.03 28913291 59914092
Time: 03:15:27 PM
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
Sda 275.38 0.00 1738.69 0 3460
Sda1 14.57 0.00 58.29 0 116
Sda2 0.00 0.00 0.00 00
Sda3 419.60 0.00 1678.39 0 3340
...
Time information is printed for each output, followed by a list of disk IO conditions.
Device: displays the disk name
Tps: represents the number of transfers per second output to the physical disk. A transfer is an Icano request to a physical disk. A plurality of logical requests can be combined as a single Ipicuro request to the disk. The transmission has a medium size.
KB_read/s: the amount of data read from disk per second, in KB.
KB_wrtn/s: the amount of data written to disk per second, in KB.
Kb_read: total number of KB read.
Kb_wrtn: total number of KB written.
2. Win32_PerfFormattedData_PerfDisk_LogicalDisk object in WMI
Win32_PerfFormattedData_PerfDisk_LogicalDisk represents the logical disk performance data object, which can be used to obtain the mental information of the disk. The Win32_PerfFormattedData_PerfDisk_LogicalDisk object has the following main properties:
Name: disk name
DiskTransfersPerSec: number of disk transfers per second.
DiskReadBytesPerSec: the amount of data read from disk per second, in Byte.
DiskWriteBytesPerSec: the amount of data read from disk per second, in Byte.
PercentFreeSpace: percentage of disks available.
3. Points for attention when using Win32_PerfFormattedData_PerfDisk_LogicalDisk
When using Win32_PerfFormattedData_PerfDisk_LogicalDisk, you should be aware of:
(1) you cannot use objWMIService.ExecQuery to execute Select statements to obtain disk performance data.
(2) you must use WbemScripting.SWbemRefresher to add Win32_PerfFormattedData_PerfDisk_LogicalDisk, and then constantly call the Refresh method to refresh data to obtain performance information.
(3) during the first refresh, the useful data can not be obtained, but the disk performance data can only be obtained from the second time.
(4) the above problems are related to the mechanism of performance monitoring using counters in WMI.
4. Use examples
In order to provide a good user interface for monitoring disk performance, VBScript can be used to write scripts to obtain disk performance data. The code for the script is as follows:
'Script. File Name: DiskMonitor.vbs
StrComputer = "."
Set bjWMIService = GetObject ("winmgmts:" _
& "{impersonationLevel=impersonate}!\" & strComputer & "\ root\ cimv2")
Set bjRefresher = CreateObject ("WbemScripting.SWbemRefresher")
Set colDisks = objRefresher.AddEnum (objWMIService, "Win32_PerfFormattedData_PerfDisk_LogicalDisk") .objectSet
If Wscript.Arguments.Count = 0 Then
ObjRefresher.Refresh
For Each objDisk in colDisks
Wscript.Echo objDisk.Name & "& objDisk.DiskReadBytesPerSec &" & objDisk.DiskWriteBytesPerSec
Next
End If
If Wscript.Arguments.Count = 1 Then
Interval = CInt (Wscript.Arguments (0)) * 1000
Do While True
ObjRefresher.Refresh
Wscript.Echo
Wscript.Echo "Time:" & "& Time ()
Wscript.Echo FormatStr ("Device:", 15,0) & FormatStr ("tps", 7,1) & FormatStr ("kB_read/s", 13,1) & FormatStr ("kB_wrtn/s", 13,1) & FormatStr ("Free Space", 13,1)
For Each objDisk in colDisks
Wscript.Echo FormatStr (objDisk.Name, 15,0) & FormatStr (objDisk.DiskTransfersPerSec, 7,1) & FormatStr (objDisk.DiskReadBytesPerSec, 13,1) & FormatStr (objDisk.DiskWriteBytesPerSec, 13,1) & FormatStr (objDisk.PercentFreeSpace & "%", 13,1)
Next
Wscript.Sleep Interval
Loop
End If
If Wscript.Arguments.Count = 2 Then
I = 0
Interval = CInt (Wscript.Arguments (0)) * 1000
Count = CInt (Wscript.Arguments (1))
Do While i < Count
ObjRefresher.Refresh
Wscript.Echo
Wscript.Echo "Time:" & "& Time ()
Wscript.Echo FormatStr ("Device:", 15,0) & FormatStr ("tps", 7,1) & FormatStr ("kB_read/s", 13,1) & FormatStr ("kB_wrtn/s", 13,1) & FormatStr ("Free Space", 13,1)
For Each objDisk in colDisks
Wscript.Echo FormatStr (objDisk.Name, 15,0) & FormatStr (objDisk.DiskTransfersPerSec, 7,1) & FormatStr (objDisk.DiskReadBytesPerSec, 13,1) & FormatStr (objDisk.DiskWriteBytesPerSec, 13,1) & FormatStr (objDisk.PercentFreeSpace & "%", 13,1)
Next
Wscript.Sleep Interval
I = I + 1
Loop
End If
Function FormatStr (str, tLen, direction)
SLen = Len (str)
FStr = ""
Num = tLen-sLen
J = 0
Do While j < num
FStr = fStr & ""
J = j + 1
Loop
If direction = 1 Then
FStr = fStr & str
Else
FStr = str & fStr
End If
FormatStr = fStr
End Function
Examples of use:
(1) CSCript. DiskMonitor.vbs
If you do not refresh the Win32_PerfFormattedData_PerfDisk_LogicalDisk object once, you will not get useful data.
(2) CSCript. DiskMonitor.vbs 2
Get disk performance data every 2 seconds and output it until you press Ctrl+C to terminate the program.
(3) CSCript. DiskMonitor.vbs 2 100
Disk performance data is taken and output every 2 seconds for a total of 100 times, and then the output information includes DiskTransfersPerSec, DiskReadBytesPerSec, DiskWriteBytesPerSec, and PercentFreeSpace.
After reading the above, do you have any further understanding of how to monitor disk IO performance? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.