From 6aa7d400a8b519ba090a9d52ffb00051af3be5cb Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Sat, 17 Nov 2012 23:28:53 +0000 Subject: WARN: The user if there is no status/content test for HTTP, or banner for TCP-tests. --- lib/custodian/parser.rb | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'lib/custodian/parser.rb') diff --git a/lib/custodian/parser.rb b/lib/custodian/parser.rb index 88d81fc..f9fc89f 100644 --- a/lib/custodian/parser.rb +++ b/lib/custodian/parser.rb @@ -387,8 +387,12 @@ class MonitorConfig # # TCP-tests will include a banner, optionally # - if ( line =~ /\s+with\s+banner\s+'([^']+)'/ ) - test[:banner]=$1.dup + if ( test[:test_type] =~ /tcp/ ) + if ( line =~ /\s+with\s+banner\s+'([^']+)'/ ) + test[:banner]=$1.dup + else + puts "You did not specify a banner to match against in line: #{line}" + end end @@ -407,13 +411,24 @@ class MonitorConfig # http://example.vm/ must run http with status 200 and content 'OK'. # # - if ( line =~ /\s+with\s+status\s+([0-9]+)\s+/ ) - test[:http_status]=$1.dup - end - if ( line =~ /\s+with\s+content\s+'([^']+)'/ ) - test[:http_text]=$1.dup + if ( test[:test_type] =~ /^https?/ ) + found = 0 + + if ( line =~ /\s+with\s+status\s+([0-9]+)\s+/ ) + test[:http_status]=$1.dup + found += 1 + end + if ( line =~ /\s+with\s+content\s+'([^']+)'/ ) + test[:http_text]=$1.dup + found += 1 + end + + if ( found == 0 ) + puts "WARNING: Neither an expected text, or a status code, were specified in the line: #{line}" + end end + # # These are special cased for the DNS types # -- cgit v1.2.1