aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Readme.textile12
-rw-r--r--lib/longboat.rb2
-rw-r--r--lib/longboat/config.rb10
-rw-r--r--lib/longboat/raiders.rb (renamed from lib/longboat/jobs.rb)24
-rw-r--r--lib/raiders/slurm_job_states.rb (renamed from lib/jobs/slurm_job_states.rb)4
-rwxr-xr-xlongboat4
6 files changed, 29 insertions, 27 deletions
diff --git a/Readme.textile b/Readme.textile
index d5f5f3a..7d993d5 100644
--- a/Readme.textile
+++ b/Readme.textile
@@ -2,17 +2,19 @@ h1. Longboat
Longboat is a metric collection system. Intended for Viking, but theoretically generic.
-h2. Jobs
+h2. Raiders
-Longboat will pick up all jobs in the lib/jobs directory. Each job consists of:
+Raiders go out, raid things, and return to the longboat with metrics for the collector.
-* a file with a snake_case name, such as @my_job.rb@
+Longboat will pick up all raiders in the lib/raiders directory. Each raider consists of:
+
+* a file with a snake_case name, such as @my_raider.rb@
* containing a single class with a CamelCase name matching the file name, such as @MyJob@
* with two methods:
** @initialize@, which takes two arguments of:
*** the collector to @report!@ the metrics to, and
-*** a hash containing config relevant to jobs
-** @run@, no arguments, which triggers a job run and metric report
+*** a hash containing config relevant to raiders
+** @raid@, no arguments, which triggers a raid and metric report
@Longboat::Collector#report!@ takes as arguments:
diff --git a/lib/longboat.rb b/lib/longboat.rb
index 6383558..bbbac52 100644
--- a/lib/longboat.rb
+++ b/lib/longboat.rb
@@ -1,4 +1,4 @@
require 'longboat/collector'
require 'longboat/config'
-require 'longboat/jobs'
+require 'longboat/raiders'
require 'longboat/server'
diff --git a/lib/longboat/config.rb b/lib/longboat/config.rb
index 3fd1510..7e793c1 100644
--- a/lib/longboat/config.rb
+++ b/lib/longboat/config.rb
@@ -5,15 +5,15 @@ module Longboat
def self.parse!
Optimist::options do
# Collection interval
- opt :collect_every, "Collection interval", type: Integer, default: 60
+ opt :raid_every, "Collection interval", type: Integer, default: 60
# Job data
- opt :jobs_path, "Paths to search for jobs", type: String, default: "./lib/jobs", multi: true
- opt :metric_prefix, "Prefix for metric names", type: String, default: "longboat_"
+ opt :raiders_path, "Paths to search for raiders", type: String, default: "./lib/raiders", multi: true
+ opt :metric_prefix, "Prefix for metric names", type: String, default: "longboat_"
# Sinatra server
- opt :server_bind, "Server listening address", type: String, default: "127.0.0.1:8564"
- opt :server_path, "Path to metrics", type: String, default: "/metrics"
+ opt :server_bind, "Server listening address", type: String, default: "127.0.0.1:8564"
+ opt :server_path, "Path to metrics", type: String, default: "/metrics"
end
end
end
diff --git a/lib/longboat/jobs.rb b/lib/longboat/raiders.rb
index 5166993..103cac5 100644
--- a/lib/longboat/jobs.rb
+++ b/lib/longboat/raiders.rb
@@ -1,11 +1,11 @@
module Longboat
- class Jobs
+ class Raiders
def initialize(collector, config)
@collector = collector
- @jobs = []
+ @raiders = []
@config = config
- @config[:jobs_path].each do |dir|
+ @config[:raiders_path].each do |dir|
next unless Dir.exist?(dir)
Dir.entries(dir).each do |file|
@@ -14,27 +14,27 @@ module Longboat
reqname = File.basename(file, ".rb")
cname = reqname.split('_').map(&:capitalize).join
- require "jobs/#{reqname}"
- @jobs << Kernel.const_get(cname).new(@collector, job_config)
+ require "raiders/#{reqname}"
+ @raiders << Kernel.const_get(cname).new(@collector, raider_config)
end
end
end
- def collect!
- @jobs.each(&:run)
+ def raid!
+ @raiders.each(&:raid)
end
- def collect_every(time = @config[:collect_every], async = true)
+ def raid_every(time = @config[:raid_every], async = true)
if async
Thread.new do
loop do
- collect!
+ raid!
sleep(time)
end
end
else
loop do
- collect!
+ raid!
sleep(time)
end
end
@@ -42,8 +42,8 @@ module Longboat
private
- def job_config
- @config.slice(:collect_every, :metric_prefix)
+ def raider_config
+ @config.slice(:raid_every, :metric_prefix)
end
end
end
diff --git a/lib/jobs/slurm_job_states.rb b/lib/raiders/slurm_job_states.rb
index 1211f11..20b69c8 100644
--- a/lib/jobs/slurm_job_states.rb
+++ b/lib/raiders/slurm_job_states.rb
@@ -1,10 +1,10 @@
class SlurmJobStates
def initialize(collector, config)
@collector = collector
- @interval = config[:collect_every]
+ @interval = config[:raid_every]
end
- def run
+ def raid
start_time = (Time.now - @interval).strftime("%H:%M:%S")
# Get raw data from sacct,
diff --git a/longboat b/longboat
index 2631d45..b4f0dee 100755
--- a/longboat
+++ b/longboat
@@ -8,8 +8,8 @@ config = Longboat::Config.parse!
# Start collection
collector = Longboat::Collector.new(config)
-jobs = Longboat::Jobs.new(collector, config)
-t = jobs.collect_every
+raiders = Longboat::Raiders.new(collector, config)
+t = raiders.raid_every
# Serve metrics on HTTP
Longboat::Server.serve!(collector, config)