eole-mariadb/creolefuncs/mariadb.py

14 lines
399 B
Python
Raw Normal View History

2018-04-11 17:00:18 +02:00
# -*- coding: utf-8 -*-
def getMemoryPercentage(percent):
import os
try:
percent = int(percent)
totalMemory = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
memoryToUse = (totalMemory*percent)/100
memoryMb = memoryToUse/(1024.**2)
2018-04-12 09:24:54 +02:00
return "{0}M".format(int(memoryMb))
2018-04-11 17:00:18 +02:00
except:
return "Error during memory percentage calculation"