aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Lasseter <nat.lasseter@york.ac.uk>2020-11-03 15:51:58 +0000
committerNat Lasseter <nat.lasseter@york.ac.uk>2020-11-03 15:51:58 +0000
commit4823c4515895714c118f6add8c5642bdcec228d5 (patch)
tree05f5e9480a3ffbffc37b0bea2662a421913fcd86
parent0940a2469969403c7cb61f00bb5496da803ec8f3 (diff)
Add --test flag for testing new raiders
-rw-r--r--lib/longboat/config.rb13
-rwxr-xr-xlongboat12
2 files changed, 17 insertions, 8 deletions
diff --git a/lib/longboat/config.rb b/lib/longboat/config.rb
index 7e793c1..f235154 100644
--- a/lib/longboat/config.rb
+++ b/lib/longboat/config.rb
@@ -5,15 +5,18 @@ module Longboat
def self.parse!
Optimist::options do
# Collection interval
- opt :raid_every, "Collection interval", type: Integer, default: 60
+ opt :raid_every, "Collection interval", type: Integer, default: 60
# Job data
- 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_"
+ 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"
+
+ # Testing
+ opt :test, "Output metrics to stdout and quit", type: TrueClass, default: false
end
end
end
diff --git a/longboat b/longboat
index b4f0dee..658ec27 100755
--- a/longboat
+++ b/longboat
@@ -9,7 +9,13 @@ config = Longboat::Config.parse!
# Start collection
collector = Longboat::Collector.new(config)
raiders = Longboat::Raiders.new(collector, config)
-t = raiders.raid_every
-# Serve metrics on HTTP
-Longboat::Server.serve!(collector, config)
+if config.test
+ # We're in test mode, output metrics to stdout once and quit
+ raiders.raid!
+ puts collector.prometheus_metrics
+else
+ # Serve metrics on HTTP forever
+ raiders.raid_every
+ Longboat::Server.serve!(collector, config)
+end