summaryrefslogtreecommitdiff
path: root/bin/custodian-enqueue
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-13 22:19:53 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-13 22:19:53 +0000
commit8d7db2d53b32bbec7924e2548112a28dd8866aaf (patch)
treeff6297b2174db847ccb07b9fb5bb0988c8b915bb /bin/custodian-enqueue
parentb2f331ae09a295ea2fd2923ed9ab7de18fceba04 (diff)
Added --help/--manual flags
Diffstat (limited to 'bin/custodian-enqueue')
-rwxr-xr-xbin/custodian-enqueue80
1 files changed, 74 insertions, 6 deletions
diff --git a/bin/custodian-enqueue b/bin/custodian-enqueue
index e92c49b..ce147c7 100755
--- a/bin/custodian-enqueue
+++ b/bin/custodian-enqueue
@@ -1,10 +1,40 @@
#!/usr/bin/ruby1.8
#
-# Notes
+# NAME
+# custodian-enqueue - Insert sentinel-probes into a queue.
#
-# Macros may be defined either literally, or as a result of a HTTP-fetch.
-# Macro names match the pattern "^[0-9A-Z_]$"
+# SYNOPSIS
+# custodian-enqueue [ -h | --help ] [-m | --manual] [--file | -f FILE] [--dump | -d ]
#
+# OPTIONS
+#
+# -h, --help Show a help message, and exit.
+#
+# -m, --manual Show this manual, and exit.
+#
+# -d, --dump Dump the generated JSON to the console; don't insert in the queue.
+#
+# -f, --file FILE Parse the given configuration file.
+#
+# ABOUT
+#
+# This tool reads a single configuration file and parses it into a
+# series of network & protocol tests. These tests are serialized
+# into JSON, and stored in a beanstalkd queue.
+#
+# The intention is that the tests will be pulled from the queue and
+# executed by the companion program custodian-dequeue. The dequeing
+# process may occur up numerous other hosts
+#
+# CONFIGURATION FILE
+#
+# The configuration file is 99% compatible with that used in the tool
+# custodian replaces.
+#
+#
+# AUTHOR
+#
+# Steve Kemp <steve@bytemark.co.uk>
#
@@ -447,18 +477,26 @@ end
#
if __FILE__ == $0 then
+ $help = false
+ $manual = false
begin
opts = GetoptLong.new(
- [ "--dump", "-d", GetoptLong::NO_ARGUMENT ],
- [ "--file", "-f", GetoptLong::REQUIRED_ARGUMENT ]
+ [ "--dump", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--file", "-f", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ],
+ [ "--manual","-m", GetoptLong::NO_ARGUMENT ]
)
opts.each do |opt, arg|
case opt
when "--dump":
ENV["DUMP"] = "1"
when "--file":
- ENV["FILE"] = arg
+ ENV["FILE"] = arge
+ when "--help":
+ $help = true
+ when "--manual":
+ $manual = true
end
end
rescue StandardError => ex
@@ -466,6 +504,36 @@ if __FILE__ == $0 then
exit
end
+
+ #
+ # CAUTION! Here be quality kode.
+ #
+ if $manual or $help
+
+ # Open the file, stripping the shebang line
+ lines = File.open(__FILE__){|fh| fh.readlines}[1..-1]
+
+ found_synopsis = false
+
+ lines.each do |line|
+
+ line.chomp!
+ break if line.empty?
+
+ if $help and !found_synopsis
+ found_synopsis = (line =~ /^#\s+SYNOPSIS\s*$/)
+ next
+ end
+
+ puts line[2..-1].to_s
+
+ break if $help and found_synopsis and line =~ /^#\s*$/
+
+ end
+
+ exit 0
+ end
+
mon = MonitorConfig.new( ENV['FILE'] )
mon.parse_file();
end