Ejemplo n.º 1
0
def graph(a,f):
    line_cpu=[]
    c=[]
    m=[]
    d=[]
    while True:
        c.append(data.cpu())
	m.append(data.mem())
	d.append(data.dsk())
	
	if len(c)>60:
	    del c[0]
	    del m[0]
	    del d[0]
	if len(line_cpu)!=0:
	    l = line_cpu.pop(0)
	    l.remove()
	    l = line_mem.pop(0)
	    l.remove()
	    l = line_dsk.pop(0)
	    l.remove()
	    
	line_cpu=a.plot(c,'b')
	line_mem=a.plot(m,'r')
	line_dsk=a.plot(d,'g')
	cc='CPU  : '+c[-1]+'%'
	mm='RAM  : '+m[-1]+'%'
	dd='DISK : '+d[-1]+'%'
	
	f.legend( (line_cpu, line_mem, line_dsk), (cc, mm, dd))
	
	f.canvas.draw()
Ejemplo n.º 2
0
def main():
    if len(sys.argv) <= 1:
        print "Specify a process to monitor"
        sys.exit(1)
    process = sys.argv[1]
    pid = get_pid(process)
    if pid == "":
        print "No PID found"
        sys.exit(1)
    print "Process: %s" % process
    print "Pid: %s" % pid
    print 'NO.    CPU    MEMORY    DISK    I/O'
    matplotlib.rcParams['toolbar'] = 'None'
    plt.figure(figsize=(20, 10))
    i = 0
    while True:
        i += 1
        plt.ylim(0, 100)
        plt.xlim(0, N)
        _cpu = data.cpu(pid, process)
        _mem = data.mem(pid, process)
        _disk = data.disk()
        _io = data.io()
        print i, '\t', _cpu, '\t', _mem, '\t', _disk, '\t', _io
        cpu.append(_cpu)
        mem.append(_mem)
        #disk.append(_disk)
        #io.append(_io)
        plt.grid(True)
        plt.xlabel('TIME IN S')
        plt.ylabel('USAGE IN %')
        plt.title(' - - SYSTEM MONITOR - - ')
        cpu_label = 'CPU (' + _cpu + '%)'
        mem_label = 'MEM (' + _mem + '%)'
        disk_label = 'DISK (' + _disk + 'KB/S)'
        io_label = 'IO (' + _io + 'KB/S)'
        plt.plot(cpu[-60:-1], 'g', label=cpu_label)
        plt.plot(mem[-60:-1], 'r', label=mem_label)
        plt.plot(disk[-60:-1], 'k', label=disk_label)
        plt.plot(io[-60:-1], 'b', label=io_label)
        plt.legend(loc='upper center',
                   bbox_to_anchor=(0.5, -0.06, 0, 0.04),
                   ncol=5)
        if len(cpu) > N:
            del cpu[0]
            del mem[0]

#del disk[0]
#del io[0]
        plt.draw()
        matplotlib.interactive(True)
        plt.show()
        plt.clf()
Ejemplo n.º 3
0
def main():
    if len(sys.argv) <= 1:
	print "Specify a process to monitor"
	sys.exit(1)
    process=sys.argv[1]
    pid=get_pid(process)
    if pid == "":
	print "No PID found"
	sys.exit(1)
    print "Process: %s"%process
    print "Pid: %s"%pid
    print 'NO.    CPU    MEMORY    DISK    I/O'
    matplotlib.rcParams['toolbar'] = 'None'
    plt.figure(figsize=(20,10))
    i=0
    while True:
        i+=1
        plt.ylim(0,100)
        plt.xlim(0,N)
        _cpu=data.cpu(pid,process)
        _mem=data.mem(pid, process)
        _disk=data.disk()
	_io=data.io()
        print i,'\t',_cpu,'\t',_mem,'\t',_disk,'\t',_io
        cpu.append(_cpu)
        mem.append(_mem)
        #disk.append(_disk)
	#io.append(_io)
        plt.grid(True)
        plt.xlabel('TIME IN S')
        plt.ylabel('USAGE IN %')
        plt.title(' - - SYSTEM MONITOR - - ')
        cpu_label='CPU ('+_cpu+'%)'
	mem_label='MEM ('+_mem+'%)'
	disk_label='DISK ('+_disk+'KB/S)'
	io_label='IO ('+_io+'KB/S)'
        plt.plot(cpu[-60:-1],'g', label=cpu_label)
        plt.plot(mem[-60:-1],'r', label=mem_label)
	plt.plot(disk[-60:-1],'k', label=disk_label)
	plt.plot(io[-60:-1],'b', label=io_label)
	plt.legend(loc='upper center', bbox_to_anchor=(0.5, -0.06,0,0.04), ncol=5)
	if len(cpu)>N:
            del cpu[0]
	    del mem[0]
	    #del disk[0]
	    #del io[0]
        plt.draw()
        matplotlib.interactive(True)
	plt.show()
        plt.clf()
Ejemplo n.º 4
0
def main():
    if len(sys.argv) <= 1:
        print "Specify a process to monitor"
        sys.exit(1)
    process = sys.argv[1]
    pid = get_pid(process)
    if pid == "":
        print "No PID found"
        sys.exit(1)
    print "Process: %s" % process
    print "Pid: %s" % pid
    while True:
        _cpu = data.cpu(pid, process)
        _mem = data.mem(pid, process)
        _disk = data.disk()
        _io = data.io()
        print "CPU (", _cpu, "%) - MEM (", _mem, "%) - DISK (", _disk, "KB/S) - IO (", _io, "KB/S)"
Ejemplo n.º 5
0
def main():
    if len(sys.argv) <= 1:
        print "Specify a process to monitor"
        sys.exit(1)
    process = sys.argv[1]
    pid = get_pid(process)
    if pid == "":
        print "No PID found"
        sys.exit(1)
    print "Process: %s" % process
    print "Pid: %s" % pid
    while True:
        _cpu = data.cpu(pid, process)
        _mem = data.mem(pid, process)
        _disk = data.disk()
        _io = data.io()
        print 'CPU (', _cpu, '%) - MEM (', _mem, '%) - DISK (', _disk, 'KB/S) - IO (', _io, 'KB/S)'