def graph(rrd_path, img_path, start="end-360m", end="now", width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = " ".join( [ "rrdtool graph %s" % img_path, "--end %s" % end, "--start %s" % start, "--width %s" % width, "--height %s" % height, "--lower-limit 0", "--rigid", '--title "disk"', '--vertical-label "GB"', "DEF:total=%s:total:LAST" % rrd_path, "DEF:used=%s:used:LAST" % rrd_path, "CDEF:a2=total,1024,/,", "CDEF:a3=a2,1024,/,", "CDEF:b2=used,1024,/,", "CDEF:b3=b2,1024,/,", 'AREA:a3#FFFF00:"total"', 'AREA:b3#FF8000:"used"', ] ) try: local_exec(cmd) except: raise
def graph(rrd_path, img_path, start='end-360m', end='now', width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join([ 'rrdtool graph %s' % img_path, '--end %s' % end, '--start %s' % start, '--width %s' % width, '--height %s' % height, '--lower-limit 0', '--rigid', '--title "iops"', '--vertical-label "size"', 'DEF:read=%s:read:AVERAGE' % rrd_path, 'DEF:write=%s:write:AVERAGE' % rrd_path, 'AREA:read#ff0000:"read"', 'AREA:write#00ff00:"write"' ]) try: local_exec(cmd) except: raise
def graph(rrd_path, img_path, start="end-360m", end="now", width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = " ".join( [ "rrdtool graph %s" % img_path, "--end %s" % end, "--start %s" % start, "--width %s" % width, "--height %s" % height, "--lower-limit 0", "--rigid", '--title "network"', '--vertical-label "bytes/s"', "--units=si", "DEF:in=%s:in:AVERAGE" % rrd_path, "DEF:out=%s:out:AVERAGE" % rrd_path, 'LINE1:in#FF6633:"in"', 'LINE1:out#00ff00:"out"', ] ) # print cmd try: local_exec(cmd) except: raise
def graph(rrd_path, img_path, start='end-360m', end='now', width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join([ 'rrdtool graph %s' % img_path, '--end %s' % end, '--start %s' % start, '--width %s' % width, '--height %s' % height, '--title "load average"', '--vertical-label "load"', '--lower-limit 0', '-Y -X 0', '--rigid', 'DEF:avg1=%s:load1:AVERAGE' % rrd_path, 'DEF:avg5=%s:load5:AVERAGE' % rrd_path, 'DEF:avg15=%s:load15:AVERAGE' % rrd_path, 'AREA:avg1#E7CD00:"avg1"', 'AREA:avg5#DE9300:"avg5"', 'AREA:avg15#F20E01:"avg15"' ]) try: local_exec(cmd) except: raise
def graph(rrd_path, img_path, start='end-360m', end='now', width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join([ 'rrdtool graph %s' % img_path, '--end %s' % end, '--start %s' % start, '--width %s' % width, '--height %s' % height, '--lower-limit 0', '--rigid', '--title "memory"', '--vertical-label "GB"', 'DEF:total=%s:total:AVERAGE' % rrd_path, 'DEF:free=%s:free:AVERAGE' % rrd_path, 'DEF:cached=%s:cached:AVERAGE' % rrd_path, 'DEF:buffers=%s:buffers:AVERAGE' % rrd_path, 'CDEF:a1=total,', 'CDEF:a2=a1,1024,/,', 'CDEF:a3=a2,1024,/,', 'CDEF:a4=a3,1024,/,', 'CDEF:b1=free,', 'CDEF:b2=b1,1024,/,', 'CDEF:b3=b2,1024,/,', 'CDEF:b4=b3,1024,/,', 'CDEF:c1=cached,', 'CDEF:c2=c1,1024,/,', 'CDEF:c3=c2,1024,/,', 'CDEF:c4=c3,1024,/,', 'CDEF:d1=buffers,', 'CDEF:d2=d1,1024,/,', 'CDEF:d3=d2,1024,/,', 'CDEF:d4=d3,1024,/,', 'AREA:a4#FFFF00:"total"', 'AREA:b4#00ff00:"free"', 'AREA:c4#0000ff:"cached"', 'AREA:d4#FF6633:"buffers"' ]) try: local_exec(cmd) except: raise
def graph(rrd_path, img_path, start='end-360m', end='now', width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join([ 'rrdtool graph %s' % img_path, '--end %s' % end, '--start %s' % start, '--width %s' % width, '--height %s' % height, '--lower-limit 0', '--rigid', '--title "disk"', '--vertical-label "GB"', 'DEF:total=%s:total:LAST' % rrd_path, 'DEF:used=%s:used:LAST' % rrd_path, 'CDEF:a2=total,1024,/,', 'CDEF:a3=a2,1024,/,', 'CDEF:b2=used,1024,/,', 'CDEF:b3=b2,1024,/,', 'AREA:a3#FFFF00:"total"', 'AREA:b3#FF8000:"used"' ]) try: local_exec(cmd) except: raise
def graph(rrd_path, img_path, start='end-360m', end='now', width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join([ 'rrdtool graph %s' % img_path, '--end %s' % end, '--start %s' % start, '--width %s' % width, '--height %s' % height, '--lower-limit 0', '--rigid', '--title "swap"', '--vertical-label "GB"', 'DEF:total=%s:total:AVERAGE' % rrd_path, 'DEF:used=%s:used:AVERAGE' % rrd_path, 'CDEF:a1=total,1024,/,', 'CDEF:a2=a1,1024,/,', 'CDEF:a3=a2,1024,/,', 'CDEF:b1=used,1024,/,', 'CDEF:b2=b1,1024,/,', 'CDEF:b3=b2,1024,/,', 'AREA:a3#ff0000:"total"', 'AREA:b3#00ff00:"used"' ]) try: local_exec(cmd) except: raise
def graph(rrd_path, img_path, start='end-360m', end='now', width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join([ 'rrdtool graph %s' % img_path, '--end %s' % end, '--start %s' % start, '--width %s' % width, '--height %s' % height, '--lower-limit 0', '--rigid', '--title "network"', '--vertical-label "bytes/s"', '--units=si', 'DEF:in=%s:in:AVERAGE' % rrd_path, 'DEF:out=%s:out:AVERAGE' % rrd_path, 'LINE1:in#FF6633:"in"', 'LINE1:out#00ff00:"out"' ]) #print cmd try: local_exec(cmd) except: raise
def graph(rrd_path, img_path, start='end-360m', end='now', width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join([ 'rrdtool graph %s' % img_path, '--end %s' % end, '--start %s' % start, '--width %s' % width, '--height %s' % height, '--title "load average"', '--vertical-label "load"', '--lower-limit 0', '-Y -X 0', '--rigid', 'DEF:avg1=%s:load1:AVERAGE' % rrd_path, 'DEF:avg5=%s:load5:AVERAGE' % rrd_path, 'DEF:avg15=%s:load15:AVERAGE' % rrd_path, 'AREA:avg1#E7CD00:"avg1"', 'AREA:avg5#DE9300:"avg5"', 'AREA:avg15#F20E01:"avg15"' ]) try: local_exec(cmd) except: raise
def local_create(rrd_path, cmd): if not rrd_path.endswith('.rrd'): raise Exception('Error: wrong rrd file path.') rrd_dir = '/'.join(rrd_path.split('/')[0:-1]) try: mkdirs(rrd_dir) except: raise if not os.path.exists(rrd_path): try: local_exec(cmd) except: raise
def local_create(rrd_path, cmd): if not rrd_path.endswith('.rrd'): raise Exception('Error: wrong rrd file path.') rrd_dir = '/'.join(rrd_path.split('/')[0:-1]) try: mkdirs(rrd_dir) except: raise if not os.path.exists(rrd_path): try: local_exec(cmd) except: raise
def local_create(rrd_path, cmd): if not rrd_path.endswith(".rrd"): raise Exception("Error: wrong rrd file path.") rrd_dir = "/".join(rrd_path.split("/")[0:-1]) try: mkdirs(rrd_dir) except: raise if not os.path.exists(rrd_path): try: local_exec(cmd) except: raise
def update(rrd_path, data): """ :param rrd_path: path of rrd file,likes:/root/store/rrds/swap.rrd :param data: data would be updated into rrd, likes: [total, used] """ if not os.path.exists(rrd_path): try: create(rrd_path) except: raise cmd = "rrdtool update %s %d:%f:%f" % (rrd_path, time.time(), data[0], data[1]) try: local_exec(cmd) except: raise
def update(rrd_path, data): """ :param rrd_path: path of rrd file,likes:/root/store/rrds/mem.rrd :param data: data would be updated into rrd, likes: [mem_total, mem_free, mem_cached, mem_buffers] """ if not os.path.exists(rrd_path): try: create(rrd_path) except: raise cmd = 'rrdtool update %s %d:%f:%f:%f:%f' % (rrd_path, time.time(), data[0], data[1], data[2], data[3]) try: local_exec(cmd) except: raise
def update(rrd_path, data): """ :param rrd_path: path of rrd file,likes:/root/store/rrds/nw.rrd :param data: data would be updated into rrd, likes: [in, out] """ if not os.path.exists(rrd_path): try: create(rrd_path) except: raise cmd = "rrdtool update %s %d:%d:%d" % (rrd_path, time.time(), data[0], data[1]) print cmd try: local_exec(cmd) except: raise
def update(rrd_path, data): """ :param rrd_path: path of rrd file,likes:/root/store/rrds/iops.rrd :param data: data would be updated into rrd, likes: [read, write] """ if not os.path.exists(rrd_path): try: create(rrd_path) except: raise cmd = 'rrdtool update %s %d:%f:%f' % (rrd_path, time.time(), data[0], data[1]) try: local_exec(cmd) except: raise
def graph(rrd_path, img_path, start='end-360m', end='now', width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join([ 'rrdtool graph %s' % img_path, '--end %s' % end, '--start %s' % start, '--width %s' % width, '--height %s' % height, '--lower-limit 0', '--rigid', '--title "memory"', '--vertical-label "GB"', 'DEF:total=%s:total:AVERAGE' % rrd_path, 'DEF:free=%s:free:AVERAGE' % rrd_path, 'DEF:cached=%s:cached:AVERAGE' % rrd_path, 'DEF:buffers=%s:buffers:AVERAGE' % rrd_path, 'CDEF:a1=total,', 'CDEF:a2=a1,1024,/,', 'CDEF:a3=a2,1024,/,', 'CDEF:a4=a3,1024,/,', 'CDEF:b1=free,', 'CDEF:b2=b1,1024,/,', 'CDEF:b3=b2,1024,/,', 'CDEF:b4=b3,1024,/,', 'CDEF:c1=cached,', 'CDEF:c2=c1,1024,/,', 'CDEF:c3=c2,1024,/,', 'CDEF:c4=c3,1024,/,', 'CDEF:d1=buffers,', 'CDEF:d2=d1,1024,/,', 'CDEF:d3=d2,1024,/,', 'CDEF:d4=d3,1024,/,', 'AREA:a4#FFFF00:"total"', 'AREA:b4#00ff00:"free"', 'AREA:c4#0000ff:"cached"', 'AREA:d4#FF6633:"buffers"' ]) try: local_exec(cmd) except: raise
def update(rrd_path, data): """ :param rrd_path: path of rrd file,likes:/root/store/rrds/mem.rrd :param data: data would be updated into rrd, likes: [mem_total, mem_free, mem_cached, mem_buffers] """ if not os.path.exists(rrd_path): try: create(rrd_path) except: raise cmd = 'rrdtool update %s %d:%f:%f:%f:%f' % ( rrd_path, time.time(), data[0], data[1], data[2], data[3] ) try: local_exec(cmd) except: raise
def graph(rrd_path, img_path, start='end-360m', end='now', width=200, height=45): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join([ 'rrdtool graph %s' % img_path, '--end %s' % end, '--start %s' % start, '--width %s' % width, '--height %s' % height, '--lower-limit 0', '--rigid', '--title "iops"', '--vertical-label "size"', 'DEF:read=%s:read:AVERAGE' % rrd_path, 'DEF:write=%s:write:AVERAGE' % rrd_path, 'AREA:read#ff0000:"read"', 'AREA:write#00ff00:"write"' ]) try: local_exec(cmd) except: raise
def fetch(rrd_path, CF='AVERAGE', resolution=None, start='now', end='now'): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join([ 'rrdtool fetch %s' % rrd_path, CF, '--resolution %s' % resolution if resolution else '', '--start %s' % start, '--end %s' % end ]) try: out, err = local_exec(cmd) return out, err except: raise
def fetch(rrd_path, CF='AVERAGE', resolution=None, start='now', end='now'): if not os.path.exists(rrd_path): raise Exception("Error:file %s doesn't exist" % rrd_path) cmd = ' '.join(['rrdtool fetch %s' % rrd_path, CF, '--resolution %s' % resolution if resolution else '', '--start %s' % start, '--end %s' % end ]) try: out, err = local_exec(cmd) return out, err except: raise
def update(rrd_path, data): """ :param rrd_path: path of rrd file,likes:/root/store/rrds/load.rrd :param data: data would be updated into rrd, likes: [load1, load5, load15] """ if not os.path.exists(rrd_path): try: create(rrd_path) except: raise cmd = 'rrdtool update %s %d:%f:%f:%f' % (rrd_path, time.time(), data[0], data[1], data[2]) try: out, err = local_exec(cmd) if err: raise Exception(err) except: raise
def update(rrd_path, data): """ :param rrd_path: path of rrd file,likes:/root/store/rrds/load.rrd :param data: data would be updated into rrd, likes: [load1, load5, load15] """ if not os.path.exists(rrd_path): try: create(rrd_path) except: raise cmd = 'rrdtool update %s %d:%f:%f:%f' % ( rrd_path, time.time(), data[0], data[1], data[2] ) try: out, err = local_exec(cmd) if err: raise Exception(err) except: raise