eole-mariadb/creolefuncs/mariadb.py

14 lines
399 B
Python

# -*- 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 = int(memoryToUse/(1024.**2))
return "{0}M".format(memoryMb)
except:
return "Error during memory percentage calculation"