diff options
author | Nat Lasseter <nat.lasseter@york.ac.uk> | 2020-03-02 14:30:43 +0000 |
---|---|---|
committer | Nat Lasseter <nat.lasseter@york.ac.uk> | 2020-03-02 14:30:43 +0000 |
commit | 96537e39ae2faa4c7801423055db26b86f875431 (patch) | |
tree | 700ccc30e5157c0aeac571b0e8f0e04cc6a5a713 /lib/jobs | |
parent | cd0f6b103553f547bc21a8447e785c31f7ce858c (diff) |
Broke apart job running and metric collection. Jobs are now picked up automagically from lib/jobs
Diffstat (limited to 'lib/jobs')
-rw-r--r-- | lib/jobs/slurm_job_states.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/jobs/slurm_job_states.rb b/lib/jobs/slurm_job_states.rb new file mode 100644 index 0000000..bc3e8a1 --- /dev/null +++ b/lib/jobs/slurm_job_states.rb @@ -0,0 +1,26 @@ +class SlurmJobStates + def initialize(collector) + @collector = collector + end + + def run + start_time = (Time.now - 60).strftime("%H:%M:%S") + raw = `sacct -a -P -o State -S #{start_time}`.lines.map(&:strip)[1..-1] + + tally = Hash.new{0} + + raw.each do |state| + tally[state] += 1 + end + + tally.each do |state, number| + @collector.report!( + "longboat_slurm_job_states", + number, + help: "Number of jobs in each state", + type: "gauge", + labels: {state: state} + ) + end + end +end |