How Python Gets the system ioPS sample code _python

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.