Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use disk io Test under Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the disk io test under Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

In the past two days, I was testing the PS6000 storage of Dell, and I didn't bother to find a test tool under linux, so I directly used the dd command to test it, but because there was a lot of data to be tested, from 512b to 4m, every file had to be tested for reading and writing, which would be too tiring for human flesh to do, so the following script was generated.

This script is written in perl and completes each read or write test according to the test case.

There are three parameters in this script, two are required and one is optional.

-r test read performance

-w test write performance

-c optional parameter to turn off the cache of the file system

#! / bin/evn perluse JSON;use Data::Dumper;use Cwd;use File::Basename;our $cache_flag =''; # get the directory my $cwd;if ($0 = ~ m {^ /}) {$cwd = dirname ($0);} else {my $dir = getcwd (); $cwd = dirname ("$dir/$0");} # get the parameter if (@ ARGV)

< 1 ) {&usage;exit;}elsif ( @ARGV == 1 ) {if ( ( $ARGV[0] ne "-r" ) && ( $ARGV[0] ne "-w" ) ) {print "Unrecognized Option\n";&usage;exit;}}elsif ( @ARGV == 2 ) {if ( $ARGV[0] eq "-r" ) {$cache_flag = "iflag=direct,nonblock";}elsif ( $ARGV[0] eq "-w" ) {$cache_flag = "oflag=direct,nonblock";}elsif ( ( $ARGV[0] ne "-r" ) || ( $ARGV[0] ne "-w" ) ) {print "Unrecognized Option\n";&usage;exit;}}my $opt = $ARGV[0];# 使用帮助sub usage {print "Usage: iotest.pl [OPTION] [OPTION]\n";print "\n";print "-r\texecute read test\n";print "-w\texecute write test\n";print "-c\tiotest with local filesystem cache\n\n";}# 检查测试文件是否存在sub check_file {if ( !-e "./iotest" ) {print "The test file dose not exist,please run write test first\n";exit;}}# 打开测试用例open FH, ">

Iotestr.log 2 > & 1 "; print rfh" IOTest Block: $key\ n "; `$ cmd`; print rfh"\ n ";}} elsif ($opt eq"-w ") {while (($key, $value) = each% strings) {open wfh,'> > iotestw.log';my $cmd =" / bin/dd if=/dev/zero of=./iotest bs=$key count=$value $cache_flag > > iotestw.log 2 > & 1 "; print wfh" IOTest Block: $key\ n "; `$ cmd`; print wfh"\ n ";}}

Let's take a look at the format in which test cases are written. Here the mosquito uses the json string, which is easy for perl to read. The contents of the file are as follows.

{"512K": "4096000", "1K": "2048000", "2K": "1024000", "4K": "512000", "8K": "256000", "16K": "128000", "32K": "64000", "64k": "32K", "128k": "16000", "256k": "8000"," 512k ":" 4000000 "," 1m ":" 2000m "," 2m ":" 1000m "," 4m ":" 256000 "}

The file is mainly divided into two fields, the block size before the colon, the count number after the colon, through the block size and count number to create the file, mosquitoes here are unified to generate a 2G file. The file is named iotest.json, and you can put the test case and the test script in the same directory. The use aspect is very simple, go to the disk or directory to be tested, and execute

# perl / dir/to/iotest.pl-w

The disk write test for turning on file system swap can be completed. After the execution of the program, a .log file will be created in the current directory to record the test results. the following figure shows the results of the mosquito test. I made a table.

The above is all the contents of the article "how to use disk io Test under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report