bug fix top processes

This commit is contained in:
Usman Nasir
2020-05-03 22:02:44 +05:00
parent b20af734dd
commit d297bbb43b

View File

@@ -580,6 +580,8 @@ def topProcessesStatus(request):
## Memory ## Memory
logging.CyberCPLogFileWriter.writeToFile(str(memory))
if memory[3].find('+') > -1: if memory[3].find('+') > -1:
memoryFinal = memory[3].split('+')[0] memoryFinal = memory[3].split('+')[0]
else: else:
@@ -587,6 +589,7 @@ def topProcessesStatus(request):
data['totalMemory'] = str(int(float(memoryFinal) / 1024)) + 'MB' data['totalMemory'] = str(int(float(memoryFinal) / 1024)) + 'MB'
## ##
if memory[5].find('free') > -1: if memory[5].find('free') > -1:
@@ -594,6 +597,7 @@ def topProcessesStatus(request):
else: else:
data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB' data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB'
## ##
if memory[7].find('used') > -1: if memory[7].find('used') > -1:
@@ -601,13 +605,21 @@ def topProcessesStatus(request):
else: else:
data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB' data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB'
if memory[9].find('buff') > -1:
data['buffCache'] = str(int(float(memory[8]) / 1024)) + 'MB' try:
else: if memory[9].find('buff') > -1:
data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB' data['buffCache'] = str(int(float(memory[8]) / 1024)) + 'MB'
else:
data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB'
except:
logging.CyberCPLogFileWriter.writeToFile(memory[8])
data['buffCache'] = str(int(float(memory[8].split('+')[0]) / 1024)) + 'MB'
## Swap ## Swap
logging.CyberCPLogFileWriter.writeToFile(str(swap))
data['swapTotalMemory'] = str(int(float(swap[2]) / 1024)) + 'MB' data['swapTotalMemory'] = str(int(float(swap[2]) / 1024)) + 'MB'
data['swapFreeMemory'] = str(int(float(swap[4]) / 1024)) + 'MB' data['swapFreeMemory'] = str(int(float(swap[4]) / 1024)) + 'MB'