Ejemplo n.º 1
0
Archivo: disk.py Proyecto: e42s/uss
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
Ejemplo n.º 2
0
Archivo: iops.py Proyecto: spawn3/uss
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
Ejemplo n.º 3
0
Archivo: nw.py Proyecto: e42s/uss
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
Ejemplo n.º 4
0
Archivo: load.py Proyecto: e42s/uss
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
Archivo: disk.py Proyecto: spawn3/uss
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
Ejemplo n.º 7
0
Archivo: swap.py Proyecto: e42s/uss
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
Ejemplo n.º 8
0
Archivo: nw.py Proyecto: spawn3/uss
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
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
Archivo: swap.py Proyecto: e42s/uss
    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
Ejemplo n.º 11
0
Archivo: nw.py Proyecto: spawn3/uss
    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
Ejemplo n.º 12
0
Archivo: nw.py Proyecto: e42s/uss
    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
Ejemplo n.º 13
0
Archivo: disk.py Proyecto: e42s/uss
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
Ejemplo n.º 14
0
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
Ejemplo n.º 15
0
Archivo: nw.py Proyecto: e42s/uss
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
Ejemplo n.º 16
0
Archivo: iops.py Proyecto: spawn3/uss
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
Ejemplo n.º 17
0
Archivo: mem.py Proyecto: e42s/uss
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
Ejemplo n.º 18
0
Archivo: mem.py Proyecto: e42s/uss
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
Ejemplo n.º 19
0
Archivo: iops.py Proyecto: e42s/uss
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
Ejemplo n.º 20
0
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
Ejemplo n.º 21
0
Archivo: load.py Proyecto: e42s/uss
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
Ejemplo n.º 22
0
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
Ejemplo n.º 23
0
Archivo: load.py Proyecto: e42s/uss
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