aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNat Lasseter <nat.lasseter@york.ac.uk>2020-03-17 10:11:38 +0000
committerNat Lasseter <nat.lasseter@york.ac.uk>2020-03-17 10:11:38 +0000
commitaa71ddb4b8af22a5b9ca050b4ee82bc29732d344 (patch)
treeaff7cbe9a25f1259a00cf96b1dac85d07472ace5 /lib
parent91384f35f325a7adb911ce6336aefe1cd4d81d74 (diff)
Broke out Viking raiders into new repo to keep longboat generic
Diffstat (limited to 'lib')
-rw-r--r--lib/raiders/.gitkeep0
-rw-r--r--lib/raiders/slurm_job_states.rb41
2 files changed, 0 insertions, 41 deletions
diff --git a/lib/raiders/.gitkeep b/lib/raiders/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/raiders/.gitkeep
diff --git a/lib/raiders/slurm_job_states.rb b/lib/raiders/slurm_job_states.rb
deleted file mode 100644
index 20b69c8..0000000
--- a/lib/raiders/slurm_job_states.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-class SlurmJobStates
- def initialize(collector, config)
- @collector = collector
- @interval = config[:raid_every]
- end
-
- def raid
- start_time = (Time.now - @interval).strftime("%H:%M:%S")
-
- # Get raw data from sacct,
- # read jobs into an array,
- # remove any whitespace from the ends of each string,
- # drop the header,
- # and split each line into state and partition
- raw = `sacct -a -P -o State,Partition -S #{start_time}`.
- lines.
- map(&:strip)[1..-1].
- map{|l|l.split("|")}
-
- # Make a tally of each state/partition combo
- tally = Hash.new{0}
- raw.each do |job|
- tally[job] += 1
- end
-
- # Clean up any previously reported metrics
- # to prevent stale labelsets
- @collector.redact!("slurm_job_states")
-
- # Report new metrics
- tally.each do |labelset, number|
- @collector.report!(
- "slurm_job_states",
- number,
- help: "Number of jobs in each state",
- type: "gauge",
- labels: {state: labelset[0], partition: labelset[1]}
- )
- end
- end
-end