标签:style class blog code tar color
#!/usr/bin/env python # coding=gbk import sys import os import time if __name__== ‘__main__‘: filename = sys.argv[1] nowtime = int(time.time()) starttime = nowtime - 60 cmd = "rrdtool fetch "+filename+" AVERAGE --start " + str(starttime) + " --end "+str(nowtime) # print cmd values = [] f = os.popen(cmd) for res in f: if res.find(":") == -1: continue if res.find("nan") != -1: continue values.append(eval(res.split(‘:‘)[1].strip().split(‘ ‘)[0].strip())) # print values res = 0.0 for v in values: res = res + v if len(values) == 0: res = 0.0 else: res = res/len(values) print "value:"+str(res)
标签:style class blog code tar color
原文地址:http://www.cnblogs.com/fredy-z/p/3810518.html