python代码
import subprocess
import collectd
import time
NAME = 'io_info'
VERBOSE = True
def get_stats():
value = []
io_value = [[]]
subprocess.Popen("iostat -d -m -x 1 2 | grep -E 'dm-2' | tail -n1 | awk '{print $6,$7,$10,$13,$14}' > /tmp/io_info" ,shell=True)
with open('/tmp/io_info', 'r') as f:
lines = f.readlines()
for line in lines:
value=line.split( )
#print value
time.sleep(5)
io_value_read_Mb = float(value[0])
io_value_write_Mb = float(value[