mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add metric to the core plugin to collect $GALAXY_MEMORY_MB
This commit is contained in:
@@ -8,6 +8,7 @@ from ...metrics import formatting
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
GALAXY_SLOTS_KEY = "galaxy_slots"
|
||||
GALAXY_MEMORY_MB_KEY = "galaxy_memory_mb"
|
||||
START_EPOCH_KEY = "start_epoch"
|
||||
END_EPOCH_KEY = "end_epoch"
|
||||
RUNTIME_SECONDS_KEY = "runtime_seconds"
|
||||
@@ -19,6 +20,8 @@ class CorePluginFormatter(formatting.JobMetricFormatter):
|
||||
value = int(value)
|
||||
if key == GALAXY_SLOTS_KEY:
|
||||
return ("Cores Allocated", "%d" % value)
|
||||
elif key == GALAXY_MEMORY_MB_KEY:
|
||||
return ("Memory Allocated (MB)", "%d" % value)
|
||||
elif key == RUNTIME_SECONDS_KEY:
|
||||
return ("Job Runtime (Wall Clock)", formatting.seconds_to_str(value))
|
||||
else:
|
||||
@@ -40,6 +43,7 @@ class CorePlugin(InstrumentPlugin):
|
||||
def pre_execute_instrument(self, job_directory):
|
||||
commands = []
|
||||
commands.append(self.__record_galaxy_slots_command(job_directory))
|
||||
commands.append(self.__record_galaxy_memory_mb_command(job_directory))
|
||||
commands.append(self.__record_seconds_since_epoch_to_file(job_directory, "start"))
|
||||
return commands
|
||||
|
||||
@@ -50,9 +54,11 @@ class CorePlugin(InstrumentPlugin):
|
||||
|
||||
def job_properties(self, job_id, job_directory):
|
||||
galaxy_slots_file = self.__galaxy_slots_file(job_directory)
|
||||
galaxy_memory_mb_file = self.__galaxy_memory_mb_file(job_directory)
|
||||
|
||||
properties = {}
|
||||
properties[GALAXY_SLOTS_KEY] = self.__read_integer(galaxy_slots_file)
|
||||
properties[GALAXY_MEMORY_MB_KEY] = self.__read_integer(galaxy_memory_mb_file)
|
||||
start = self.__read_seconds_since_epoch(job_directory, "start")
|
||||
end = self.__read_seconds_since_epoch(job_directory, "end")
|
||||
if start is not None and end is not None:
|
||||
@@ -65,6 +71,10 @@ class CorePlugin(InstrumentPlugin):
|
||||
galaxy_slots_file = self.__galaxy_slots_file(job_directory)
|
||||
return '''echo "$GALAXY_SLOTS" > '%s' ''' % galaxy_slots_file
|
||||
|
||||
def __record_galaxy_memory_mb_command(self, job_directory):
|
||||
galaxy_memory_mb_file = self.__galaxy_memory_mb_file(job_directory)
|
||||
return '''echo "$GALAXY_MEMORY_MB" > '%s' ''' % galaxy_memory_mb_file
|
||||
|
||||
def __record_seconds_since_epoch_to_file(self, job_directory, name):
|
||||
path = self._instrument_file_path(job_directory, "epoch_%s" % name)
|
||||
return 'date +"%s" > ' + path
|
||||
@@ -76,6 +86,9 @@ class CorePlugin(InstrumentPlugin):
|
||||
def __galaxy_slots_file(self, job_directory):
|
||||
return self._instrument_file_path(job_directory, "galaxy_slots")
|
||||
|
||||
def __galaxy_memory_mb_file(self, job_directory):
|
||||
return self._instrument_file_path(job_directory, "galaxy_memory_mb")
|
||||
|
||||
def __read_integer(self, path):
|
||||
value = None
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user