Permalink
Browse files

Heartbeat page is a little more user-friendly.

  • Loading branch information...
1 parent b320d62 commit 9337d902f50f16869aa62edc955ffd0f6e8f9321 @bguthrie bguthrie committed Aug 19, 2013
@@ -4,11 +4,11 @@ $(document).ready(function() {
increasing = colors[0] < colors[2];
$(this).find(".point").each(function() {
- var value = parseFloat($(this).text());
+ var value = parseFloat($(this).data("value") || $(this).text());
var color = increasing ?
( value <= colors[1] ? "red" : ( value <= colors[2] ? "orange" : "green" ) ) :
- ( value > colors[1] ? "red" : ( value > colors[2] ? "orange" : "green" ) );
+ ( value >= colors[0] ? "red" : ( value >= colors[1] ? "orange" : "green" ) );
$(this).css({ color: color });
});
@@ -63,6 +63,10 @@ def initialize heartbeat, fails_app
super heartbeat, fails_app, "INACTIVE"
end
+ def gap
+ @last_timestamp.blank? ? 0 : Time.now.to_i - @last_timestamp.to_i
+ end
+
def check
@threshold = ENV['VK_HEARTBEAT_SENT_EMAIL'].try(:to_i) || 5
@last_timestamp = @heartbeat.last_sent_email
@@ -82,6 +86,10 @@ def initialize heartbeat, fails_app
super heartbeat, fails_app, "INACTIVE"
end
+ def gap
+ @last_timestamp.blank? ? 0 : Time.now.to_i - @last_timestamp.to_i
+ end
+
def check
@threshold = ENV['VK_HEARTBEAT_SIGNATURE'].try(:to_i) || 60
# Failing on a shortage of signatures turned out to be a bit overzealous, particularly in the middle of the night.
@@ -104,8 +112,12 @@ def workers
@workers ||= Sidekiq::Workers.new.size
end
+ def threshold
+ 100
+ end
+
def check
- @ok = max_q <= 100
+ @ok = max_q <= threshold
end
def stats
@@ -15,15 +15,11 @@ def emails_sent_since date_time
def emailable_members
Member.count - Unsubscribe.count
end
-
+
def new_members
Signature.where(created_member: true).count - Unsubscribe.where("cause='unsubscribed'").count
end
- def workers
- Resque.info[:workers]
- end
-
def status
status = ApplicationStatus.new.tap do |s|
s[:email] = EmailStatus.new self, true
@@ -4,99 +4,52 @@
%h3{:class => @status.style} Application Status: #{@status.text}
%table.table.table-condensed.bordered-table.table-striped
+ - email_seconds = @status[:email].threshold.minutes.to_i
+ - signature_seconds = @status[:signature].threshold.minutes.to_i
%thead
- %th
- Status
- %th
- Function
- %th
- Fails App
- %th
- Threshold (minutes)
- %th
- Last
- %th{:colspan => 3}
- %tr
- %td{:class => @status[:email].style }
- #{@status[:email].text }
- %td
- Sending emails
- %td
- #{@status[:email].fails_app?}
- %td
- #{@status[:email].threshold}
- %td
- #{@status[:email].last_timestamp}
- %td{:colspan => 4}
- %tr
- %td{:class => @status[:signature].style }
- #{@status[:signature].text}
- %td
- Collecting signatures
- %td
- #{@status[:signature].fails_app?}
- %td
- #{@status[:signature].threshold}
- %td
- #{@status[:signature].last_timestamp}
- %td{:colspan => 4}
+ %th Status
+ %th Function
+ %th Fails App
+ %th Threshold
+ %th Value
+ %th Comments
- %tr
- %td{:colspan => 8}
- &nbsp;
-
- %thead
- %th
- Status
- %th
- Component
- %th
- Fails App
- %th
- Workers
- %th
- Pending
- %th
- Processed
- %th
- Working
- %th
- Failed
- %th
- Max Q
- %tr
- %td{:class => @status[:resque].style }
- #{@status[:resque].text}
- %td
- Resque
- %td
- #{@status[:resque].fails_app?}
- %td
- #{@status[:resque].workers}
- %td
- #{@status[:resque].stats.enqueued}
- %td
- #{@status[:resque].stats.processed}
+ %tr.colorize{data: { colors: [ email_seconds, email_seconds / 3.0, 0 ].join(",") }}
+ %td{:class => @status[:email].style }= @status[:email].text
+ %td Last email sent
+ %td= @status[:email].fails_app?
+ %td No more than #{@status[:email].threshold} minutes ago
+ %td.point{data: { value: @status[:email].gap }}
+ = time_ago_in_words @status[:email].last_timestamp || Time.now
%td
- #{@status[:resque].workers}
- %td
- #{@status[:resque].stats.failed}
+
+ %tr.colorize{data: { colors: [ signature_seconds, signature_seconds / 3.0, 0 ].join(",") }}
+ %td{:class => @status[:signature].style }= @status[:signature].text
+ %td Last signature created
+ %td= @status[:signature].fails_app?
+ %td No more than #{@status[:signature].threshold} minutes ago
+ %td.point{data: { value: Time.now.to_i - @status[:signature].last_timestamp.to_i }}
+ = time_ago_in_words @status[:signature].last_timestamp
%td
- #{@status[:resque].max_q}
+
+ %tr.colorize{data: { colors: "100,20,0" }}
+ %td{:class => @status[:resque].style}= @status[:resque].text
+ %td Total pending email jobs
+ %td= @status[:resque].fails_app?
+ %td No more than #{@status[:resque].threshold} pending jobs
+ %td.point= @status[:resque].max_q
+ %td
+ %a{href: sidekiq_web_path} Worker status
%h3 Statistics
%table.table.table-condensed.bordered-table.table-striped
%tr
- %td{:width => "220 px"}
- Emails sent in the past week
- %td
- #{@emails_sent_past_week}
+ %td{:width => "220 px"} Emails sent in the past week
+ %td= @emails_sent_past_week
%td
%tr
- %td
- Number of emailable members
- %td
- #{@emailable_members}
+ %td Number of emailable members
+ %td= @emailable_members
%td

0 comments on commit 9337d90

Please sign in to comment.