dashing-contrib 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +41 -7
- data/lib/dashing-contrib/assets/widgets/dashing_state/dashing_state.coffee +5 -8
- data/lib/dashing-contrib/assets/widgets/dashing_state/dashing_state.html +2 -2
- data/lib/dashing-contrib/history.rb +11 -1
- data/lib/dashing-contrib/routes.rb +8 -0
- data/lib/dashing-contrib/version.rb +1 -1
- metadata +2 -9
- data/lib/dashing-contrib/assets/widgets/kue_status/README.md +0 -41
- data/lib/dashing-contrib/assets/widgets/kue_status/preview.png +0 -0
- data/lib/dashing-contrib/assets/widgets/pingdom_uptime/README.md +0 -68
- data/lib/dashing-contrib/assets/widgets/pingdom_uptime/preview.png +0 -0
- data/lib/dashing-contrib/assets/widgets/rickshawgraph/README.md +0 -86
- data/lib/dashing-contrib/assets/widgets/sidekiq/README.md +0 -36
- data/lib/dashing-contrib/assets/widgets/sidekiq/preview.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec500df2f1e3dabe80001d360235bab603642512
|
4
|
+
data.tar.gz: 5f27671229a2809906e0dd522b2767cf4fcd3372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c41b316df3d7f77cac798f53414ca25c49e08ac195c192dd13c9510277703b21bbb4c2f383c320185c166cd98565a57b4f157e7a10fb19def458a0ebc04a7af
|
7
|
+
data.tar.gz: e9ac3b976d43ecc3ea5929e9498c3f8f9dd9e5b128049a5e5740f7948ada8dc17e5f397424178866b64168d999ebe4b8d4bb5fa6e3ec9e8304dd0752bcadc13d
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Read each individual widget documentation to use dashing-contrib built-in widget
|
|
17
17
|
## Installation
|
18
18
|
Add this line to your Dashing's dashboard Gemfile:
|
19
19
|
|
20
|
-
gem 'dashing-contrib', '~> 0.1.
|
20
|
+
gem 'dashing-contrib', '~> 0.1.1'
|
21
21
|
|
22
22
|
Update dependencies:
|
23
23
|
|
@@ -40,12 +40,12 @@ Include built-in SCSS to `assets/stylesheets/application.scss`
|
|
40
40
|
|
41
41
|
Now you will be able to use the following widgets, click to see individual documentation:
|
42
42
|
|
43
|
-
* [Rickshawgraph](https://github.com/QubitProducts/dashing-contrib/
|
44
|
-
* [Sidekiq](https://github.com/QubitProducts/dashing-contrib/
|
45
|
-
* [Pingdom Uptime](https://github.com/QubitProducts/dashing-contrib/
|
46
|
-
* [Kue Status](https://github.com/QubitProducts/dashing-contrib/
|
47
|
-
* [Nagios List](https://github.com/QubitProducts/dashing-contrib/
|
48
|
-
* Dashing State
|
43
|
+
* [Rickshawgraph](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Rickshawgraph)
|
44
|
+
* [Sidekiq](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Sidekiq)
|
45
|
+
* [Pingdom Uptime](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Pingdom-Uptime)
|
46
|
+
* [Kue Status](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Kue-Status)
|
47
|
+
* [Nagios List](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Nagios-List)
|
48
|
+
* Dashing State (global alert if any widget is under critical state)
|
49
49
|
|
50
50
|
## dotenv
|
51
51
|
|
@@ -126,6 +126,40 @@ Take a look some build-in jobs as example:
|
|
126
126
|
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.
|
127
127
|
|
128
128
|
|
129
|
+
# Widget State
|
130
|
+
|
131
|
+
All built-in jobs managed by 'DashingContrib::Runnable' assumes each widget instance has a 'state' under ok, warning or critical. We suggest your custom widget should also follow this convension.
|
132
|
+
|
133
|
+
This gem creates an additional REST API, as well as a widget to show a global healthness of the system. This is awesome if you would like to build some physical alert system around it.
|
134
|
+
|
135
|
+
`GET http://{dashing_endpoint}/api/states`
|
136
|
+
|
137
|
+
```json
|
138
|
+
{
|
139
|
+
"ok": 2,
|
140
|
+
"warning": 0,
|
141
|
+
"critical": 0,
|
142
|
+
"detailed_status": {
|
143
|
+
"dashboard": {
|
144
|
+
"state": "ok",
|
145
|
+
"title": "Dashboard",
|
146
|
+
"updated_at": 1403823187
|
147
|
+
},
|
148
|
+
"nagios-list": {
|
149
|
+
"state": "ok",
|
150
|
+
"title": "Nagios Checks",
|
151
|
+
"updated_at": 1403823178
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
```
|
156
|
+
|
157
|
+
# Persistent History
|
158
|
+
|
159
|
+
A new REST endpoint allows to force keep a snapshot of current events data and update the history.yml yaml file.
|
160
|
+
|
161
|
+
`Post http://{dashing_endpoint}/api/history/save`
|
162
|
+
|
129
163
|
|
130
164
|
## How to contribute
|
131
165
|
|
@@ -1,11 +1,8 @@
|
|
1
1
|
class Dashing.DashingState extends Dashing.Widget
|
2
|
-
@accessor 'items', ->
|
3
|
-
items = []
|
4
|
-
for key, item of @detailed_status
|
5
|
-
items = items.concat(item)
|
6
|
-
|
7
|
-
return items
|
8
|
-
|
9
|
-
|
10
2
|
|
3
|
+
@accessor 'widgetStates', ->
|
4
|
+
checks = []
|
5
|
+
for key, item of @get('detailed_status')
|
6
|
+
checks = checks.concat(item)
|
11
7
|
|
8
|
+
checks
|
@@ -17,8 +17,8 @@
|
|
17
17
|
|
18
18
|
</div>
|
19
19
|
<ul>
|
20
|
-
<li data-foreach-
|
21
|
-
<span data-bind="
|
20
|
+
<li data-foreach-state="widgetStates" data-bind-class="state.state | prepend 'item-state-'">
|
21
|
+
<span data-bind="state.title"></span>
|
22
22
|
</li>
|
23
23
|
</ul>
|
24
24
|
</div>
|
@@ -8,7 +8,17 @@ module DashingContrib
|
|
8
8
|
def history
|
9
9
|
Sinatra::Application.settings.history
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
|
+
def history_file
|
13
|
+
Sinatra::Application.settings.history_file
|
14
|
+
end
|
15
|
+
|
16
|
+
def save
|
17
|
+
File.open(history_file, 'w') do |f|
|
18
|
+
f.puts history.to_yaml
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
12
22
|
def raw_event(event_name)
|
13
23
|
return nil if history[event_name].nil?
|
14
24
|
history[event_name].gsub(/^data:/, '')
|
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.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jing Dong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -214,25 +214,18 @@ files:
|
|
214
214
|
- lib/dashing-contrib/assets/widgets/dashing_state/dashing_state.coffee
|
215
215
|
- lib/dashing-contrib/assets/widgets/dashing_state/dashing_state.html
|
216
216
|
- lib/dashing-contrib/assets/widgets/dashing_state/dashing_state.scss
|
217
|
-
- lib/dashing-contrib/assets/widgets/kue_status/README.md
|
218
217
|
- lib/dashing-contrib/assets/widgets/kue_status/kue_status.coffee
|
219
218
|
- lib/dashing-contrib/assets/widgets/kue_status/kue_status.html
|
220
219
|
- lib/dashing-contrib/assets/widgets/kue_status/kue_status.scss
|
221
|
-
- lib/dashing-contrib/assets/widgets/kue_status/preview.png
|
222
220
|
- lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.coffee
|
223
221
|
- lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.html
|
224
222
|
- lib/dashing-contrib/assets/widgets/nagios_list/nagios_list.scss
|
225
|
-
- lib/dashing-contrib/assets/widgets/pingdom_uptime/README.md
|
226
223
|
- lib/dashing-contrib/assets/widgets/pingdom_uptime/pingdom_uptime.coffee
|
227
224
|
- lib/dashing-contrib/assets/widgets/pingdom_uptime/pingdom_uptime.html
|
228
225
|
- lib/dashing-contrib/assets/widgets/pingdom_uptime/pingdom_uptime.scss
|
229
|
-
- lib/dashing-contrib/assets/widgets/pingdom_uptime/preview.png
|
230
|
-
- lib/dashing-contrib/assets/widgets/rickshawgraph/README.md
|
231
226
|
- lib/dashing-contrib/assets/widgets/rickshawgraph/rickshawgraph.coffee
|
232
227
|
- lib/dashing-contrib/assets/widgets/rickshawgraph/rickshawgraph.html
|
233
228
|
- lib/dashing-contrib/assets/widgets/rickshawgraph/rickshawgraph.scss
|
234
|
-
- lib/dashing-contrib/assets/widgets/sidekiq/README.md
|
235
|
-
- lib/dashing-contrib/assets/widgets/sidekiq/preview.png
|
236
229
|
- lib/dashing-contrib/assets/widgets/sidekiq/sidekiq.coffee
|
237
230
|
- lib/dashing-contrib/assets/widgets/sidekiq/sidekiq.html
|
238
231
|
- lib/dashing-contrib/assets/widgets/sidekiq/sidekiq.scss
|
@@ -1,41 +0,0 @@
|
|
1
|
-
KueStatus Widget
|
2
|
-
=====
|
3
|
-
|
4
|
-

|
5
|
-
|
6
|
-
A widget shows current status of [Kue](https://github.com/learnboost/kue) job queue.
|
7
|
-
|
8
|
-
## Usage
|
9
|
-
|
10
|
-
Add the widget HTML to your dashboard
|
11
|
-
|
12
|
-
```html
|
13
|
-
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
|
14
|
-
<div data-id="kue-information" data-view="KueStatus" data-title="Kue information"></div>
|
15
|
-
</li>
|
16
|
-
````
|
17
|
-
|
18
|
-
## Job
|
19
|
-
|
20
|
-
An example of `jobs/kue_status_job.rb`
|
21
|
-
|
22
|
-
```ruby
|
23
|
-
# built-in Kue helpers
|
24
|
-
require 'dashing-contrib/bottles/kue'
|
25
|
-
|
26
|
-
SCHEDULER.every '10s' do
|
27
|
-
# Use .env file in your project to extract endpoint value
|
28
|
-
# if dev and production enviroment are different
|
29
|
-
client = DashingContrib::Kue::Client.new(endpoint: 'http://kue.example.com')
|
30
|
-
stats = client.stats
|
31
|
-
|
32
|
-
metrics = [
|
33
|
-
{ label: 'Processed', value: stats[:complete_count] },
|
34
|
-
{ label: 'Processing', value: stats[:active_count] },
|
35
|
-
{ label: 'Failed', value: stats[:failed_count] },
|
36
|
-
{ label: 'Queued', value: stats[:inactive_count] },
|
37
|
-
{ label: 'Delayed', value: stats[:delayed_count] }
|
38
|
-
]
|
39
|
-
send_event('kue-information', { metrics: metrics } )
|
40
|
-
end
|
41
|
-
````
|
Binary file
|
@@ -1,68 +0,0 @@
|
|
1
|
-
Pingdom Uptime
|
2
|
-
==============
|
3
|
-
|
4
|
-

|
5
|
-
|
6
|
-
|
7
|
-
### Requirement
|
8
|
-
|
9
|
-
The smile face requires font-awesome >= 4.1.0. dashing-contrib includes 4.1.0 CSS and load font from CDN. You can safely delete the fonts folder and font-awesome css files in generated dashing asset folder.
|
10
|
-
|
11
|
-
### Example html usage
|
12
|
-
|
13
|
-
```html
|
14
|
-
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
|
15
|
-
<div data-view="PingdomUptime"
|
16
|
-
data-id="pingdom-uptime"
|
17
|
-
data-title="Dashboard"></div>
|
18
|
-
</li>
|
19
|
-
```
|
20
|
-
|
21
|
-
|
22
|
-
### Example job
|
23
|
-
|
24
|
-
This also shows a coupld of dashing-contrib data APIs for pingdom.
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
# Some helper methods for pingdom
|
28
|
-
require 'dashing-contrib/bottles/pingdom'
|
29
|
-
|
30
|
-
SCHEDULER.every '30s' do
|
31
|
-
nowTime = Time.now.to_i
|
32
|
-
t1_month = 86400 * 30
|
33
|
-
|
34
|
-
# 24 hours
|
35
|
-
defaultDateRange = nowTime - 86400
|
36
|
-
# 4 months ago
|
37
|
-
firstDateRange = nowTime - (t1_month * 4)
|
38
|
-
# 1 year to date
|
39
|
-
secondDateRange = nowTime - (t1_month * 12)
|
40
|
-
|
41
|
-
client = DashingContrib::Pingdom::Client.new(
|
42
|
-
username: ENV['PINGDOM_USERNAME'],
|
43
|
-
password: ENV['PINGDOM_PASSWORD'],
|
44
|
-
api_key: ENV['PINGDOM_API_KEY']
|
45
|
-
)
|
46
|
-
# checks id provided by pingdom
|
47
|
-
id = '1234432'
|
48
|
-
current_uptime = client.uptime(id, defaultDateRange, nowTime)
|
49
|
-
first_uptime = client.uptime(id, firstDateRange, nowTime)
|
50
|
-
second_uptime = client.uptime(id, secondDateRange, nowTime)
|
51
|
-
status = client.checks(id)
|
52
|
-
|
53
|
-
data = {
|
54
|
-
current: current_uptime.to_s,
|
55
|
-
first: first_uptime.to_s,
|
56
|
-
first_title: '4 Months',
|
57
|
-
second: second_uptime.to_s,
|
58
|
-
second_title: 'YTD',
|
59
|
-
is_up: status[:check][:status] == 'up',
|
60
|
-
current_response_time: status[:check][:lastresponsetime],
|
61
|
-
last_downtime: ::DashingContrib::Time.readable_diff(::Time.at(status[:check][:lasterrortime]))
|
62
|
-
}
|
63
|
-
|
64
|
-
send_event("pingdom-uptime", data)
|
65
|
-
end
|
66
|
-
```
|
67
|
-
|
68
|
-
|
Binary file
|
@@ -1,86 +0,0 @@
|
|
1
|
-
Graphing Widget
|
2
|
-
===============
|
3
|
-
|
4
|
-
Documentation initally written by [jwalton](https://gist.github.com/jwalton) from [gist](https://gist.github.com/jwalton/6614023)
|
5
|
-
|
6
|
-
dashing-contrib includes this widget by default. If you want view template structured differently, you can create a HTML template in project root `widgets/rickshawgraph/rickshawgraph.html`.
|
7
|
-
|
8
|
-
|
9
|
-
The graphing widget shows graphs using the Rickshaw graphing library. The names of data fields
|
10
|
-
should be (vaguely) familiar if you've used Rickshaw before.
|
11
|
-
|
12
|
-
dashing-contrib includes [latest rickshaw.js](https://raw.github.com/shutterstock/rickshaw/master/rickshaw.min.js). You can delete generated rickshaw Javascript in dashing project assets folder.
|
13
|
-
|
14
|
-
Supported HTML data fields
|
15
|
-
--------------------------
|
16
|
-
|
17
|
-
* `data-title`: Title to display.
|
18
|
-
* `data-displayed-value`: If provided, then the value to display overtop of the graph. If not
|
19
|
-
provided, then the most recent value will be used if there is only one series.
|
20
|
-
* `data-renderer`: Any valid Rickshaw renderer, including 'area', 'line', 'bar', 'scatterplot'.
|
21
|
-
* `data-stroke`: If "true", then area graphs will be drawn with a stroke.
|
22
|
-
* `data-unstack`: If "true", then area and bar graphs will be "unstacked".
|
23
|
-
* `data-colors`: A ":" separated list of colors to use for each plot. If there are fewer colors
|
24
|
-
provided than there are series to graph, then pleasing colors will be automatically chosen. (e.g.:
|
25
|
-
`data-colors="#ccc:#ddd:#eee"`)
|
26
|
-
* `data-stroke-colors`: A ":" separated list of colors to use for strokes.
|
27
|
-
* `data-color-scheme`: One of "rainbow", "near-rainbow", "compliment", "default". Controls how
|
28
|
-
default colors are assigned.
|
29
|
-
* `data-default-alpha`: Alpha for default colors.
|
30
|
-
* `data-legend`: If "true", then a legend will be added to your graph.
|
31
|
-
* `data-min` and `data-max`: Set the highest and lowest values of the y-axis.
|
32
|
-
* `data-summary-method` determines how the value shown in the graph is computed. If
|
33
|
-
`data-displayed-value` is set, this is ignored. Otherwise this should be one of:
|
34
|
-
* "last" - Default - If there is only one series, show the most recent value from that series.
|
35
|
-
* "sum" - Sum of all values across all series.
|
36
|
-
* "sumLast" - Sum of last values across all series.
|
37
|
-
* "highest" - For stacked graphs, the highest single data point based on the sum of all series.
|
38
|
-
For unstacked graphs, the highest single data point of any series.
|
39
|
-
|
40
|
-
Passing Data
|
41
|
-
------------
|
42
|
-
|
43
|
-
Data can be provided in a number of formats. Data can be passed as a series of points:
|
44
|
-
|
45
|
-
points = [{x:1, y: 4}, {x:2, y:27}, {x:3, y:6}]
|
46
|
-
send_event('convergence', points: points)
|
47
|
-
|
48
|
-
Note that the `x` values are interpreted as unix timestamps. Data can also be passed as full-on
|
49
|
-
Rickshaw-style series:
|
50
|
-
|
51
|
-
series = [
|
52
|
-
{
|
53
|
-
name: "Convergence",
|
54
|
-
data: [{x:1, y: 4}, {x:2, y:27}, {x:3, y:6}]
|
55
|
-
},
|
56
|
-
{
|
57
|
-
name: "Divergence",
|
58
|
-
data: [{x:1, y: 5}, {x:2, y:2}, {x:3, y:9}]
|
59
|
-
}
|
60
|
-
]
|
61
|
-
send_event('convergence', series: series)
|
62
|
-
|
63
|
-
You can even provide colors and strokes here, which will override the values defined in the HTML.
|
64
|
-
Or data can be passed as Graphite-style data:
|
65
|
-
|
66
|
-
graphite = [
|
67
|
-
{
|
68
|
-
target: "stats_counts.http.ok",
|
69
|
-
datapoints: [[10, 1378449600], [40, 1378452000], [53, 1378454400], [63, 1378456800], [27, 1378459200]]
|
70
|
-
},
|
71
|
-
{
|
72
|
-
target: "stats_counts.http.err",
|
73
|
-
datapoints: [[0, 1378449600], [4, 1378452000], [nil, 1378454400], [3, 1378456800], [0, 1378459200]]
|
74
|
-
}
|
75
|
-
]
|
76
|
-
send_event('http', series: graphite)
|
77
|
-
|
78
|
-
You can even send data as JSON strings, straight from Graphite:
|
79
|
-
|
80
|
-
require "rest-client"
|
81
|
-
SCHEDULER.every '10s', :first_in => 0 do
|
82
|
-
target = "aliasSub(summarize(stats_counts.http.*%2C%2720min%27)%2C%27%5E.*http.(%5Cw*).*%27%2C%27%5C1%27)"
|
83
|
-
url = "http://graphteserver.local:8000/render?format=json&target=#{target}&from=today"
|
84
|
-
graphite_json_data = RestClient.get url
|
85
|
-
send_event 'http_counts', { series: graphite_json_data }
|
86
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
Sidekiq Widget
|
2
|
-
===============
|
3
|
-
|
4
|
-
Sidekiq widget and documentation is intially developed by [pallan](https://github.com/pallan) with some improvements.
|
5
|
-
|
6
|
-

|
7
|
-
|
8
|
-
|
9
|
-
## Usage
|
10
|
-
|
11
|
-
Add the widget HTML to your dashboard
|
12
|
-
```html
|
13
|
-
<li data-row="2" data-col="4" data-sizex="2" data-sizey="2">
|
14
|
-
<div data-id="sidekiq" data-view="Sidekiq" data-title="Sidekiq" style=""></div>
|
15
|
-
</li>
|
16
|
-
```
|
17
|
-
|
18
|
-
## Job setup
|
19
|
-
|
20
|
-
Create a `jobs/sidekiq.rb` in your dashing project.
|
21
|
-
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
|
25
|
-
# Require a built-in job
|
26
|
-
require 'dashing-contrib/jobs/sidekiq'
|
27
|
-
|
28
|
-
# Configure the job and setup Sidekiq connection
|
29
|
-
# 'event' is your dashing event name
|
30
|
-
|
31
|
-
DashingContrib::Jobs::Sidekiq.run every: '10s', event: 'sidekiq-metric-name' do
|
32
|
-
Sidekiq.configure_client do |config|
|
33
|
-
config.redis = { url: 'redis://localhost.com:6379', namespace: 'sidekiq:namespace' }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
```
|
Binary file
|