summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2017-10-17 02:21:23 -0200
committerdrebs <drebs@riseup.net>2017-10-17 02:49:16 -0200
commitbb8c98053434e5aa0de09b0a2a0fbe35e69542f3 (patch)
treeba80802ca61fa8b2bd03c79c057d191e4abfbe95
parentc3e807eb42ea7389676b714584bde204eab18577 (diff)
Add benchmark status to dashboard.
A "benchmarks" widget is added, together with a update job. The job queries the benchmarks.leap.se website and shows current benchmarking status and outliers. It's a simple start for something that can get more complex depending on identified needs.
-rw-r--r--dashboards/dashboard.erb6
-rw-r--r--jobs/update_benchmark.rb16
-rw-r--r--widgets/benchmarks/benchmarks.coffee15
-rw-r--r--widgets/benchmarks/benchmarks.html23
-rw-r--r--widgets/benchmarks/benchmarks.scss13
5 files changed, 71 insertions, 2 deletions
diff --git a/dashboards/dashboard.erb b/dashboards/dashboard.erb
index 619d594..baa57d9 100644
--- a/dashboards/dashboard.erb
+++ b/dashboards/dashboard.erb
@@ -1,7 +1,6 @@
-<li data-row="1" data-col="1" data-sizex="2" data-sizey="2">
+<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
<div data-id="gitlab-builds" data-view="GitlabBuildStatus" data-title="Builds"></div>
</li>
-
<li data-row="1" data-col="3" data-sizex="2" data-sizey="1">
<div data-id="nagios-mail" data-view="Nagios" data-unordered="true" data-title="Nagios mail.bitmask" data-moreinfo="Unacknowledged events"></div>
</li>
@@ -9,6 +8,9 @@
<div data-id="nagios-dev" data-view="Nagios" data-unordered="true" data-title="Nagios dev.bitmask" data-moreinfo="Unacknowledged events"></div>
</li>
+<li data-row="2" data-col="1" data-sizex="2" data-sizey="1">
+ <div data-id="benchmarks" data-view="Benchmarks" data-unordered="true" data-title="benchmarks.leap.se"></div>
+</li>
<li data-row="2" data-col="3" data-sizex="2" data-sizey="1">
<div data-id="nagios-demo" data-view="Nagios" data-unordered="true" data-title="Nagios demo.bitmask" data-moreinfo="Unacknowledged events"></div>
</li>
diff --git a/jobs/update_benchmark.rb b/jobs/update_benchmark.rb
new file mode 100644
index 0000000..8e98db3
--- /dev/null
+++ b/jobs/update_benchmark.rb
@@ -0,0 +1,16 @@
+require "json"
+require "net/http"
+require "uri"
+
+outliers_uri = URI.parse("https://benchmarks.leap.se/outliers.json")
+is_benchmarked_uri = URI.parse("https://benchmarks.leap.se/is-benchmarked.html")
+
+SCHEDULER.every '5m', :first_in => 0 do |job|
+ response = Net::HTTP.get(outliers_uri)
+ outliers = JSON.parse(response)
+
+ response = Net::HTTP.get(is_benchmarked_uri)
+ benchmarked = response.gsub /<[^>]+>/, ''
+
+ send_event('benchmarks', { "good": outliers["good"].length, "bad": outliers["bad"].length, "is-benchmarked-status": benchmarked})
+end
diff --git a/widgets/benchmarks/benchmarks.coffee b/widgets/benchmarks/benchmarks.coffee
new file mode 100644
index 0000000..1d47b7c
--- /dev/null
+++ b/widgets/benchmarks/benchmarks.coffee
@@ -0,0 +1,15 @@
+class Dashing.Benchmarks extends Dashing.Widget
+
+ ready: ->
+ # This is fired when the widget is done being rendered
+
+ onData: (data) ->
+ # Handle incoming data
+ # You can access the html node of this widget with `@node`
+ # Example: $(@node).fadeOut().fadeIn() will make the node flash each time data comes in.
+
+ @accessor 'hasBadOutliers', ->
+ @get('bad') > 0
+
+ @accessor 'hasGoodOutliers', ->
+ @get('good') > 0
diff --git a/widgets/benchmarks/benchmarks.html b/widgets/benchmarks/benchmarks.html
new file mode 100644
index 0000000..d7dda1c
--- /dev/null
+++ b/widgets/benchmarks/benchmarks.html
@@ -0,0 +1,23 @@
+<h1 class="title"><a href="https://benchmarks.leap.se/"><span data-bind="title"></span></a></h1>
+
+<p>&nbsp;</p>
+
+<h4><a href="https://benchmarks.leap.se"><span>Current Status</span></a></h4>
+
+<p>
+ <a href="https://benchmarks.leap.se">
+ <span data-bind="is-benchmarked-status"></span>
+ </a>
+</p>
+
+<p>&nbsp;</p>
+
+<h4><a href="https://benchmarks.leap.se">Recent Outliers</a></h4>
+
+<p>
+ <a href="https://benchmarks.leap.se">
+ <span data-bind="good" data-addclass-good="hasGoodOutliers"></span> / <span data-bind="bad" data-addclass-bad="hasBadOutliers"></span></a>
+ </a>
+</p>
+
+<p class="updated-at" data-bind="updatedAtMessage"></p>
diff --git a/widgets/benchmarks/benchmarks.scss b/widgets/benchmarks/benchmarks.scss
new file mode 100644
index 0000000..7acfe24
--- /dev/null
+++ b/widgets/benchmarks/benchmarks.scss
@@ -0,0 +1,13 @@
+.widget-benchmarks {
+ background-color: black;
+}
+
+.good {
+ color: green;
+ font-weight: bold;
+}
+
+.bad {
+ color: #d93c38;
+ font-weight: bold;
+}