summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-03-09 14:43:10 +0000
committerSteve Kemp <steve@steve.org.uk>2015-03-09 14:43:10 +0000
commit69acb34d89e05637f04531f4ba8903f1dd887383 (patch)
tree023a3777576237d3b89b7554c00ee2ae1142b0a9 /lib
parentff910ae9491d81085e25d289f61cec72e96e57ef (diff)
Removed trailing whitespace from the code
Diffstat (limited to 'lib')
-rw-r--r--lib/custodian/alertfactory.rb4
-rw-r--r--lib/custodian/alerts/mauve.rb20
-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.rb52
-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.rb8
-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.rb2
-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.rb8
-rw-r--r--lib/custodian/worker.rb14
32 files changed, 148 insertions, 148 deletions
diff --git a/lib/custodian/alertfactory.rb b/lib/custodian/alertfactory.rb
index f2d8639..42680a1 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 47431d6..c3c6521 100644
--- a/lib/custodian/alerts/mauve.rb
+++ b/lib/custodian/alerts/mauve.rb
@@ -110,7 +110,7 @@ module Custodian
# we're in the working day.
#
if ((wday != 0) && (wday != 6)) &&
- (hour >= day_start && hour < day_end)
+ (hour >= day_start && hour < day_end)
working = true
end
@@ -199,9 +199,9 @@ module Custodian
subject = @test.target
if (subject =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/) ||
- (subject =~ /^([0-9a-f:]+)$/)
+ (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
@@ -297,7 +297,7 @@ 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:]+)$/)
+ (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/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb
index c65f90a..a4e7baf 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 2e51c5d..a16de0a 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 ddefe45..e3c192d 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 591abfb..9ce1980 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,13 +138,13 @@ 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 '([^']+)'/
@@ -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
@@ -237,7 +237,7 @@ module Custodian
else
resolve_modes = @resolve_modes
end
-
+
resolve_modes.each do |resolve_mode|
status = nil
content = nil
@@ -249,11 +249,11 @@ module Custodian
#
# Should we follow redirections?
#
- if follow_redirects?
+ if follow_redirects?
c.follow_location = true
c.max_redirects = 10
end
-
+
unless @host_override.nil?
c.headers['Host'] = @host_override
end
@@ -275,13 +275,13 @@ module Custodian
end
#
- # Overwrite protocol_msg with the IP we connect to.
+ # Overwrite protocol_msg with the IP we connect to.
#
if c.primary_ip
if :ipv4 == resolve_mode
- protocol_msg = "#{c.primary_ip}"
+ protocol_msg = "#{c.primary_ip}"
else
- protocol_msg = "[#{c.primary_ip}]"
+ protocol_msg = "[#{c.primary_ip}]"
end
end
@@ -299,18 +299,18 @@ module Custodian
rescue => x
errors << "#{protocol_msg}: #{x.class}: #{x.message}\n #{x.backtrace.join("\n ")}."
end
-
+
#
# 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
- expected_content.is_a?(String) and
- content !~ /#{expected_content}/i
+
+ if content.is_a?(String) and
+ expected_content.is_a?(String) and
+ content !~ /#{expected_content}/i
errors << "#{protocol_msg}: The response did not contain our expected text '#{expected_content}'."
end
end
@@ -327,7 +327,7 @@ module Custodian
@error = errors.join("\n")
return false
end
-
+
#
# All done.
#
diff --git a/lib/custodian/protocoltest/imap.rb b/lib/custodian/protocoltest/imap.rb
index 3512cd5..5f6ba25 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 ba94499..ab881de 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 d7e58fa..4a6009f 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 2d0bcc2..3770686 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
@@ -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 ce63639..152c53f 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 321c9d5..bb87e85 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 4beaaca..07f608f 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 c2c9a04..7622fb5 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 eeb1e60..2429c79 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 f97776c..d88d131 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 1293cc9..88ac67a 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 89f4e65..1a52b03 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 b27901d..6968ae9 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 6b1f721..52b7b14 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 324f87d..feb50f2 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 44c3910..5e14329 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 367cf78..fc95dd3 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 a73b35c..229b02d 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 740cdbf..24411f2 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)
diff --git a/lib/custodian/settings.rb b/lib/custodian/settings.rb
index 318ecdc..73e7c4b 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 64ea7c8..57bb1f7 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 db3304d..99079a1 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 b93fef5..95e788f 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 3b3586e..a4c6075 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 c0ca4eb..7de76b3 100644
--- a/lib/custodian/util/timespan.rb
+++ b/lib/custodian/util/timespan.rb
@@ -18,14 +18,14 @@ module Custodian
# Handle PM times.
#
if (desc.kind_of? String) &&
- (desc =~ /([0-9]+)pm$/i)
+ (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 e9a7532..a8118da 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
@@ -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