Skip to content

Commit

Permalink
Merge branch 'master' of github.com:highgroove/scout-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
JEG2 committed Sep 28, 2009
2 parents 7cc8948 + 31fd817 commit 57be3d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 6 additions & 5 deletions mysql_query_statistics/mysql_query_statistics.rb
Expand Up @@ -20,7 +20,6 @@ def build_report
now = Time.now
mysql = Mysql.connect(host, user, password, nil, (port.nil? ? nil : port.to_i), socket)
result = mysql.query('SHOW /*!50002 GLOBAL */ STATUS')

rows = []
total = 0
result.each do |row|
Expand All @@ -36,12 +35,14 @@ def build_report
value = calculate_counter(now, name, row.last.to_i)
# only report if a value is calculated
next unless value
report(name => value)
report_hash[name] = value
end


total_val = calculate_counter(now, 'total', total)
report('total' => total_val) if total_val
report_hash['total'] = total_val if total_val

report(report_hash)
end

private
Expand All @@ -58,7 +59,7 @@ def calculate_counter(current_time, name, value)
result = nil
# only check if a past run has a value for the specified query type
if memory(name) && memory(name).is_a?(Hash)
last_time, last_value = memory(name).values_at('time', 'value')
last_time, last_value = memory(name).values_at(:time, :value)
# We won't log it if the value has wrapped
if last_value and value >= last_value
elapsed_seconds = current_time - last_time
Expand All @@ -69,7 +70,7 @@ def calculate_counter(current_time, name, value)
result = result / elapsed_seconds.to_f
end
end

# remember(:last_request_time, Time.now)
remember(name => {:time => current_time, :value => value})

result
Expand Down
5 changes: 4 additions & 1 deletion url_monitor/url_monitor.rb
@@ -1,4 +1,5 @@
require 'net/http'
require 'net/https'
require 'uri'

class UrlMonitor < Scout::Plugin
Expand Down Expand Up @@ -60,7 +61,9 @@ def http_response(url)
retry_url_trailing_slash = true
retry_url_execution_expired = true
begin
Net::HTTP.start(uri.host,uri.port) {|http|
http = Net::HTTP.new(uri.host,uri.port)
http.use_ssl = url =~ %r{\Ahttps://}
http.start(){|http|
http.open_timeout = TIMEOUT_LENGTH
req = Net::HTTP::Get.new((uri.path != '' ? uri.path : '/' ) + (uri.query ? ('?' + uri.query) : ''))
if uri.user && uri.password
Expand Down

0 comments on commit 57be3d2

Please sign in to comment.