Skip to content

Commit

Permalink
Allow selection of specific cgroup params for cgroup metrics plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
natefoo committed May 3, 2018
1 parent f8606a8 commit ab8542a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion config/job_metrics_conf.xml.sample
Expand Up @@ -38,9 +38,15 @@
<!-- <env variables="HOSTNAME,SLURM_CPUS_ON_NODE,SLURM_JOBID" /> -->

<!-- If galaxy jobs are run in cgroups, like slurm does if memory limits
are enforced, we can try to grep some information from this. -->
are enforced, we can try to grep some information from this. By default,
only a small set of cgroup parameters will be recorded, the list of which
can be found in lib/galaxy/jobs/metrics/instrumenters/cgroup.py. -->
<!-- <cgroup /> -->
<!-- All params from the `cpuacct,cpu` and `memory` controllers can be
recorded. -->
<!-- <cgroup verbose="true" /> -->
<!-- Or, specific params can be recorded. -->
<!-- <cgroup params="cpuacct.usage,memory.max_usage_in_bytes,memory.memsw.max_usage_in_bytes" /> -->

<!-- Uncomment to record hostname - *nix only -->
<!-- <hostname /> -->
Expand Down
8 changes: 7 additions & 1 deletion lib/galaxy/jobs/metrics/instrumenters/cgroup.py
Expand Up @@ -54,6 +54,12 @@ class CgroupPlugin(InstrumentPlugin):

def __init__(self, **kwargs):
self.verbose = asbool(kwargs.get("verbose", False))
params_str = kwargs.get("params", None)
if params_str:
params = [v.strip() for v in params_str.split(",")]
else:
params = TITLES.keys()
self.params = params

def post_execute_instrument(self, job_directory):
commands = []
Expand Down Expand Up @@ -92,7 +98,7 @@ def __read_metrics(self, path):
return metrics

def __add_metric(self, metrics, metric):
if metric and (metric.subkey in TITLES or self.verbose):
if metric and (metric.subkey in self.params or self.verbose):
metrics[metric.subkey] = metric.value

def __read_key_value(self, line, prev_metric):
Expand Down

0 comments on commit ab8542a

Please sign in to comment.