summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/custodian-dequeue4
-rwxr-xr-xbin/custodian-enqueue6
-rwxr-xr-xbin/custodian-queue10
-rwxr-xr-xbin/multi-ping4
-rw-r--r--lib/custodian/alertfactory.rb4
-rw-r--r--lib/custodian/alerts/mauve.rb26
-rw-r--r--lib/custodian/parser.rb48
-rw-r--r--lib/custodian/protocoltest/dns.rb8
-rw-r--r--lib/custodian/protocoltest/dnsbl.rb8
-rw-r--r--lib/custodian/protocoltest/ftp.rb6
-rw-r--r--lib/custodian/protocoltest/http.rb34
-rw-r--r--lib/custodian/protocoltest/imap.rb4
-rw-r--r--lib/custodian/protocoltest/jabber.rb4
-rw-r--r--lib/custodian/protocoltest/ldap.rb14
-rw-r--r--lib/custodian/protocoltest/mx.rb10
-rw-r--r--lib/custodian/protocoltest/mysql.rb4
-rw-r--r--lib/custodian/protocoltest/named.rb4
-rw-r--r--lib/custodian/protocoltest/openproxy.rb2
-rw-r--r--lib/custodian/protocoltest/ping.rb20
-rw-r--r--lib/custodian/protocoltest/pop3.rb4
-rw-r--r--lib/custodian/protocoltest/postgresql.rb4
-rw-r--r--lib/custodian/protocoltest/redis.rb4
-rw-r--r--lib/custodian/protocoltest/rsync.rb6
-rw-r--r--lib/custodian/protocoltest/smtp.rb4
-rw-r--r--lib/custodian/protocoltest/smtprelay.rb8
-rw-r--r--lib/custodian/protocoltest/ssh.rb4
-rw-r--r--lib/custodian/protocoltest/ssl.rb6
-rw-r--r--lib/custodian/protocoltest/tcp.rb36
-rw-r--r--lib/custodian/protocoltest/telnet.rb4
-rw-r--r--lib/custodian/queue.rb4
-rw-r--r--lib/custodian/settings.rb12
-rw-r--r--lib/custodian/testfactory.rb10
-rw-r--r--lib/custodian/util/bytemark.rb2
-rw-r--r--lib/custodian/util/dns.rb2
-rw-r--r--lib/custodian/util/ping.rb8
-rw-r--r--lib/custodian/util/timespan.rb10
-rw-r--r--lib/custodian/worker.rb16
-rwxr-xr-xt/test-custodian-alertfactory.rb4
-rwxr-xr-xt/test-custodian-parser.rb6
-rwxr-xr-xt/test-custodian-testfactory.rb4
-rwxr-xr-xt/test-custodian-util-bytemark.rb2
41 files changed, 190 insertions, 190 deletions
diff --git a/bin/custodian-dequeue b/bin/custodian-dequeue
index a411746..48dea57 100755
--- a/bin/custodian-dequeue
+++ b/bin/custodian-dequeue
@@ -136,7 +136,7 @@ if __FILE__ == $PROGRAM_NAME then
#
# Single step?
#
- if ( ENV['SINGLE'] )
+ if ENV['SINGLE']
worker.process_single_job
exit(0)
end
@@ -144,7 +144,7 @@ if __FILE__ == $PROGRAM_NAME then
#
# Run until we see a failure?
#
- if ( ENV['FAIL'] )
+ if ENV['FAIL']
worker.process_until_fail
exit(0)
end
diff --git a/bin/custodian-enqueue b/bin/custodian-enqueue
index 568c0d6..b1be84d 100755
--- a/bin/custodian-enqueue
+++ b/bin/custodian-enqueue
@@ -131,7 +131,7 @@ if __FILE__ == $PROGRAM_NAME then
#
settings = Custodian::Settings.instance
queue = Custodian::QueueType.create( settings.queue_type )
- if ( ! queue )
+ if ! queue
puts "Failed to connect to the #{settings.queue_type} queue"
exit 1
end
@@ -157,9 +157,9 @@ if __FILE__ == $PROGRAM_NAME then
mon.jobs.each do |test|
- if ( ENV['TEST'] )
+ if ENV['TEST']
# nop
- elsif ( ENV['DUMP'] )
+ elsif ENV['DUMP']
puts test
else
queue.add( test.to_s )
diff --git a/bin/custodian-queue b/bin/custodian-queue
index 9dec58a..66bf2ba 100755
--- a/bin/custodian-queue
+++ b/bin/custodian-queue
@@ -72,7 +72,7 @@ if __FILE__ == $PROGRAM_NAME then
opts.each do |opt, arg|
case opt
when "--monitor" then
- if ( arg )
+ if arg
$MONITOR = arg.to_i
else
$MONITOR = 5000
@@ -130,14 +130,14 @@ if __FILE__ == $PROGRAM_NAME then
#
# Alerting on a queue that is too-full?
#
- if ( !$MONITOR.nil? )
+ if !$MONITOR.nil?
#
# Find the number of jobs
#
jobs = queue.size?
- if ( jobs > $MONITOR )
+ if jobs > $MONITOR
exit 1
else
exit 0
@@ -148,7 +148,7 @@ if __FILE__ == $PROGRAM_NAME then
#
# Showing stats?
#
- if ( $STATS )
+ if $STATS
jobs = queue.size?
puts "There are #{jobs || 0} jobs pending."
exit( 0 )
@@ -158,7 +158,7 @@ if __FILE__ == $PROGRAM_NAME then
#
# Are we flushing the queue?
#
- if ( $FLUSH )
+ if $FLUSH
queue.flush!
end
diff --git a/bin/multi-ping b/bin/multi-ping
index 9833215..9760b35 100755
--- a/bin/multi-ping
+++ b/bin/multi-ping
@@ -105,7 +105,7 @@ hostname = ARGV.shift
#
# Abort if we don't have a hostname
#
-if ( hostname.nil? )
+if hostname.nil?
puts "Usage: #{$PROGRAM_NAME} hostname"
exit 1
end
@@ -121,7 +121,7 @@ helper = Custodian::Util::Ping.new( hostname )
#
# Ping the host, via the helper
#
-if ( helper.run_ping )
+if helper.run_ping
puts "#{hostname} - #{helper.address} - is alive."
exit 0
else
diff --git a/lib/custodian/alertfactory.rb b/lib/custodian/alertfactory.rb
index a9b6d3d..1cb4751 100644
--- a/lib/custodian/alertfactory.rb
+++ b/lib/custodian/alertfactory.rb
@@ -46,8 +46,8 @@ module Custodian
#
def self.create( alert_type, obj )
- raise ArgumentError, "The type of notifier to create cannot be nil" if ( alert_type.nil? )
- raise ArgumentError, "The type of notifier to create must be a string" unless ( alert_type.kind_of? String )
+ raise ArgumentError, "The type of notifier to create cannot be nil" if alert_type.nil?
+ raise ArgumentError, "The type of notifier to create must be a string" unless alert_type.kind_of? String
c = @@subclasses[alert_type]
if c
diff --git a/lib/custodian/alerts/mauve.rb b/lib/custodian/alerts/mauve.rb
index dfa4a04..92c38ee 100644
--- a/lib/custodian/alerts/mauve.rb
+++ b/lib/custodian/alerts/mauve.rb
@@ -109,8 +109,8 @@ module Custodian
# If we're Monday-Friday, between the start & end time, then
# we're in the working day.
#
- if ( ( ( wday != 0 ) && ( wday != 6 ) ) &&
- ( hour >= day_start && hour < day_end ) )
+ if ( ( wday != 0 ) && ( wday != 6 ) ) &&
+ ( hour >= day_start && hour < day_end )
working = true
end
@@ -198,10 +198,10 @@ module Custodian
#
subject = @test.target
- if ( ( subject =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ ) ||
- ( subject =~ /^([0-9a-f:]+)$/ ) )
+ if ( subject =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ ) ||
+ ( subject =~ /^([0-9a-f:]+)$/ )
res = Custodian::Util::DNS.ip_to_hostname( subject )
- if ( res )
+ if res
subject = res
end
end
@@ -234,7 +234,7 @@ module Custodian
#
# If we're raising then add the error
#
- if ( failure )
+ if failure
alert.detail = "<p>The #{test_type} test failed against #{test_host}.</p>"
@@ -246,7 +246,7 @@ module Custodian
#
# Add the user-detail if present
#
- alert.detail = "#{alert.detail}<p>#{user_text}</p>" if ( !user_text.nil? )
+ alert.detail = "#{alert.detail}<p>#{user_text}</p>" if !user_text.nil?
#
# Add the test-failure message
@@ -257,7 +257,7 @@ module Custodian
# Determine if this is inside/outside the bytemark network
#
location = expand_inside_bytemark( test_host )
- if ( !location.nil? && location.length )
+ if !location.nil? && location.length
alert.detail = "#{alert.detail}\n#{location}"
end
end
@@ -282,7 +282,7 @@ module Custodian
# We'll also make the host a link that can be clicked in the alert we raise.
#
target = host
- if ( target =~ /^([a-z]+):\/\/([^\/]+)/ )
+ if target =~ /^([a-z]+):\/\/([^\/]+)/
target = $2.dup
host = "<a href=\"#{host}\">#{host}</a>"
end
@@ -296,8 +296,8 @@ module Custodian
#
# Resolve the target to an IP, unless it is already an address.
#
- if ( ( target =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ ) ||
- ( target =~ /^([0-9a-f:]+)$/ ) )
+ if ( target =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ ) ||
+ ( target =~ /^([0-9a-f:]+)$/ )
resolved = target
else
resolved = Custodian::Util::DNS.hostname_to_ip( target )
@@ -307,13 +307,13 @@ module Custodian
#
# Did we get an error?
#
- return "" unless ( !resolved.nil? )
+ return "" unless !resolved.nil?
#
# Return the formatted message
#
- if ( Custodian::Util::Bytemark.inside?( resolved.to_s ) )
+ if Custodian::Util::Bytemark.inside?( resolved.to_s )
if ( resolved == target )
return "<p>#{host} is inside the Bytemark network.</p>"
else
diff --git a/lib/custodian/parser.rb b/lib/custodian/parser.rb
index bce507b..ae5edb0 100644
--- a/lib/custodian/parser.rb
+++ b/lib/custodian/parser.rb
@@ -124,13 +124,13 @@ module Custodian
#
# Get the name of the macro.
#
- name = $1.dup if ( line =~ /^([0-9A-Z_]+)\s+/ )
+ name = $1.dup if line =~ /^([0-9A-Z_]+)\s+/
#
# Get the value
#
- if ( line =~ /fetched\s+from\s+(.*)[\r\n\.]*$/ )
+ if line =~ /fetched\s+from\s+(.*)[\r\n\.]*$/
#
# HTTP-fetch
@@ -139,10 +139,10 @@ module Custodian
text = getURL(uri)
text.split( /[\r\n]/ ).each do |line|
- val.push( line ) if ( line.length > 0)
+ val.push( line ) if line.length > 0
end
- elsif ( line =~ /\s(is|are)\s+(.*)\.+$/ )
+ elsif line =~ /\s(is|are)\s+(.*)\.+$/
#
# Literal list of hosts
@@ -152,7 +152,7 @@ module Custodian
#
# If there is " and " then tokenize
#
- if ( hosts =~ /\s+and\s+/ )
+ if hosts =~ /\s+and\s+/
tmp = hosts.split( /\s+and\s+/ )
tmp.each do |entry|
val.push( entry )
@@ -165,7 +165,7 @@ module Custodian
end
end
- if ( is_macro?( name ) )
+ if is_macro?( name )
raise ArgumentError, "The macro #{name} is already defined"
end
@@ -214,13 +214,13 @@ module Custodian
r = []
- if ( input =~ /^(\S+)\s+(.*)$/ )
+ if input =~ /^(\S+)\s+(.*)$/
macro=$1.dup
rest=$2.dup
end
- if ( is_macro?( macro ) )
+ if is_macro?( macro )
get_macro_targets(macro).each do |host|
r.push( "#{host} #{rest}" )
end
@@ -239,19 +239,19 @@ module Custodian
raise ArgumentError, "Line is not a string: #{line}" unless( line.kind_of? String )
- line.chomp! if ( !line.nil? )
+ line.chomp! if !line.nil?
- line.strip! if ( !line.nil? )
+ line.strip! if !line.nil?
#
# A blank line, or a comment may be skipped.
#
- return nil if ( ( line.nil? ) || ( line =~ /^#/ ) || ( line.length < 1 ) )
+ return nil if ( line.nil? ) || ( line =~ /^#/ ) || ( line.length < 1 )
#
# Look for a time period.
#
- if ( line =~ /between\s+([0-9]+)-([0-9]+)/i )
+ if line =~ /between\s+([0-9]+)-([0-9]+)/i
#
# The starting/ending hours.
@@ -272,23 +272,23 @@ module Custodian
#
# Should we exclude the test?
#
- if ( line =~ /except\s+between/i )
- return nil if ( inside )
+ if line =~ /except\s+between/i
+ return nil if inside
else
- return nil if ( ! inside )
+ return nil if ! inside
end
end
#
# Look for macro definitions, inline
#
- if ( line =~ /^([0-9A-Z]_+)\s+are\s+fetched\s+from\s+([^\s]+)\.?/ )
+ if line =~ /^([0-9A-Z]_+)\s+are\s+fetched\s+from\s+([^\s]+)\.?/
define_macro( line )
- elsif ( line =~ /^([0-9A-Z_]+)\s+(is|are)\s+/ )
+ elsif line =~ /^([0-9A-Z_]+)\s+(is|are)\s+/
define_macro( line )
- elsif ( line =~ /^(\S+)\s+must\s+ping(.*)/ )
+ elsif line =~ /^(\S+)\s+must\s+ping(.*)/
#
# Ping is a special case because the configuration file entry
# would read:
@@ -310,7 +310,7 @@ module Custodian
new_line = "#{pre} must run ping #{post}"
return( parse_line( new_line ) )
- elsif ( line =~ /^\S+\s+must(\s+not)?\s+run\s+([^\s]+)(\s+|\.|$)/i )
+ elsif line =~ /^\S+\s+must(\s+not)?\s+run\s+([^\s]+)(\s+|\.|$)/i
#
# Expand the macro if we should
@@ -344,7 +344,7 @@ module Custodian
#
job = Custodian::TestFactory.create( macro_expanded )
- if ( job && ( job.kind_of? Array ) )
+ if job && ( job.kind_of? Array )
ret.push( job[0].to_s )
end
rescue => ex
@@ -368,7 +368,7 @@ module Custodian
#
# If we're given a string then split it on newline
#
- if ( text.kind_of?( String ) )
+ if text.kind_of?( String )
a = text.split( /[\r\n]/ )
text = a
end
@@ -392,7 +392,7 @@ module Custodian
# The line was a comment.
#
#
- if ( ret.kind_of?( Array ) )
+ if ret.kind_of?( Array )
ret.each do |probe|
@jobs.push( probe )
end
@@ -411,8 +411,8 @@ module Custodian
#
def parse_file( filename )
- raise ArgumentError, "Missing configuration file!" if ( filename.nil? )
- raise ArgumentError, "File not found: #{@file}" unless ( File.exist?( filename) )
+ raise ArgumentError, "Missing configuration file!" if filename.nil?
+ raise ArgumentError, "File not found: #{@file}" unless File.exist?( filename)
#
# Read the configuration file.
diff --git a/lib/custodian/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb
index 5787881..4bdbd83 100644
--- a/lib/custodian/protocoltest/dns.rb
+++ b/lib/custodian/protocoltest/dns.rb
@@ -47,13 +47,13 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
end
- if ( line =~ /for\s+([^\s]+)\sresolving\s([A-Z]+)\s+as\s'([^']+)'/ )
+ if line =~ /for\s+([^\s]+)\sresolving\s([A-Z]+)\s+as\s'([^']+)'/
@resolve_name = $1.dup
@resolve_type = $2.dup
@resolve_expected = $3.dup.downcase.split(/[\s,]+/)
@@ -107,14 +107,14 @@ module Custodian
# Do the lookup
#
results = resolve_via( @host, resolve_type, resolve_name, period )
- return false if ( results.nil? )
+ return false if results.nil?
#
# OK we have an array of results. If every one of the expected
# results is contained in those results returned then we're good.
#
- if ( !(results - @resolve_expected).empty? or !(@resolve_expected - results).empty? )
+ if !(results - @resolve_expected).empty? or !(@resolve_expected - results).empty?
@error = "DNS server *#{@host}* (#{@server_ip}) returned the wrong records for @#{resolve_name} IN #{resolve_type}@.\n\nWe expected '#{resolve_expected.join(",")}', but we received '#{results.join(",")}'\n"
end
diff --git a/lib/custodian/protocoltest/dnsbl.rb b/lib/custodian/protocoltest/dnsbl.rb
index 7f96768..da93ff0 100644
--- a/lib/custodian/protocoltest/dnsbl.rb
+++ b/lib/custodian/protocoltest/dnsbl.rb
@@ -36,7 +36,7 @@ module Custodian
#
# See which blacklist(s) we're testing against.
#
- if ( line =~ /via\s+([^\s]+)\s+/ )
+ if line =~ /via\s+([^\s]+)\s+/
@zones = $1.dup
else
@zones = "zen.spamhaus.org"
@@ -45,7 +45,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -81,13 +81,13 @@ module Custodian
# Given IP 1.2.3.4 we lookup the address of the name
# 4.3.2.1.$zone
#
- if ( @host =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ )
+ if @host =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/
name = "#{$4}.#{$3}.#{$2}.#{$1}.#{zone}"
result = Custodian::Util::DNS.hostname_to_ip( name )
- if ( ( !result.nil? ) && ( result.length > 0 ) )
+ if ( !result.nil? ) && ( result.length > 0 )
@error = "IP #{@host} listed in blacklist #{zone}. Lookup of #{name} lead to result: #{result}"
return true
end
diff --git a/lib/custodian/protocoltest/ftp.rb b/lib/custodian/protocoltest/ftp.rb
index c13a0af..bbed744 100644
--- a/lib/custodian/protocoltest/ftp.rb
+++ b/lib/custodian/protocoltest/ftp.rb
@@ -32,14 +32,14 @@ module Custodian
# Save the host
#
@host = line.split( /\s+/)[0]
- if ( @host =~ /^ftp:\/\/([^\/]+)\/?/ )
+ if @host =~ /^ftp:\/\/([^\/]+)\/?/
@host = $1.dup
end
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -48,7 +48,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 21
diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb
index a36b349..9226441 100644
--- a/lib/custodian/protocoltest/http.rb
+++ b/lib/custodian/protocoltest/http.rb
@@ -65,7 +65,7 @@ module Custodian
#
# Ensure we've got a HTTP/HTTPS url.
#
- if ( @url !~ /^https?:/ )
+ if @url !~ /^https?:/
raise ArgumentError, "The target wasn't a HTTP/HTTPS URL: #{line}"
end
@@ -99,7 +99,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -108,20 +108,20 @@ module Custodian
#
# Expected status
#
- if ( line =~ /with status ([0-9]+)/ )
+ if line =~ /with status ([0-9]+)/
@expected_status = $1.dup
else
@expected_status = "200"
end
- if ( line =~ /with (IPv[46])/i )
+ if line =~ /with (IPv[46])/i
@resolve_modes << $1.downcase.to_sym
end
#
# The content we expect to find
#
- if ( line =~ /with content '([^']+)'/ )
+ if line =~ /with content '([^']+)'/
@expected_content = $1.dup
else
@expected_content = nil
@@ -130,7 +130,7 @@ module Custodian
#
# Do we follow redirects?
#
- if ( line =~ /not following redirects?/i )
+ if line =~ /not following redirects?/i
@redirect = false
end
@@ -138,16 +138,16 @@ module Custodian
# Do we use cache-busting?
#
@cache_busting = true
- if ( line =~ /with\s+cache\s+busting/ )
+ if line =~ /with\s+cache\s+busting/
@cache_busting = true
end
- if ( line =~ /without\s+cache\s+busting/ )
+ if line =~ /without\s+cache\s+busting/
@cache_busting = false
end
# Do we need to override the HTTP Host: Header?
@host_override = nil
- if ( line =~ /with host header '([^']+)'/)
+ if line =~ /with host header '([^']+)'/
@host_override = $1.dup
end
end
@@ -157,9 +157,9 @@ module Custodian
# Get the right type of this object, based on the URL
#
def get_type
- if ( @url =~ /^https:/ )
+ if @url =~ /^https:/
"https"
- elsif ( @url =~ /^http:/ )
+ elsif @url =~ /^http:/
"http"
else
raise ArgumentError, "URL isn't http/https: #{@url}"
@@ -221,9 +221,9 @@ module Custodian
# Parse and append a query-string if not present, if we're
# running with cache-busting.
#
- if ( @cache_busting )
+ if @cache_busting
u = URI.parse( test_url )
- if ( ! u.query )
+ if ! u.query
u.query = "ctime=#{Time.now.to_i}"
test_url = u.to_s
end
@@ -249,7 +249,7 @@ module Custodian
#
# Should we follow redirections?
#
- if ( follow_redirects? )
+ if follow_redirects?
c.follow_location = true
c.max_redirects = 10
end
@@ -304,13 +304,13 @@ module Custodian
# A this point we've either had an exception, or we've
# got a result
#
- if ( status and expected_status.to_i != status.to_i )
+ if status and expected_status.to_i != status.to_i
errors << "#{protocol_msg}: Status code was #{status} not the expected #{expected_status}."
end
- if ( content.is_a?(String) and
+ if content.is_a?(String) and
expected_content.is_a?(String) and
- content !~ /#{expected_content}/i )
+ content !~ /#{expected_content}/i
errors << "#{protocol_msg}: The response did not contain our expected text '#{expected_content}'."
end
end
diff --git a/lib/custodian/protocoltest/imap.rb b/lib/custodian/protocoltest/imap.rb
index f0e3288..3f338b2 100644
--- a/lib/custodian/protocoltest/imap.rb
+++ b/lib/custodian/protocoltest/imap.rb
@@ -38,7 +38,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -48,7 +48,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 143
diff --git a/lib/custodian/protocoltest/jabber.rb b/lib/custodian/protocoltest/jabber.rb
index 12e4391..1431139 100644
--- a/lib/custodian/protocoltest/jabber.rb
+++ b/lib/custodian/protocoltest/jabber.rb
@@ -37,7 +37,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -46,7 +46,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 5222
diff --git a/lib/custodian/protocoltest/ldap.rb b/lib/custodian/protocoltest/ldap.rb
index 56203b2..ba8b442 100644
--- a/lib/custodian/protocoltest/ldap.rb
+++ b/lib/custodian/protocoltest/ldap.rb
@@ -39,24 +39,24 @@ module Custodian
@ldap_user = nil
@ldap_pass = nil
- if ( line =~ /with\s+username\s+'([^']+)'/ )
+ if line =~ /with\s+username\s+'([^']+)'/
@ldap_user = $1.dup
end
- if ( line =~ /with\s+password\s+'([^']+)'/ )
+ if line =~ /with\s+password\s+'([^']+)'/
@ldap_pass = $1.dup
end
- if ( @ldap_user.nil? )
+ if @ldap_user.nil?
raise ArgumentError, "No username specified: #{@line}"
end
- if ( @ldap_pass.nil? )
+ if @ldap_pass.nil?
raise ArgumentError, "No password specified: #{@line}"
end
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -65,7 +65,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup.to_i
else
@port = 389
@@ -112,7 +112,7 @@ module Custodian
# Bind.
ldap.bind( @ldap_user, @ldap_pass )
- if ( ldap.bound? )
+ if ldap.bound?
#
# Search
diff --git a/lib/custodian/protocoltest/mx.rb b/lib/custodian/protocoltest/mx.rb
index 2372556..b77e596 100644
--- a/lib/custodian/protocoltest/mx.rb
+++ b/lib/custodian/protocoltest/mx.rb
@@ -28,7 +28,7 @@ module Custodian
# The main domain we're querying
@host = line.split(/\s+/)[0]
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -90,7 +90,7 @@ module Custodian
#
# So on that basis we must alert.
#
- if ( mx.empty? ) then
+ if mx.empty? then
@error = "Failed to perform DNS lookup of MX record(s) for host #{@host}"
return false
end
@@ -114,12 +114,12 @@ module Custodian
read = socket.sysread(1024)
# trim to a sane length & strip newlines.
- if ( ! read.nil? )
+ if ! read.nil?
read = read[0,255]
read.gsub!(/[\n\r]/, "")
end
- if ( read =~ /^220/ )
+ if read =~ /^220/
passed += 1
else
failed += 1
@@ -140,7 +140,7 @@ module Custodian
#
# At this point we should have tested the things
#
- if ( failed > 0 )
+ if failed > 0
@error = "There are #{mx.size} hosts running as MX-servers for domain #{@host} - #{passed}:OK #{failed}:FAILED - #{error}"
return false
else
diff --git a/lib/custodian/protocoltest/mysql.rb b/lib/custodian/protocoltest/mysql.rb
index 36a0677..135dc38 100644
--- a/lib/custodian/protocoltest/mysql.rb
+++ b/lib/custodian/protocoltest/mysql.rb
@@ -38,7 +38,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -48,7 +48,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 3306
diff --git a/lib/custodian/protocoltest/named.rb b/lib/custodian/protocoltest/named.rb
index 94e214a..c4e5e8a 100644
--- a/lib/custodian/protocoltest/named.rb
+++ b/lib/custodian/protocoltest/named.rb
@@ -37,7 +37,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -46,7 +46,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 53
diff --git a/lib/custodian/protocoltest/openproxy.rb b/lib/custodian/protocoltest/openproxy.rb
index 851982c..da432f0 100644
--- a/lib/custodian/protocoltest/openproxy.rb
+++ b/lib/custodian/protocoltest/openproxy.rb
@@ -44,7 +44,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb
index 423b925..90e4241 100644
--- a/lib/custodian/protocoltest/ping.rb
+++ b/lib/custodian/protocoltest/ping.rb
@@ -41,7 +41,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -71,9 +71,9 @@ module Custodian
#
binary = nil
binary = "./bin/multi-ping"
- binary = "/usr/bin/multi-ping" if ( File.exist?( "/usr/bin/multi-ping" ) )
+ binary = "/usr/bin/multi-ping" if File.exist?( "/usr/bin/multi-ping" )
- if ( binary.nil? )
+ if binary.nil?
@error = "Failed to find '/usr/bin/multi-ping'"
return false
end
@@ -85,7 +85,7 @@ module Custodian
#
# $(/tmp/exploit.sh) must run ping ..
#
- if ( @host !~ /^([a-zA-Z0-9:\-\.]+)$/ )
+ if @host !~ /^([a-zA-Z0-9:\-\.]+)$/
@error = "Invalid hostname for ping-test: #{@host}"
return false
end
@@ -109,7 +109,7 @@ module Custodian
#
begin
x = IPAddr.new( @host )
- if ( x.ipv4? or x.ipv6? )
+ if x.ipv4? or x.ipv6?
ips.push( @host )
end
rescue ArgumentError
@@ -125,10 +125,10 @@ module Custodian
#
# Allow the test to disable one/both
#
- if ( @line =~ /ipv4_only/ )
+ if @line =~ /ipv4_only/
do_ipv6 = false
end
- if ( @line =~ /ipv6_only/ )
+ if @line =~ /ipv6_only/
do_ipv4 = false
end
@@ -140,11 +140,11 @@ module Custodian
timeout( period ) do
Resolv::DNS.open do |dns|
- if ( do_ipv4 )
+ if do_ipv4
ress = dns.getresources(@host, Resolv::DNS::Resource::IN::A)
ress.map { |r| ips.push( r.address.to_s ) }
end
- if ( do_ipv6 )
+ if do_ipv6
ress = dns.getresources(@host, Resolv::DNS::Resource::IN::AAAA)
ress.map { |r| ips.push( r.address.to_s ) }
end
@@ -159,7 +159,7 @@ module Custodian
#
# Did we fail to perform a DNS lookup?
#
- if ( ips.empty? )
+ if ips.empty?
@error = "#{@host} failed to resolve to either IPv4 or IPv6"
return false
end
diff --git a/lib/custodian/protocoltest/pop3.rb b/lib/custodian/protocoltest/pop3.rb
index 613b2b4..48b2d37 100644
--- a/lib/custodian/protocoltest/pop3.rb
+++ b/lib/custodian/protocoltest/pop3.rb
@@ -38,7 +38,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -48,7 +48,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 110
diff --git a/lib/custodian/protocoltest/postgresql.rb b/lib/custodian/protocoltest/postgresql.rb
index c07a42b..7ce4d70 100644
--- a/lib/custodian/protocoltest/postgresql.rb
+++ b/lib/custodian/protocoltest/postgresql.rb
@@ -38,7 +38,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -48,7 +48,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 5432
diff --git a/lib/custodian/protocoltest/redis.rb b/lib/custodian/protocoltest/redis.rb
index aacb8dd..1d732a0 100644
--- a/lib/custodian/protocoltest/redis.rb
+++ b/lib/custodian/protocoltest/redis.rb
@@ -38,7 +38,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -48,7 +48,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 6379
diff --git a/lib/custodian/protocoltest/rsync.rb b/lib/custodian/protocoltest/rsync.rb
index 7eeac4f..75c27ae 100644
--- a/lib/custodian/protocoltest/rsync.rb
+++ b/lib/custodian/protocoltest/rsync.rb
@@ -33,14 +33,14 @@ module Custodian
# If the target is an URL then strip to the hostname.
#
@host = line.split( /\s+/)[0]
- if ( @host =~ /^rsync:\/\/([^\/]+)\/?/ )
+ if @host =~ /^rsync:\/\/([^\/]+)\/?/
@host = $1.dup
end
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -50,7 +50,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 873
diff --git a/lib/custodian/protocoltest/smtp.rb b/lib/custodian/protocoltest/smtp.rb
index 819e795..1d98dca 100644
--- a/lib/custodian/protocoltest/smtp.rb
+++ b/lib/custodian/protocoltest/smtp.rb
@@ -37,7 +37,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -46,7 +46,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 25
diff --git a/lib/custodian/protocoltest/smtprelay.rb b/lib/custodian/protocoltest/smtprelay.rb
index 45abf16..397c5cb 100644
--- a/lib/custodian/protocoltest/smtprelay.rb
+++ b/lib/custodian/protocoltest/smtprelay.rb
@@ -31,7 +31,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 25
@@ -40,7 +40,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -63,9 +63,9 @@ module Custodian
def get_hostname
hostname = "localhost.localdomain"
- if ( File.exist?( "/etc/hostname" ) )
+ if File.exist?( "/etc/hostname" )
File.readlines("/etc/hostname" ).each do |line|
- hostname = line if ( !line.nil? )
+ hostname = line if !line.nil?
hostname.chomp!
end
end
diff --git a/lib/custodian/protocoltest/ssh.rb b/lib/custodian/protocoltest/ssh.rb
index 30b4458..9b5a608 100644
--- a/lib/custodian/protocoltest/ssh.rb
+++ b/lib/custodian/protocoltest/ssh.rb
@@ -39,7 +39,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -49,7 +49,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 22
diff --git a/lib/custodian/protocoltest/ssl.rb b/lib/custodian/protocoltest/ssl.rb
index 4929f7b..67af348 100644
--- a/lib/custodian/protocoltest/ssl.rb
+++ b/lib/custodian/protocoltest/ssl.rb
@@ -390,7 +390,7 @@ module Custodian
#
# If the line disables us then return early
#
- if ( @line =~ /no_ssl_check/ )
+ if @line =~ /no_ssl_check/
return true
end
@@ -403,7 +403,7 @@ module Custodian
#
# If outside 10AM-5PM we don't run the test.
#
- if ( hour < 10 || hour > 17 )
+ if hour < 10 || hour > 17
puts( "Outside office hours - Not running SSL-Verification of #{@host}" )
return true
end
@@ -411,7 +411,7 @@ module Custodian
#
# Double-check we've got an SSL host
#
- if ( ! @host =~ /^https:\/\// )
+ if ! @host =~ /^https:\/\//
puts( "Not an SSL URL" )
return true
end
diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb
index 24a05be..dfaab2d 100644
--- a/lib/custodian/protocoltest/tcp.rb
+++ b/lib/custodian/protocoltest/tcp.rb
@@ -75,7 +75,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -84,7 +84,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = nil
@@ -93,7 +93,7 @@ module Custodian
#
# Save the optional banner.
#
- if ( line =~ /with\s+banner\s+'([^']+)'/ )
+ if line =~ /with\s+banner\s+'([^']+)'/
@banner = $1.dup
else
@banner = nil
@@ -101,7 +101,7 @@ module Custodian
@error = nil
- if ( @port.nil? )
+ if @port.nil?
raise ArgumentError, "Missing port to test against"
end
end
@@ -166,7 +166,7 @@ module Custodian
#
begin
x = IPAddr.new( host )
- if ( x.ipv4? or x.ipv6? )
+ if x.ipv4? or x.ipv6?
ips.push( host )
end
rescue ArgumentError
@@ -184,10 +184,10 @@ module Custodian
#
# Allow the test to disable one/both
#
- if ( @line =~ /ipv4_only/ )
+ if @line =~ /ipv4_only/
do_ipv6 = false
end
- if ( @line =~ /ipv6_only/ )
+ if @line =~ /ipv6_only/
do_ipv4 = false
end
@@ -201,11 +201,11 @@ module Custodian
Resolv::DNS.open do |dns|
- if ( do_ipv4 )
+ if do_ipv4
ress = dns.getresources(host, Resolv::DNS::Resource::IN::A)
ress.map { |r| ips.push( r.address.to_s ) }
end
- if ( do_ipv6 )
+ if do_ipv6
ress = dns.getresources(host, Resolv::DNS::Resource::IN::AAAA)
ress.map { |r| ips.push( r.address.to_s ) }
end
@@ -220,7 +220,7 @@ module Custodian
#
# Did we fail to perform a DNS lookup?
#
- if ( ips.empty? )
+ if ips.empty?
@error = "#{@host} failed to resolve to either IPv4 or IPv6"
return false
end
@@ -232,7 +232,7 @@ module Custodian
# were given.
#
ips.each do |ip|
- if ( ! run_test_internal_real( ip, port, banner, do_read ) )
+ if ! run_test_internal_real( ip, port, banner, do_read )
return false
#
@@ -275,32 +275,32 @@ module Custodian
# read a banner from the remote server, if we're supposed to.
read = nil
- read = socket.sysread(1024) if ( do_read )
+ read = socket.sysread(1024) if do_read
# trim to a sane length & strip newlines.
- if ( ! read.nil? )
+ if ! read.nil?
read = read[0,255]
read.gsub!(/[\n\r]/, "")
end
socket.close
- if ( banner.nil? )
+ if banner.nil?
@error = nil
return true
else
# test for banner
# regexp.
- if ( banner.kind_of? Regexp )
- if ( ( !read.nil? ) && ( banner.match(read) ) )
+ if banner.kind_of? Regexp
+ if ( !read.nil? ) && ( banner.match(read) )
return true
end
end
# string.
- if ( banner.kind_of? String )
- if ( ( !read.nil? ) && ( read =~ /#{banner}/i ) )
+ if banner.kind_of? String
+ if ( !read.nil? ) && ( read =~ /#{banner}/i )
return true
end
end
diff --git a/lib/custodian/protocoltest/telnet.rb b/lib/custodian/protocoltest/telnet.rb
index 134db15..b5e0cde 100644
--- a/lib/custodian/protocoltest/telnet.rb
+++ b/lib/custodian/protocoltest/telnet.rb
@@ -37,7 +37,7 @@ module Custodian
#
# Is this test inverted?
#
- if ( line =~ /must\s+not\s+run\s+/ )
+ if line =~ /must\s+not\s+run\s+/
@inverted = true
else
@inverted = false
@@ -46,7 +46,7 @@ module Custodian
#
# Save the port
#
- if ( line =~ /on\s+([0-9]+)/ )
+ if line =~ /on\s+([0-9]+)/
@port = $1.dup
else
@port = 23
diff --git a/lib/custodian/queue.rb b/lib/custodian/queue.rb
index 671e44e..b635c1f 100644
--- a/lib/custodian/queue.rb
+++ b/lib/custodian/queue.rb
@@ -98,7 +98,7 @@ end
foo, job = @redis.blpop( "queue", :timeout => timeout )
- if ( job )
+ if job
return job
else
sleep( timeout )
@@ -157,7 +157,7 @@ end
def fetch(timeout)
begin
j = @queue.reserve(timeout)
- if ( j ) then
+ if j then
b = j.body
j.delete
return b
diff --git a/lib/custodian/settings.rb b/lib/custodian/settings.rb
index e0d2d27..1739495 100644
--- a/lib/custodian/settings.rb
+++ b/lib/custodian/settings.rb
@@ -49,8 +49,8 @@ module Custodian
# Load and "parse" the key=value content.
#
File.open( file, "r" ).each_line do |line|
- next if ( line.nil? || line =~ /^#/ )
- if ( line =~ /^(.*)=(.*)$/ )
+ next if line.nil? || line =~ /^#/
+ if line =~ /^(.*)=(.*)$/
key = $1.dup
val = $2.dup
key.strip!
@@ -95,7 +95,7 @@ module Custodian
def timeout
_load unless( _loaded? )
- if ( @settings['timeout'] )
+ if @settings['timeout']
@settings['timeout'].to_i
else
30
@@ -111,7 +111,7 @@ module Custodian
def retries
_load unless( _loaded? )
- if ( @settings['retries'] )
+ if @settings['retries']
@settings['retries'].to_i
else
5
@@ -131,7 +131,7 @@ module Custodian
def retry_delay
_load unless( _loaded? )
- if ( @settings['retry_delay'] )
+ if @settings['retry_delay']
@settings['retry_delay'].to_i
else
0
@@ -202,7 +202,7 @@ module Custodian
# Find the alerting method.
#
# if we have something setup then use it.
- if ( @settings["#{alert}_target"] )
+ if @settings["#{alert}_target"]
return( @settings["#{alert}_target"] )
end
diff --git a/lib/custodian/testfactory.rb b/lib/custodian/testfactory.rb
index 03222a2..748e114 100644
--- a/lib/custodian/testfactory.rb
+++ b/lib/custodian/testfactory.rb
@@ -31,8 +31,8 @@ module Custodian
def self.create( line )
- raise ArgumentError, "The type of test to create cannot be nil" if ( line.nil? )
- raise ArgumentError, "The type of test to create must be a string" unless ( line.kind_of? String )
+ raise ArgumentError, "The type of test to create cannot be nil" if line.nil?
+ raise ArgumentError, "The type of test to create must be a string" unless line.kind_of? String
#
# The array we return.
@@ -43,12 +43,12 @@ module Custodian
#
# If this is an obvious protocol test.
#
- if ( line =~ /must\s+(not\s+)?run\s+(\S+)(\s+|\.|$)/ )
+ if line =~ /must\s+(not\s+)?run\s+(\S+)(\s+|\.|$)/
test_type = $2.dup
test_type.chomp!( "." )
- if ( @@subclasses[test_type].nil? )
+ if @@subclasses[test_type].nil?
raise ArgumentError, "There is no handler registered for the '#{test_type}' test-type"
end
@@ -66,7 +66,7 @@ module Custodian
#
# We do this only after we've instantiated the test.
#
- if ( line =~ /\s+otherwise\s+'([^']+)'/ )
+ if line =~ /\s+otherwise\s+'([^']+)'/
obj.set_notification_text( $1.dup )
end
diff --git a/lib/custodian/util/bytemark.rb b/lib/custodian/util/bytemark.rb
index c821b18..07e5684 100644
--- a/lib/custodian/util/bytemark.rb
+++ b/lib/custodian/util/bytemark.rb
@@ -29,7 +29,7 @@ module Custodian
def self.inside?( target )
inside = false
- if ( BYTEMARK_RANGES.any?{|range| range.include?(IPAddr.new(target))} )
+ if BYTEMARK_RANGES.any?{|range| range.include?(IPAddr.new(target))}
inside = true
end
diff --git a/lib/custodian/util/dns.rb b/lib/custodian/util/dns.rb
index 9cbbf59..2a0c705 100644
--- a/lib/custodian/util/dns.rb
+++ b/lib/custodian/util/dns.rb
@@ -61,7 +61,7 @@ module Custodian
timeout( period ) do
begin
Socket.getaddrinfo(hostname, 'echo').each do |a|
- resolved = a[3] if ( a )
+ resolved = a[3] if a
end
rescue SocketError
resolved = nil
diff --git a/lib/custodian/util/ping.rb b/lib/custodian/util/ping.rb
index 9abc746..4056803 100644
--- a/lib/custodian/util/ping.rb
+++ b/lib/custodian/util/ping.rb
@@ -26,7 +26,7 @@ module Custodian
#
def initialize( hostname )
- raise ArgumentError, "Hostname must not be nil" if ( hostname.nil? )
+ raise ArgumentError, "Hostname must not be nil" if hostname.nil?
raise ArgumentError, "Hostname must be a String" unless hostname.kind_of?( String )
@hostname = hostname
@@ -47,7 +47,7 @@ module Custodian
# Does the hostname resolve to an IPv4 address?
#
def is_ipv4?
- if ( ( ! @resolved.nil? ) && ( @resolved =~ /^([0-9]+).([0-9]+).([0-9]+).([0-9]+)$/ ) )
+ if ( ! @resolved.nil? ) && ( @resolved =~ /^([0-9]+).([0-9]+).([0-9]+).([0-9]+)$/ )
true
else
false
@@ -59,7 +59,7 @@ module Custodian
# Does the hostname resolve to an IPv6 address?
#
def is_ipv6?
- if ( ( ! @resolved.nil? ) && ( @resolved =~ /^([a-f0-9:]+)$/i ) )
+ if ( ! @resolved.nil? ) && ( @resolved =~ /^([a-f0-9:]+)$/i )
true
else
false
@@ -74,7 +74,7 @@ module Custodian
# Return false on error.
#
def run_ping
- if ( is_ipv6? )
+ if is_ipv6?
if ( system( "ping6 -c 1 #{@resolved} 2>/dev/null >/dev/null" ) == true )
return true
end
diff --git a/lib/custodian/util/timespan.rb b/lib/custodian/util/timespan.rb
index 5340c65..b3cb647 100644
--- a/lib/custodian/util/timespan.rb
+++ b/lib/custodian/util/timespan.rb
@@ -17,15 +17,15 @@ module Custodian
#
# Handle PM times.
#
- if ( ( desc.kind_of? String ) &&
- ( desc =~ /([0-9]+)pm$/i ) )
+ if ( desc.kind_of? String ) &&
+ ( desc =~ /([0-9]+)pm$/i )
desc = $1.dup.to_i + 12;
end
#
# Handle AM times.
#
- if ( desc.kind_of? String )
+ if desc.kind_of? String
desc = desc.sub( /am$/, '' )
desc = desc.to_i
end
@@ -70,7 +70,7 @@ module Custodian
while( hour != p_end )
valid[hour] = 1
hour += 1
- hour = 0 if ( hour > 23 )
+ hour = 0 if hour > 23
end
valid[p_end]=1
@@ -92,7 +92,7 @@ module Custodian
#
# Default to the current hour, if not specified.
#
- if ( cur_hour.nil? )
+ if cur_hour.nil?
cur_hour = Time.now.hour
end
diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb
index fd1abce..2c806fd 100644
--- a/lib/custodian/worker.rb
+++ b/lib/custodian/worker.rb
@@ -93,7 +93,7 @@ module Custodian
# Show a message on STDOUT if "--verbose" was specified.
#
def log_message( msg )
- puts msg if ( ENV["VERBOSE" ] )
+ puts msg if ENV["VERBOSE" ]
end
@@ -125,7 +125,7 @@ module Custodian
#
# Ensure that the job is sane.
#
- raise ArgumentError, "Job was empty" if (job.nil?)
+ raise ArgumentError, "Job was empty" if job.nil?
raise ArgumentError, "Job was not a string" unless job.kind_of?(String)
#
@@ -162,7 +162,7 @@ module Custodian
#
# We exit here if we receive a single success.
#
- while ( ( count < ( @retry_count + 1 ) ) && ( result == false ) )
+ while ( count < ( @retry_count + 1 ) ) && ( result == false )
log_message( "Running test - [#{count}/#{@retry_count}]" )
@@ -170,9 +170,9 @@ module Custodian
# Run the test - inverting the result if we should
#
result = test.run_test
- result = ! result if ( test.inverted )
+ result = ! result if test.inverted
- if ( result )
+ if result
log_message( "Test succeeed - clearing alert" )
do_clear( test )
end
@@ -186,7 +186,7 @@ module Custodian
# The intention here is that if the test passes then there will
# be no delay. If the test fails then we'll sleep.
#
- if ( ( result == false ) && ( @retry_delay > 0 ) && ( count < @retry_count ) )
+ if ( result == false ) && ( @retry_delay > 0 ) && ( count < @retry_count )
log_message( "Sleeping for #{@retry_delay} seconds to allow cool-down" )
sleep( @retry_delay )
end
@@ -218,7 +218,7 @@ module Custodian
#
# If we didn't succeed on any of the attempts raise the alert.
#
- if ( ! result )
+ if ! result
#
# Raise the alert, passing the error message.
@@ -291,7 +291,7 @@ module Custodian
# give the alerter a reference to the settings object.
alert.set_settings( @settings )
- alert.duration( duration ) if ( alert.respond_to? "duration" )
+ alert.duration( duration ) if alert.respond_to? "duration"
end
end
diff --git a/t/test-custodian-alertfactory.rb b/t/test-custodian-alertfactory.rb
index e12dbdd..42873ec 100755
--- a/t/test-custodian-alertfactory.rb
+++ b/t/test-custodian-alertfactory.rb
@@ -54,8 +54,8 @@ class TestAlertFactory < Test::Unit::TestCase
mauve = false
end
- methods.push( "redis" ) if ( redis )
- methods.push( "mauve" ) if ( mauve )
+ methods.push( "redis" ) if redis
+ methods.push( "mauve" ) if mauve
methods.each do |name|
diff --git a/t/test-custodian-parser.rb b/t/test-custodian-parser.rb
index 43a0754..bd5205b 100755
--- a/t/test-custodian-parser.rb
+++ b/t/test-custodian-parser.rb
@@ -305,7 +305,7 @@ EOF
assert( obj.size == 1 )
assert_equal( obj[0].to_s, str )
- if ( follow )
+ if follow
assert( obj[0].follow_redirects? )
else
assert( ! obj[0].follow_redirects? )
@@ -344,7 +344,7 @@ EOF
assert( obj.size == 1 )
assert_equal( obj[0].to_s, str )
- if ( cb )
+ if cb
assert( obj[0].cache_busting? )
else
assert( ! obj[0].cache_busting? )
@@ -390,7 +390,7 @@ EOF
assert( obj.size == 1 )
assert_equal( obj[0].to_s, str )
- if ( fail.nil? )
+ if fail.nil?
assert( obj[0].get_notification_text.nil? )
else
assert_equal( obj[0].get_notification_text, fail )
diff --git a/t/test-custodian-testfactory.rb b/t/test-custodian-testfactory.rb
index 6c71003..b067ab8 100755
--- a/t/test-custodian-testfactory.rb
+++ b/t/test-custodian-testfactory.rb
@@ -255,13 +255,13 @@ class TestTestFactory < Test::Unit::TestCase
# for each handler ..
registered[type].each do |name|
- if ( name.to_s =~ /protocoltest::(.*)Test$/i )
+ if name.to_s =~ /protocoltest::(.*)Test$/i
tst = $1.dup.downcase
#
# NOTE: Skip the DNS and LDAP tests - they are more complex.
#
- next if ( tst =~ /^(ldap|dns|dnsbl|sslcertificate)$/ )
+ next if tst =~ /^(ldap|dns|dnsbl|sslcertificate)$/
# normal
test_one = "http://foo.com/.com must run #{tst} on 1234"
diff --git a/t/test-custodian-util-bytemark.rb b/t/test-custodian-util-bytemark.rb
index 764babc..9296dcb 100755
--- a/t/test-custodian-util-bytemark.rb
+++ b/t/test-custodian-util-bytemark.rb
@@ -52,7 +52,7 @@ class TestBytemarkUtil < Test::Unit::TestCase
to_test.each do |name,inside|
- if ( inside )
+ if inside
assert( Custodian::Util::Bytemark.inside?( name ) == true )
else
assert( Custodian::Util::Bytemark.inside?( name ) == false )