Skip to content

Commit

Permalink
Merge pull request #57 from pkarkazis/master
Browse files Browse the repository at this point in the history
invert memory usage
  • Loading branch information
pkarkazis authored Jul 31, 2019
2 parents 52075a2 + f9650ac commit 35c86fd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sp_mon/VmData.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def prom_parser(self):
for cp in data_['cpu']:
vm_cpu_perc += "vm_cpu_perc{resource_id=\""+self.id+"\", core=\""+str(cp['core'])+"\"}" +str(cp['usage']) + timestamp + '\n'

vm_mem_perc += "vm_mem_perc{resource_id=\""+self.id+"\"}" +str(round(float((data_['ram']['freeRam'])/float(data_['ram']['totalRAM'])*100),2)) + timestamp + '\n'
vm_mem_perc += "vm_mem_perc{resource_id=\""+self.id+"\"}" +str(round(100.0 - (float((data_['ram']['freeRam'])/float(data_['ram']['totalRAM'])*100)),2))+ timestamp + '\n'
vm_mem_free_MB += "vm_mem_free_MB{resource_id=\""+self.id+"\"}" +str(data_['ram']['freeRam']) + timestamp + '\n'
vm_mem_total_MB += "vm_mem_total_MB{resource_id=\""+self.id+"\"}" +str(data_['ram']['totalRAM']) + timestamp + '\n'

Expand Down Expand Up @@ -109,7 +109,7 @@ def prom_parser(self):

def getRAM(self):
meminfo = dict((i.split()[0].rstrip(':'),int(i.split()[1])) for i in open('/proc/meminfo').readlines())
return {"freeRam":meminfo["MemFree"], "totalRAM":meminfo["MemTotal"]}
return {"freeRam":meminfo["MemAvailable"], "totalRAM":meminfo["MemTotal"]}


def getCPU(self):
Expand Down

0 comments on commit 35c86fd

Please sign in to comment.