Introduction to iops
iops is mainly used in data, this indicator is an important reference for database performance evaluation, iops is the number of read/write (I/O) operations per second, mainly to see the performance of random access, generally in order to iops to increase the number of high to rely on disk arrays, the actual online database is basically a raid10 configuration, raid5 in the actual production environment, if the pressure to come up to resist the pressure situation. Can not, of course, to open the specific business pressure situation, if you are using a physical machine to see iops in practice can run to how much value, now the cloud is also common, if you use the RDS cloud database, the iops can be based on the business case of their own choices, basically a parameter, can be modified on demand, of course, the larger the value of the higher the cost!
The python code to get the system iops is as follows:
#!/usr/bin/python import os, time, math run_tests = 3 devices = ('/sys/block/') check_devices = [] reads = {} writes = {} for dev in devices: if ('md') or ('sd') or ('hd'): check_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 != '': (int(num)) reads[dev].append(clean[0]) writes[dev].append(clean[4]) print reads[dev] print writes[dev] (1) print "Device Read Write" print "--------------------------------------" for dev in check_devices: 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((sum(clean_reads) / len(clean_reads))) clean_writes = [] writes[dev].reverse() for test, result in enumerate(writes[dev]): if test > 0: clean_writes.append(float(writes[dev][test - 1] - result)) wops = int((sum(clean_writes) / len(clean_writes))) print "%s %s %s" % ((13), repr(rops).ljust(11), repr(wops))
summarize
Above is Python get system iops all content, I hope this article for everyone to learn and use python can have some help, if there are questions you can leave a message to exchange.