dashing-contrib 0.1.14 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 243b48fd56fbbd707229e45199f3e93924b534e6
4
- data.tar.gz: a65cc15ddff4dce410c03ca7fa69366c66d20fa6
3
+ metadata.gz: d7c4e4ad2170d67c910a352eddd02538f6a84e0b
4
+ data.tar.gz: 5cfd6158e6e8be951ce1414419834ea2dfa5580e
5
5
  SHA512:
6
- metadata.gz: 3609c31c176dc5fefdbe6126d771dfbfaeb4b79a585475dcb989c3282fc90145be7846dffc757be9580f9c5c20aad1b6cf43afe2a7d470d5643c691678b67db1
7
- data.tar.gz: e0d457b2fbf78d2f46c6ee6f572535ab51a28c5425eeb7a34028dc1e32ec3c333f564aa5fd24d96dce0878f187b4dc7af4f718df1019943a83b6712289aeb470
6
+ metadata.gz: 59e4833eeef48765bc87cdb45bcd312461901214938b0bf985c4e8292e650c2d739d2cd49f6e88fbfd61878c5f4fdcab37d128fb0dd07ad5ff487c582b6022dc
7
+ data.tar.gz: c4ca13ab3bfc906460cc672c81c9f2d3e166886868697412991a77d508301e2a30e6ca346acd882fa36569e2b61a629824adf506dce806de73eecfded2f39c19
data/README.md CHANGED
@@ -44,6 +44,7 @@ Now you will be able to use the following widgets, click to see individual docum
44
44
  * [Rickshawgraph](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Rickshawgraph)
45
45
  * [Sidekiq](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Sidekiq)
46
46
  * [Pingdom Uptime](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Pingdom-Uptime)
47
+ * [Pingdom Summary](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Pingdom-Summary)
47
48
  * [Kue Status](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Kue-Status)
48
49
  * [Nagios List](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Nagios-List)
49
50
  * [Switcher](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Switcher)
@@ -127,6 +128,7 @@ Take a look some build-in jobs as example:
127
128
  * [dashing-contrib/jobs/kue.rb](https://github.com/QubitProducts/dashing-contrib/blob/master/lib/dashing-contrib/jobs/kue.rb)
128
129
  * [dashing-contrib/jobs/nagios_list.rb](https://github.com/QubitProducts/dashing-contrib/blob/master/lib/dashing-contrib/jobs/nagios_list.rb)
129
130
  * [dashing-contrib/jobs/pingdom_uptime.rb](https://github.com/QubitProducts/dashing-contrib/blob/master/lib/dashing-contrib/jobs/pingdom_uptime.rb)
131
+ * [dashing-contrib/jobs/pingdom_summary.rb](https://github.com/QubitProducts/dashing-contrib/blob/master/lib/dashing-contrib/jobs/pingdom_summary.rb)
130
132
  * [dashing-contrib/jobs/dashing-state.rb](https://github.com/QubitProducts/dashing-contrib/blob/master/lib/dashing-contrib/jobs/dashing-state.rb)
131
133
 
132
134
  This is nice that backend data fetching can be now unit tested and reused. Dashing widget view layer can reuse the same job processor and present data in multiple forms.
@@ -0,0 +1,17 @@
1
+ class Dashing.PingdomSummary extends Dashing.Widget
2
+ @accessor 'up', Dashing.AnimatedValue
3
+ @accessor 'down', Dashing.AnimatedValue
4
+ @accessor 'unconfirmed_down', Dashing.AnimatedValue
5
+ @accessor 'unknown', Dashing.AnimatedValue
6
+ @accessor 'paused', Dashing.AnimatedValue
7
+ @accessor 'arrowClass', ->
8
+ switch @get('status')
9
+ when "ok" then 'fa fa-smile-o'
10
+ when "critical" then 'fa fa-frown-o'
11
+ else 'fa fa-meh-o'
12
+
13
+ @accessor 'statusClass', ->
14
+ switch @get('status')
15
+ when "ok" then 'current-status-container status-up'
16
+ when "critical" then 'current-status-container status-down'
17
+ else 'current-status-container status-unknown'
@@ -0,0 +1,57 @@
1
+ <div data-bind-class="state | prepend 'dashing-contrib state-'">
2
+ <section class="body">
3
+ <div class="canvas">
4
+
5
+ <div class="current-status-container" data-bind-class="statusClass">
6
+ <span data-bind="title"></span>
7
+ <span data-bind-class="arrowClass"></span>
8
+ </div>
9
+
10
+ <div class="row">
11
+ <div>
12
+ <p class="left">Up:</p>
13
+ <p class="figure right" data-bind="up | shortenedNumber | prepend prefix | append suffix"></p>
14
+ </div>
15
+ </div>
16
+
17
+ <div class="row">
18
+ <div>
19
+ <p class="left top">Paused:</p>
20
+ <p class="figure right top" data-bind="paused | shortenedNumber | prepend prefix | append suffix"></p>
21
+ </div>
22
+ </div>
23
+
24
+ <div class="row">
25
+ <div>
26
+ <p class="left top">Unconfirmed:</p>
27
+ <p class="figure right top" data-bind="unconfirmed_down | shortenedNumber | prepend prefix | append suffix"></p>
28
+ </div>
29
+ </div>
30
+
31
+ <div class="row">
32
+ <p class="left top">Down:</p>
33
+ <p class="figure right top" data-bind="down | shortenedNumber | prepend prefix | append suffix"></p>
34
+ </div>
35
+
36
+ <div class="row">
37
+ <p class="left top">Unknown:</p>
38
+ <p class="figure right top" data-bind="unknown | shortenedNumber | prepend prefix | append suffix"></p>
39
+ </div>
40
+
41
+ <div class="row">
42
+ <p class="left doubletop">Total:</p>
43
+ <p class="figure right doubletop" data-bind="total | shortenedNumber | prepend prefix | append suffix"></p>
44
+ </div>
45
+
46
+ <div class="row">
47
+ <ul class="list-nostyle">
48
+ <li data-foreach-item="items">
49
+ <span data-bind-class="item.state | prepend 'site-state-'">
50
+ <span data-bind-class="item.state | prepend 'fa fa-' | append '-o' | replace 'ok', 'smile' | replace 'warning', 'meh' | replace 'critical','frown'" class="fa"></span></span>
51
+ <span class="value" data-bind="item.label"></span>
52
+ </li>
53
+ </ul>
54
+ </div>
55
+ </div>
56
+ </section>
57
+ </div>
@@ -0,0 +1,93 @@
1
+ // ----------------------------------------------------------------------------
2
+ // Sass declarations
3
+ // ----------------------------------------------------------------------------
4
+ $background-color: #2A2A2A;
5
+ $value-color: #73AA3A;
6
+
7
+ $title-color: #B2B2B2;
8
+ $moreinfo-color: rgba(255, 255, 255, 0.7);
9
+
10
+ // ----------------------------------------------------------------------------
11
+ // Widget styles
12
+ // ----------------------------------------------------------------------------
13
+ .widget-pingdom-summary {
14
+ //refreshing default widget definition
15
+ vertical-align: baseline !important;
16
+ padding:0px !important;
17
+
18
+ background-color: $background-color;
19
+
20
+ header{
21
+ background-color: #272727;
22
+ text-transform: uppercase;
23
+ padding: 5px 0px 5px 0px;
24
+ font-weight: 700;
25
+ font-size: 12px;
26
+ text-shadow: 1px 1px #0e0e0e;
27
+ }
28
+ .title {
29
+ color: $title-color;
30
+ font-size: inherit;
31
+ }
32
+
33
+ .body {
34
+ padding: 0px;
35
+ color: #d3d4d4;
36
+ text-shadow: 1px 1px #0e0e0e;
37
+ font-family: Helvetica, Arial, sans-serif;
38
+ z-index: 1;
39
+
40
+ .row {
41
+ width:100%;
42
+ }
43
+ .left {
44
+ float:left;
45
+ width:50%;
46
+ }
47
+ .right {
48
+ float:right;
49
+ width:49%;
50
+ border-left: 1px dotted #8b8b8b;
51
+ }
52
+ .top {
53
+ border-top: 1px dotted #8b8b8b;
54
+ }
55
+ .doubletop {
56
+ border-top: 2px dotted #8b8b8b;
57
+ border-bottom: 1px dotted #8b8b8b;
58
+ }
59
+ }
60
+
61
+ .current-status-container {
62
+ padding: 10px;
63
+ font-size: 30px;
64
+ text-shadow: none;
65
+ &.status-up {
66
+ color: #9ACA3C;
67
+ }
68
+ &.status-unknown {
69
+ color: #D9D31E;
70
+ }
71
+ &.status-down {
72
+ color: #C32026;
73
+ }
74
+
75
+ i.fa {
76
+ font-size: 55px;
77
+ }
78
+ }
79
+
80
+ .value {
81
+ font-size: 10px;
82
+ }
83
+
84
+ .site-state-ok {
85
+ color: #9ACA3C;
86
+ }
87
+ .site-state-warning {
88
+ color: #D9D31E;
89
+ }
90
+ .site-state-critical {
91
+ color: #C32026;
92
+ }
93
+ }
@@ -10,12 +10,36 @@ module DashingContrib
10
10
  make_request(credentials, id)
11
11
  end
12
12
 
13
+ def summary(credentials)
14
+ checks = make_request(credentials, nil)
15
+ states = { 'up' => { checks: { }, value: 0 },
16
+ 'down' => { checks: { }, value: 0 },
17
+ 'unconfirmed_down' => { checks: { }, value: 0 },
18
+ 'unknown' => { checks: { }, value: 0 },
19
+ 'paused' => { checks: { }, value: 0 }
20
+ }
21
+
22
+ checks[:checks].each { |check|
23
+ states[check[:status]] = { checks: states[check[:status]][:checks], value: (states[check[:status]][:value] + 1) }
24
+ if check.has_key?(:lasterrortime)
25
+ states[check[:status]][:checks][check[:lasterrortime]] = check[:name]
26
+ elsif check.has_key?(:lasttesttime)
27
+ states[check[:status]][:checks][check[:lasttesttime]] = check[:name]
28
+ end
29
+ }
30
+ return states
31
+ end
32
+
13
33
  private
14
34
  def make_request(credentials, id)
15
- request_url = "https://#{credentials.username}:#{credentials.password}@api.pingdom.com/api/2.0/checks/#{id}"
35
+ if ( id.nil? )
36
+ request_url = "https://#{credentials.username}:#{credentials.password}@api.pingdom.com/api/2.0/checks/"
37
+ else
38
+ request_url = "https://#{credentials.username}:#{credentials.password}@api.pingdom.com/api/2.0/checks/#{id}"
39
+ end
16
40
  response = RestClient.get(request_url, { 'App-Key' => credentials.api_key })
17
41
  MultiJson.load response.body, { symbolize_keys: true }
18
42
  end
19
43
  end
20
44
  end
21
- end
45
+ end
@@ -18,6 +18,10 @@ module DashingContrib
18
18
  def uptime(id, from_time, to_time)
19
19
  ::DashingContrib::Pingdom::Uptime.calc(credentials, id, from_time, to_time)
20
20
  end
21
+
22
+ def summary()
23
+ ::DashingContrib::Pingdom::Checks.summary(credentials)
24
+ end
21
25
  end
22
26
  end
23
- end
27
+ end
@@ -0,0 +1,72 @@
1
+ require 'dashing-contrib/bottles/pingdom'
2
+
3
+ module DashingContrib
4
+ module Jobs
5
+ module PingdomSummary
6
+ extend DashingContrib::RunnableJob
7
+
8
+ def self.metrics(options)
9
+ client = DashingContrib::Pingdom::Client.new(
10
+ username: options[:username],
11
+ password: options[:password],
12
+ api_key: options[:api_key]
13
+ )
14
+
15
+ status = client.summary()
16
+ sum_status = 'ok'
17
+ sum_total = status["up"][:value] +
18
+ status["paused"][:value] +
19
+ status["unconfirmed_down"][:value] +
20
+ status["down"][:value] +
21
+ status["unknown"][:value]
22
+ sum_ok = status["up"][:value] + status["paused"][:value]
23
+ sum_warn = status["unknown"][:value]
24
+ sum_crit = status["down"][:value] + status["unconfirmed_down"][:value]
25
+ sum_status = 'warning' if sum_warn > 0
26
+ sum_status = 'critical' if sum_crit > 0
27
+
28
+ tofind = options[:list_top] || 3
29
+ list = Array.new
30
+
31
+ stateMap = { 'up' => 'ok',
32
+ 'paused' => 'warning',
33
+ 'unknown' => 'warning',
34
+ 'down' => 'critical',
35
+ 'unconfirmed_down' => 'critical' }
36
+
37
+ repStates = ["down","unconfirmed_down","unknown","paused"]
38
+ repStates.insert(-1, "up") if options[:include_up] || false
39
+ repStates.each { |state|
40
+ if tofind > 0
41
+ touse = status[state][:checks].keys.sort.take(tofind)
42
+ tofind = tofind - touse.size
43
+ touse.each { |key|
44
+ list.concat( [ { state: stateMap[state], label: status[state][:checks][key] } ] )
45
+ }
46
+ end
47
+ }
48
+
49
+ # returns this dataset
50
+ {
51
+ status: sum_status,
52
+ total: sum_total,
53
+ ok: sum_ok,
54
+ error: sum_crit,
55
+ up: status["up"][:value],
56
+ down: status["down"][:value],
57
+ unknown: status["unknown"][:value],
58
+ paused: status["paused"][:value],
59
+ unconfirmed_down: status["unconfirmed_down"][:value],
60
+ items: list,
61
+ }
62
+ end
63
+
64
+ def self.validate_state(metrics, options = {})
65
+ return DashingContrib::RunnableJob::CRITICAL if metrics[:status] == 'critical'
66
+ return DashingContrib::RunnableJob::WARNING if metrics[:status] == 'warning'
67
+ DashingContrib::RunnableJob::OK
68
+ end
69
+
70
+ end
71
+ end
72
+ end
@@ -1,3 +1,3 @@
1
1
  module DashingContrib
2
- VERSION = '0.1.14'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dashing-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jing Dong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -221,6 +221,9 @@ files:
221
221
  - lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
222
222
  - lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.html
223
223
  - lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.scss
224
+ - lib/dashing-contrib/assets/widgets/pingdom_summary/pingdom_summary.coffee
225
+ - lib/dashing-contrib/assets/widgets/pingdom_summary/pingdom_summary.html
226
+ - lib/dashing-contrib/assets/widgets/pingdom_summary/pingdom_summary.scss
224
227
  - lib/dashing-contrib/assets/widgets/pingdom_uptime/pingdom_uptime.coffee
225
228
  - lib/dashing-contrib/assets/widgets/pingdom_uptime/pingdom_uptime.html
226
229
  - lib/dashing-contrib/assets/widgets/pingdom_uptime/pingdom_uptime.scss
@@ -248,6 +251,7 @@ files:
248
251
  - lib/dashing-contrib/jobs/dashing-state.rb
249
252
  - lib/dashing-contrib/jobs/kue.rb
250
253
  - lib/dashing-contrib/jobs/nagios_list.rb
254
+ - lib/dashing-contrib/jobs/pingdom_summary.rb
251
255
  - lib/dashing-contrib/jobs/pingdom_uptime.rb
252
256
  - lib/dashing-contrib/jobs/sidekiq.rb
253
257
  - lib/dashing-contrib/routes.rb