aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Lasseter <nat.lasseter@york.ac.uk>2020-11-11 15:43:56 +0000
committerNat Lasseter <nat.lasseter@york.ac.uk>2020-11-11 15:43:56 +0000
commitfdc0cc08592e4606e684951b5e2503832b15d148 (patch)
treea7cd4945c95c14a8ebcd867c8a8cbdfadbe58ea7
parentbc57c085e987f831ee50798109d6bc114182c22c (diff)
slurm_number_jobs rubocop fixes
-rw-r--r--.rubocop.yml7
-rw-r--r--slurm_number_jobs.rb17
2 files changed, 17 insertions, 7 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 48211dc..303f329 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,5 +1,12 @@
Layout/LineLength:
Max: 80
+Metrics/MethodLength:
+ CountAsOne:
+ - 'array'
+ - 'hash'
+ - 'heredoc'
+ Max: 20
+
AllCops:
NewCops: enable
diff --git a/slurm_number_jobs.rb b/slurm_number_jobs.rb
index 0dd3385..91fe630 100644
--- a/slurm_number_jobs.rb
+++ b/slurm_number_jobs.rb
@@ -1,3 +1,7 @@
+# frozen_string_literal: true
+
+# Report the number of jobs currently in queue,
+# aggregated by state, user, and partition
class SlurmNumberJobs
def initialize(collector, config)
@collector = collector
@@ -6,20 +10,19 @@ class SlurmNumberJobs
def raid
raw = `squeue --format="%P,%u,%T" --noheader`
- raw = raw.lines
- raw = raw.map(&:strip)
- raw = raw.map{ |line| line.split(',') }
+ raw = raw.lines.map(&:strip)
+ raw = raw.map { |line| line.split(',') }
tally = raw.tally
- @collector.redact!("slurm_number_jobs")
+ @collector.redact!('slurm_number_jobs')
tally.each do |labelset, number|
@collector.report!(
- "slurm_number_jobs",
+ 'slurm_number_jobs',
number,
- help: "Number of jobs for a given user, partition, and state",
- type: "gauge",
+ help: 'Number of jobs for a given user, partition, and state',
+ type: 'gauge',
labels: {
partition: labelset[0],
user: labelset[1],