亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Python如何獲取系統(tǒng)iops示例代碼

原創(chuàng) 2017-01-16 14:31:02 279
摘要:iops簡介iops主要用在數(shù)據(jù)方面,這個指標是數(shù)據(jù)庫性能評定的一個重要參考,iops的是每秒進行讀寫(I/O)操作的次數(shù),主要看隨機訪問的性能,一般為了iops增高都要依靠磁盤陣列,實際線上的數(shù)據(jù)庫基本都是raid10的配置,raid5在實際生產(chǎn)環(huán)境中如果壓力上來是抗不住的,當然也要開具體業(yè)務壓力情況,如果是用物理機就要看iops在實際中能跑到多少值,現(xiàn)在云也普遍了,如果你用的RDS云數(shù)據(jù)庫,這

iops簡介

iops主要用在數(shù)據(jù)方面,這個指標是數(shù)據(jù)庫性能評定的一個重要參考,iops的是每秒進行讀寫(I/O)操作的次數(shù),主要看隨機訪問的性能,一般為了iops增高都要依靠磁盤陣列,實際線上的數(shù)據(jù)庫基本都是raid10的配置,raid5在實際生產(chǎn)環(huán)境中如果壓力上來是抗不住的,當然也要開具體業(yè)務壓力情況,如果是用物理機就要看iops在實際中能跑到多少值,現(xiàn)在云也普遍了,如果你用的RDS云數(shù)據(jù)庫,這個iops是可以根據(jù)業(yè)務情況自己選擇的,基本是個參數(shù),可以按需進行修改,當然數(shù)值越大費用越高

python獲得系統(tǒng)iops代碼如下:

#!/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'):
        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 != '':
                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_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(math.ceil(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(math.ceil(sum(clean_writes) / len(clean_writes)))
 
    print "%s %s %s" % (dev.ljust(13), repr(rops).ljust(11), repr(wops))

更多關于Python如何獲取系統(tǒng)iops示例代碼請關注PHP中文網(wǎng)(ipnx.cn)其他文章! 

發(fā)佈手記

熱門詞條