def repl(): global s shell = Monitor('rohit') cls() cls() curEpocs1 = time.time() curEpocs2 = time.time() lastBytes = 0 while True: cpu, mem = map( float, shell.run( "ps axo pcpu,pmem | awk '{sum += $0; pmem += $2} END {print sum/8, pmem}'" ).split(' ')) #cpu = 0 #for core in gtop.cpu().cpus: # cpu += 100.0 * (core.user+core.sys) / core.total #print cpu #cpu /= 8 if cpu > 100.0: cpu = 100 # Happens on Intel multicores mem = 1.0 * gtop.mem().user / gtop.mem().total * ( gtop.mem().total / 1024.0 / 1024.0 / 1024.0) #3.98 temp = float( shell.run( """sensors | grep temp1 | head -1 | awk '{print $2}' | sed 's/+//' | sed 's/.C//'""" )) netload = gtop.netload('eth0') curEpocs2 = time.time() net = (netload.bytes_total - lastBytes) / (curEpocs2 - curEpocs1) / 1024 #kbps lastBytes = netload.bytes_total curEpocs1 = curEpocs2 if net > 999: net /= 1024 netstr = "%.1fM" % net else: netstr = "%.1fK" % net goto(0, 0) pl("%.1f%% " % cpu) goto(0, 6) pl("%0.1fG" % mem) goto(0, 11) pl("%0.1fC" % temp) goto(1, 0) pl(time.strftime("%H:%M:%S")) goto(1, 9) pl(netstr.zfill(7)) #sound_data = getFFT() #for i in range(samples): # don't have sound data for now # writenum(s, sound_data[i] % 8) time.sleep(0.4)
def get_mem_info(): ''' get the memory info @return: a float num for the total memory GB value ''' value1 = round(gtop.mem().dict()['total'] / 1000.0 / 1000 / 1024, 1) value2 = round(value1, 0) if abs(value1 - value2) > 0.2: return value1 return value2
def repl(): global s shell = Monitor('rohit') cls() cls() curEpocs1 = time.time() curEpocs2 = time.time() lastBytes = 0 while True: cpu, mem = map(float, shell.run("ps axo pcpu,pmem | awk '{sum += $0; pmem += $2} END {print sum/8, pmem}'").split(' ')) #cpu = 0 #for core in gtop.cpu().cpus: # cpu += 100.0 * (core.user+core.sys) / core.total #print cpu #cpu /= 8 if cpu > 100.0: cpu = 100 # Happens on Intel multicores mem = 1.0 * gtop.mem().user / gtop.mem().total * (gtop.mem().total/1024.0/1024.0/1024.0)#3.98 temp = float(shell.run("""sensors | grep 'Core.*+' | awk '{print $3}' | sed 's/+//' | sed 's/.C//' | awk '{sum+=$0} END {print sum/4}'""")) netload = gtop.netload('eth0') curEpocs2 = time.time() net = (netload.bytes_total - lastBytes) / (curEpocs2 - curEpocs1) / 1024 #kbps lastBytes = netload.bytes_total curEpocs1 = curEpocs2 if net > 999: net /= 1024 netstr = "%.2fM" % net else: netstr = "%.2fK" % net goto(0,0) pl("%.1f%% " % cpu) goto(0, 6) pl("%0.1fG" % mem) goto(0,11) pl("%0.1fC" % temp) goto(1,0) pl(time.strftime("%H:%M:%S")) goto(1,9) pl(netstr.zfill(7)) #sound_data = getFFT() #for i in range(samples): # don't have sound data for now # writenum(s, sound_data[i] % 8) time.sleep(0.4)
def _get_mem_info(self): return gtop.mem()
def _get_memory_info(self): return gtop.mem().dict()