From cca4f6052e1df73f52f2c6f440db76344325f309 Mon Sep 17 00:00:00 2001 From: Andre Lewis Date: Tue, 29 Dec 2009 16:19:15 -0800 Subject: [PATCH] added Slow Requests Percentage field -- the % of overall requests that were slow this period --- rails_requests/rails_requests.rb | 25 +++++++++++++++++++++++-- rails_requests/rails_requests.yml | 23 ++++------------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/rails_requests/rails_requests.rb b/rails_requests/rails_requests.rb index a01f4fe6..f4fb237f 100644 --- a/rails_requests/rails_requests.rb +++ b/rails_requests/rails_requests.rb @@ -3,8 +3,26 @@ class RailsRequests < Scout::Plugin ONE_DAY = 60 * 60 * 24 - TEST_USAGE = "#{File.basename($0)} log LOG max_request_length MAX_REQUEST_LENGTH last_run LAST_RUN" - + + OPTIONS=<<-EOS + log: + name: Full Path to Rails Log File + notes: "The full path to the Ruby on Rails log file you wish to analyze (ex: /var/www/apps/APP_NAME/current/log/production.log)." + max_request_length: + name: Max Request Length (sec) + notes: If any request length is larger than this amount, an alert is generated (see Advanced for more options) + default: 3 + rla_run_time: + name: Request Log Analyzer Run Time (HH:MM) + notes: It's best to schedule these summaries about fifteen minutes before any logrotate cron job you have set would kick in. + default: '23:45' + attributes: advanced + ignored_actions: + name: Ignored Actions + notes: Takes a regex. Any URIs matching this regex will NOT count as slow requests, and you will NOT be notified if they exceed Max Request Length. Matching actions will still be included in daily summaries. + attributes: advanced + EOS + needs "elif" needs "request_log_analyzer" @@ -92,6 +110,9 @@ def build_report avg = total_request_time / request_count report_data[:average_request_length] = sprintf("%.2f", avg) + + report_data[:slow_requests_percentage] = (request_count == 0) ? 0 : (slow_request_count.to_f / request_count.to_f) * 100.0 + end remember(:last_request_time, Time.now) report(report_data) diff --git a/rails_requests/rails_requests.yml b/rails_requests/rails_requests.yml index dc094cde..fee53dd6 100644 --- a/rails_requests/rails_requests.yml +++ b/rails_requests/rails_requests.yml @@ -1,21 +1,3 @@ -options: - log: - name: Full Path to Rails Log File - notes: "The full path to the Ruby on Rails log file you wish to analyze (ex: /var/www/apps/APP_NAME/current/log/production.log)." - max_request_length: - name: Max Request Length (sec) - notes: If any request length is larger than this amount, an alert is generated (see Advanced for more options) - default: 3 - rla_run_time: - name: Request Log Analyzer Run Time (HH:MM) - notes: It's best to schedule these summaries about fifteen minutes before any logrotate cron job you have set would kick in. - default: '23:45' - advanced: true - ignored_actions: - name: Ignored Actions - notes: Takes a regex. Any URIs matching this regex will NOT count as slow requests, and you will NOT be notified if they exceed Max Request Length. Matching actions will still be included in daily summaries. - advanced: true - metadata: request_rate: precision: 2 @@ -28,7 +10,10 @@ metadata: precision: 2 label: Slow Requests units: req/min - + slow_requests_percentage: + precision: 0 + units: "%" + triggers: - type: trend dname: request_rate