From e716a49dabe2c086a97e2d8b3cffe5cf369ad026 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 9 Mar 2015 13:19:47 +0000 Subject: Removed spaces inside parenthesis. --- lib/custodian/alerts/file.rb | 14 +++++----- lib/custodian/alerts/graphite.rb | 6 ++--- lib/custodian/alerts/mauve.rb | 52 ++++++++++++++++++------------------- lib/custodian/alerts/redis-state.rb | 16 ++++++------ lib/custodian/alerts/smtp.rb | 10 +++---- 5 files changed, 49 insertions(+), 49 deletions(-) (limited to 'lib/custodian/alerts') diff --git a/lib/custodian/alerts/file.rb b/lib/custodian/alerts/file.rb index cb04084..06a704e 100644 --- a/lib/custodian/alerts/file.rb +++ b/lib/custodian/alerts/file.rb @@ -21,7 +21,7 @@ module Custodian # # Constructor - save the test-object away. # - def initialize( obj ) + def initialize(obj) @test = obj end @@ -31,15 +31,15 @@ module Custodian # Record a raise event for the given test. # def raise - write_message( "RAISE: #{test.target} failed #{test.get_type}-test - #{test.error}" ) + write_message("RAISE: #{test.target} failed #{test.get_type}-test - #{test.error}") end # # Record the duration of the given test. # - def duration( seconds ) - write_message( "#{test.get_type}-test against #{test.target} took #{seconds}ms to complete" ) + def duration(seconds) + write_message("#{test.get_type}-test against #{test.target} took #{seconds}ms to complete") end @@ -47,16 +47,16 @@ module Custodian # Record a clear event for the given test. # def clear - write_message( "CLEAR: #{test.target} failed #{test.get_type}-test" ) + write_message("CLEAR: #{test.target} failed #{test.get_type}-test") end # # Write the actual message to our target. # - def write_message( msg ) + def write_message(msg) file = File.open(@target, 'a') - file.puts( "#{Time.now} #{msg}" ) + file.puts("#{Time.now} #{msg}") file.close end diff --git a/lib/custodian/alerts/graphite.rb b/lib/custodian/alerts/graphite.rb index c98f6bf..9d69c28 100644 --- a/lib/custodian/alerts/graphite.rb +++ b/lib/custodian/alerts/graphite.rb @@ -22,7 +22,7 @@ module Custodian # # Constructor - save the test-object away. # - def initialize( obj ) + def initialize(obj) @test = obj end @@ -47,7 +47,7 @@ module Custodian # # Send the test test-duration to graphite/carbon # - def duration( ms ) + def duration(ms) # # hostname + test-type @@ -64,7 +64,7 @@ module Custodian # Send via UDP. # socket = UDPSocket.new - socket.send( payload, 0, @target, 2003 ) + socket.send(payload, 0, @target, 2003) socket.close end diff --git a/lib/custodian/alerts/mauve.rb b/lib/custodian/alerts/mauve.rb index 4c20b08..947f019 100644 --- a/lib/custodian/alerts/mauve.rb +++ b/lib/custodian/alerts/mauve.rb @@ -41,7 +41,7 @@ module Custodian # # Constructor # - def initialize( obj ) + def initialize(obj) @test = obj begin @@ -62,7 +62,7 @@ module Custodian # def raise - return unless( @loaded ) + return unless(@loaded) # # Get ready to send to mauve. @@ -75,7 +75,7 @@ module Custodian # # Construct a new alert structure. # - alert = _get_alert( true ) + alert = _get_alert(true) # # We're raising this alert. @@ -96,21 +96,21 @@ module Custodian # # Lookup the start of the day. # - day_start = @settings.key( 'day_start' ).to_i || 10 - day_end = @settings.key( 'day_end' ).to_i || 18 + day_start = @settings.key('day_start').to_i || 10 + day_end = @settings.key('day_end').to_i || 18 # # In hour suppress # - working_suppress = @settings.key( 'working_suppress' ).to_i || 4 - oncall_suppress = @settings.key( 'oncall_suppress' ).to_i || 10 + working_suppress = @settings.key('working_suppress').to_i || 4 + oncall_suppress = @settings.key('oncall_suppress').to_i || 10 # # 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 @@ -127,13 +127,13 @@ module Custodian # # We're going to suppress this alert now # - alert.suppress_until = Time.now.to_i + ( period * 60 ) + alert.suppress_until = Time.now.to_i + (period * 60) # # Update it and send it # update.alert << alert - Mauve::Sender.new( @target ).send(update) + Mauve::Sender.new(@target).send(update) end @@ -144,7 +144,7 @@ module Custodian # def clear - return unless( @loaded ) + return unless(@loaded) # # Get ready to send to mauve. @@ -157,7 +157,7 @@ module Custodian # # Construct a new alert structure. # - alert = _get_alert( false ) + alert = _get_alert(false) # # We're clearing this alert. @@ -168,7 +168,7 @@ module Custodian # Update it and send it # update.alert << alert - Mauve::Sender.new( @target ).send(update) + Mauve::Sender.new(@target).send(update) end @@ -184,7 +184,7 @@ module Custodian # Most of the mess of this method is ensuring there is some # "helpful" data in the detail-field of the alert. # - def _get_alert( failure ) + def _get_alert(failure) # # The subject of an alert MUST be one of: @@ -198,9 +198,9 @@ module Custodian # subject = @test.target - if ( subject =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ ) || - ( subject =~ /^([0-9a-f:]+)$/ ) - res = Custodian::Util::DNS.ip_to_hostname( subject ) + if (subject =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/) || + (subject =~ /^([0-9a-f:]+)$/) + res = Custodian::Util::DNS.ip_to_hostname(subject) if res subject = res end @@ -256,7 +256,7 @@ module Custodian # # Determine if this is inside/outside the bytemark network # - location = expand_inside_bytemark( test_host ) + location = expand_inside_bytemark(test_host) if !location.nil? && location.length alert.detail = "#{alert.detail}\n#{location}" end @@ -274,7 +274,7 @@ module Custodian # or not. # # - def expand_inside_bytemark( host ) + def expand_inside_bytemark(host) # # If the host is a URL then we need to work with the hostname component alone. @@ -296,11 +296,11 @@ 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 ) + resolved = Custodian::Util::DNS.hostname_to_ip(target) end @@ -313,14 +313,14 @@ module Custodian # # Return the formatted message # - if Custodian::Util::Bytemark.inside?( resolved.to_s ) - if ( resolved == target ) + if Custodian::Util::Bytemark.inside?(resolved.to_s) + if (resolved == target) return "

#{host} is inside the Bytemark network.

" else return "

#{host} resolves to #{resolved} which is inside the Bytemark network.

" end else - if ( resolved == target ) + if (resolved == target) return "

#{host} is OUTSIDE the Bytemark network.

" else return "

#{host} resolves to #{resolved} which is OUTSIDE the Bytemark network.

" diff --git a/lib/custodian/alerts/redis-state.rb b/lib/custodian/alerts/redis-state.rb index 27bb2c4..bef0015 100644 --- a/lib/custodian/alerts/redis-state.rb +++ b/lib/custodian/alerts/redis-state.rb @@ -29,14 +29,14 @@ module Custodian # Constructor - save the test-object away & instantiate # the redis connection. # - def initialize( obj ) + def initialize(obj) begin require 'rubygems' require 'redis' require 'json' - @redis = Redis.new(:host => @target ) + @redis = Redis.new(:host => @target) rescue puts 'ERROR Loading redis rubygem!' @@ -52,7 +52,7 @@ module Custodian # def raise - return unless( @redis ) + return unless(@redis) tmp = {} tmp['time'] = Time.now.to_i @@ -63,8 +63,8 @@ module Custodian tmp['test' ] = @test.to_s tmp['class' ] = @test.class - @redis.lpush( 'recent-tests', tmp.to_json) - @redis.ltrim( 'recent-tests', 0, 100 ) + @redis.lpush('recent-tests', tmp.to_json) + @redis.ltrim('recent-tests', 0, 100) end @@ -75,7 +75,7 @@ module Custodian # def clear - return unless( @redis ) + return unless(@redis) tmp = {} @@ -87,8 +87,8 @@ module Custodian tmp['test' ] = @test.to_s tmp['class' ] = @test.class - @redis.lpush( 'recent-tests', tmp.to_json) - @redis.ltrim( 'recent-tests', 0, 100 ) + @redis.lpush('recent-tests', tmp.to_json) + @redis.ltrim('recent-tests', 0, 100) end register_alert_type 'redis' diff --git a/lib/custodian/alerts/smtp.rb b/lib/custodian/alerts/smtp.rb index 38ef29e..e6cfef0 100644 --- a/lib/custodian/alerts/smtp.rb +++ b/lib/custodian/alerts/smtp.rb @@ -20,7 +20,7 @@ module Custodian # # Constructor - save the test-object away. # - def initialize( obj ) + def initialize(obj) @test = obj end @@ -33,7 +33,7 @@ module Custodian subject = "#{test.target} alert #{test.get_type}-test - #{test.error}" body = "The alert has raised, with the following details:\n#{test.error}\nRegards\n" - _send_mail( @target, subject, body ) + _send_mail(@target, subject, body) end @@ -45,7 +45,7 @@ module Custodian subject = "#{test.target} cleared #{test.get_type}-test" body = "The alert has cleared\nRegards\n" - _send_mail( @target, subject, body ) + _send_mail(@target, subject, body) end @@ -53,7 +53,7 @@ module Custodian # # Send an email # - def _send_mail( to, subject, body ) + def _send_mail(to, subject, body) msg = <