Created
July 1, 2015 16:18
-
-
Save mapledyne/084d3a6daf0f8abda6aa to your computer and use it in GitHub Desktop.
Will mark stale widgets in Dashing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$background-stale-color-1: #cc9999; | |
$background-stale-color-2: #333333; | |
$text-stale-color: #fff; | |
@-webkit-keyframes status-stale-background { | |
0% { background-color: $background-stale-color-1; } | |
50% { background-color: $background-stale-color-2; } | |
100% { background-color: $background-stale-color-1; } | |
} | |
.widget.status-stale { | |
background-color: $background-stale-color-1; | |
@include animation(status-stale-background, 2s, ease, infinite); | |
.icon-warning-sign { | |
display: inline-block; | |
} | |
.title, .more-info { | |
color: $text-stale-color; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
threshold = 7200 | |
stale = "stale" | |
SCHEDULER.every '1m' do | |
widgets = Sinatra::Application.settings.history | |
total = 0 | |
widgets.each do |key, value| | |
update_s = value.to_s.slice(value.to_s.index("updatedAt")+11..-1).tr('}','').strip | |
updated = update_s.to_i | |
now = Time.new().to_i | |
diff = now-updated | |
min = diff/60 | |
if diff>threshold | |
puts "Stale widget (" + key.to_s + ") update time: " + min.to_s + " minutes ago." | |
send_event(key.to_s, { status: stale }) | |
total = total + 1 | |
end | |
end | |
puts "Stale widgets: " + total.to_s | |
send_event("stale_widgets", { value: total, current: total }) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you sir are a genius! i have no idea what i was doing wrong, but i now have it working like a champ. going to let it run all night and see how things look in the morning. this is going to be a great tool for our IT Dept! thanks for the work you put into this.