summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-18 12:02:35 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-18 12:02:35 +0000
commit37bb5d0b2c086194311b5e36d9f4f6356e8ba383 (patch)
tree0cd1325ff5f2e00f2a3876a6879a1edd330603c4 /lib
parent43e4e6b7b88846879e2aab6377ad6fe1621bb12e (diff)
Updated
Diffstat (limited to 'lib')
-rw-r--r--lib/custodian/parser.rb32
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/custodian/parser.rb b/lib/custodian/parser.rb
index f9fc89f..77adc48 100644
--- a/lib/custodian/parser.rb
+++ b/lib/custodian/parser.rb
@@ -21,8 +21,7 @@ require 'uri'
# but in practice it manages to successfully parse each of the configuration
# files that we currently maintain @ Bytemark.
#
-# If there are any lines which are not recognized the class will terminate
-# with an error.
+# If there are any lines which are not recognized the class will raise an exception.
#
# Steve
# --
@@ -60,7 +59,7 @@ class MonitorConfig
@MACROS = Hash.new()
@queue = Beanstalk::Pool.new(['127.0.0.1:11300'])
@file = filename
- @timeout = 12
+ @timeout = 15
raise ArgumentError, "Missing configuration file!" if ( @file.nil? )
raise ArgumentError, "File not found: #{@file}" unless ( File.exists?( @file) )
@@ -145,7 +144,7 @@ class MonitorConfig
val = Array.new
#
- # Get the name
+ # Get the name of the macro.
#
name = $1.dup if ( line =~ /^([1-2A-Z_]+)\s+/ )
@@ -314,14 +313,6 @@ class MonitorConfig
end
#
- # Alert text will have a default, which may be overridden.
- #
- alert = "#{service} failed"
- if ( line =~ /otherwise '([^']+)'/ )
- alert=$1.dup
- end
-
- #
# All our service tests, except ping, require a port - we setup the defaults here,
# but the configuration file will allow users to specify an alternative
# via " on XXX ".
@@ -378,13 +369,28 @@ class MonitorConfig
:target_host => host,
:test_type => service,
:test_port => port,
- :test_alert => alert,
:verbose => true,
:timeout => @timeout
}
#
+ # Alert text will have a default, which may be overridden.
+ #
+ alert = "#{service} failed on #{host}"
+ if ( line =~ /otherwise '([^']+)'/ )
+ alert=$1.dup
+ end
+
+ #
+ # Store the alert
+ #
+ # Note: We do this in the loop so that we can have "on $host" with
+ # the per-test hostname inserted.
+ #
+ test[:test_alert] = alert
+
+ #
# TCP-tests will include a banner, optionally
#
if ( test[:test_type] =~ /tcp/ )