Introduction to ioPS
IOPS is mainly used in data, this indicator is a database performance evaluation of an important reference, IOPS is the number of read/write (I/O) operations per second, mainly to see the performance of random access, generally to increase the IOPS to rely on the disk array, the actual online database is basically RAID10 configuration, RAID5 in the actual production environment if the pressure is not able to withstand, of course, to open the specific business pressure, if it is to use the physical machine to see IOPS in the actual number of values, now the cloud is also common, if you use the RDS cloud database, this IOPS can be based on the business situation of their own choice, Basically a parameter, can be modified on demand, of course, the larger the cost of the higher
Python Gets the system ioPS code as follows:
#!/usr/bin/python import OS, time, math run_tests = 3 devices = Os.listdir ('/sys/block/') check_devices = [] reads = {} writes = {} for dev in Devices:if dev.startswith (' MD ') or Dev.startswith (' SD ') or Dev.startswith (' HD '): C Heck_devices.append (dev) reads[dev] = [] writes[dev] = [] check_devices = sorted (check_devices) for T in Range (run_tests + 1): for dev in check_devices:file_data = open ('/sys/block/%s/stat '% dev). ReadLine (). Strip (). Split (') clean = [] for num in file_data:if num!= ': clean.append (int (
num)) Reads[dev].append (clean[0]) writes[dev].append (clean[4]) print Reads[dev] Print Writes[dev] Time.sleep (1) print "Device Read Write" print "--------------------------------------" for Dev in Check_dev
Ices:clean_reads = [] reads[dev].reverse () for test, result in enumerate (Reads[dev]): if test > 0: Clean_reads. Append (float (reads[dev][test-1]-result)) Rops = Int (Math.ceil (sum (clean_reads)/len (clean_reads)) Clean_w Rites = [] writes[dev].reverse () for test, result in enumerate (Writes[dev]): if test > 0:c Lean_writes.append (float (writes[dev][test-1]-result)) Wops = Int (Math.ceil (sum (clean_writes)/len (clean_writes)) Print '%s%s '% (Dev.ljust, repr (Rops). Ljust (one), repr (Wops))
Summarize
The above is the entire content that Python obtains the system ioPS, hoped this article can have the certain help to the study and the use Python, if has the question everybody may the message exchange.