dashing-contrib 0.0.4 → 0.0.5
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/.rspec +2 -0
- data/.travis.yml +6 -0
- data/README.md +23 -17
- data/dashing-contrib.gemspec +4 -0
- data/lib/dashing-contrib.rb +2 -0
- data/lib/dashing-contrib/assets/stylesheets/font-awesome/scss/_variables.scss +1 -2
- data/lib/dashing-contrib/assets/widgets.scss +1 -1
- data/lib/dashing-contrib/assets/widgets/kue_status/README.md +41 -0
- data/lib/dashing-contrib/assets/widgets/kue_status/kue_status.coffee +1 -0
- data/lib/dashing-contrib/assets/widgets/kue_status/kue_status.html +10 -0
- data/lib/dashing-contrib/assets/widgets/kue_status/kue_status.scss +18 -0
- data/lib/dashing-contrib/assets/widgets/kue_status/preview.png +0 -0
- data/lib/dashing-contrib/assets/widgets/pingdom_uptime/README.md +68 -0
- data/lib/dashing-contrib/assets/widgets/pingdom_uptime/pingdom_uptime.scss +1 -1
- data/lib/dashing-contrib/assets/widgets/pingdom_uptime/preview.png +0 -0
- data/lib/dashing-contrib/assets/widgets/rickshawgraph/README.md +86 -0
- data/lib/dashing-contrib/assets/widgets/rickshawgraph/rickshawgraph.scss +3 -2
- data/lib/dashing-contrib/assets/widgets/sidekiq/README.md +42 -0
- data/lib/dashing-contrib/assets/widgets/sidekiq/preview.png +0 -0
- data/lib/dashing-contrib/assets/widgets/sidekiq/sidekiq.scss +1 -0
- data/lib/dashing-contrib/bottles/kue.rb +1 -0
- data/lib/dashing-contrib/bottles/kue/client.rb +46 -0
- data/lib/dashing-contrib/version.rb +1 -1
- data/spec/bottles/kue/client_spec.rb +24 -0
- data/spec/spec_helper.rb +7 -0
- metadata +63 -8
- data/lib/dashing-contrib/assets/stylesheets/font-awesome/fonts/FontAwesome.otf +0 -0
- data/lib/dashing-contrib/assets/stylesheets/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- data/lib/dashing-contrib/assets/stylesheets/font-awesome/fonts/fontawesome-webfont.svg +0 -504
- data/lib/dashing-contrib/assets/stylesheets/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/dashing-contrib/assets/stylesheets/font-awesome/fonts/fontawesome-webfont.woff +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eab4a59c857c67b6d79aefc2502baec1ab80ca73
|
4
|
+
data.tar.gz: ee8b277d23c16dcddd73f4ddd6106b50b519aa0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 509bfdaa5f9f6b4d57ab77c98709fd5a74c8cb20662f3a001aea8cc5f58185191d818128e48539920ee39d1e222310d26e0f0d8bd1566f9b711bca31a8be402f
|
7
|
+
data.tar.gz: 4b5f89720b9a04f3423b1054a2219515baf748e59ac48d0ae0f83e9fd8b2ccbcd239d45c1e054f09062bfec3b960c340bdbdb408e6a90dd5eb74ebb584bda39b
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,16 +1,21 @@
|
|
1
|
-
# dashing-contrib
|
1
|
+
# dashing-contrib
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/QubitProducts/dashing-contrib)
|
4
|
+
|
5
|
+
|
6
|
+
This project is an extension to Shopify's Dashing. It aims to solve a couple of problems:
|
4
7
|
|
5
8
|
* Extend the Dashing's widgets functionality in a healthy pattern
|
6
9
|
* Embrace sharing, reusing, testing common jobs data manipulation functionality
|
7
10
|
* A common way to load external configuration via dotenv
|
8
11
|
* Central place keeping track of extension updates, commits and contributions from multiple sources
|
9
12
|
|
13
|
+
Read each individual widget documentation to use dashing-contrib built-in widgets in this project after the installation steps.
|
14
|
+
|
10
15
|
## Installation
|
11
16
|
Add this line to your Dashing's dashboard Gemfile:
|
12
17
|
|
13
|
-
gem 'dashing-contrib', '~> 0.0.
|
18
|
+
gem 'dashing-contrib', '~> 0.0.4'
|
14
19
|
|
15
20
|
And then execute:
|
16
21
|
|
@@ -31,9 +36,9 @@ Add these lines to `assets/stylesheets/application.scss`
|
|
31
36
|
|
32
37
|
//=require dashing-contrib/assets/widgets
|
33
38
|
|
34
|
-
## Job
|
39
|
+
## Job Parameters
|
35
40
|
|
36
|
-
|
41
|
+
Shared job parameters are managed by `dotenv` gem. Add a `.env` file in your dashing project root. dashing-contrib will load your configuration from `.env` file automatically. An example `.env` file:
|
37
42
|
|
38
43
|
````
|
39
44
|
NAGIOS_ENDPOINT: http://example.com/nagios3/cgi-bin
|
@@ -45,31 +50,32 @@ PINGDOM_PASSWORD: pong
|
|
45
50
|
PINGDOM_API_KEY: pingpongpingpong
|
46
51
|
````
|
47
52
|
|
48
|
-
These values can be accessed in jobs `ENV[NAGIOS_ENDPOINT]`
|
53
|
+
These values can be accessed in jobs `ENV['NAGIOS_ENDPOINT']`
|
49
54
|
|
50
|
-
##
|
55
|
+
## Widgets Doc
|
51
56
|
|
52
|
-
* [Rickshawgraph](https://
|
53
|
-
* [Sidekiq](https://
|
57
|
+
* [Rickshawgraph](https://github.com/QubitProducts/dashing-contrib/tree/master/lib/dashing-contrib/assets/widgets/rickshawgraph) made by [jwalton](https://github.com/jwalton)
|
58
|
+
* [Sidekiq](https://github.com/QubitProducts/dashing-contrib/tree/master/lib/dashing-contrib/assets/widgets/sidekiq) made by [pallan](https://github.com/pallan)
|
59
|
+
* [Pingdom Uptime](https://github.com/QubitProducts/dashing-contrib/tree/master/lib/dashing-contrib/assets/widgets/pingdom_uptime) inspired by [Edools](https://github.com/Edools/dashing-pingdom)
|
60
|
+
* [Kue Status](https://github.com/QubitProducts/dashing-contrib/tree/master/lib/dashing-contrib/assets/widgets/kue_status)
|
54
61
|
|
55
|
-
##
|
62
|
+
## Job Helpers Doc
|
56
63
|
|
57
64
|
TODO:
|
58
65
|
|
59
66
|
## How to contribute
|
60
67
|
|
61
|
-
There are a couple of ways to contribute. Brining those widgets scattered in github, in multiple format into this repository. They usually falling into the following
|
68
|
+
There are a couple of ways to contribute. Brining those widgets scattered in github, in multiple format into this repository. They usually falling into the following categories:
|
62
69
|
|
63
|
-
|
70
|
+
#### Widgets
|
64
71
|
|
65
|
-
Common widgets should be generic solution to a common requirements. e.g. line graph,better clock with common functionalities. Documentation should be written as a
|
72
|
+
Common widgets should be generic solution to a common requirements. e.g. line graph, better clock with common functionalities. Documentation should be written as a README.md file under widget's own directory, include a preview.png file in the widget folder.
|
66
73
|
|
67
|
-
|
74
|
+
#### Jobs utils
|
68
75
|
|
69
76
|
Common Job data processing for graphing purpose.
|
70
77
|
|
78
|
+
#### Fix and add test
|
71
79
|
|
72
|
-
|
80
|
+
Test data processing Ruby modules.
|
73
81
|
|
74
|
-
* [jwalton](https://gist.github.com/jwalton)
|
75
|
-
* [pallan](https://gist.github.com/pallan)
|
data/dashing-contrib.gemspec
CHANGED
@@ -24,5 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'multi_json', '~> 1.10.1'
|
25
25
|
spec.add_dependency 'time_diff', '~> 0.3.0'
|
26
26
|
spec.add_dependency 'sidekiq', '~> 3.0.0'
|
27
|
+
spec.add_dependency 'activesupport', '~> 4.1.1'
|
28
|
+
spec.add_dependency 'sinatra'
|
29
|
+
|
27
30
|
spec.add_development_dependency 'rake'
|
31
|
+
spec.add_development_dependency 'rspec'
|
28
32
|
end
|
data/lib/dashing-contrib.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_support/all'
|
1
2
|
require 'dashing-contrib/version'
|
2
3
|
require 'dashing-contrib/configuration'
|
3
4
|
require 'dashing-contrib/history'
|
@@ -5,6 +6,7 @@ require 'dashing-contrib/routes'
|
|
5
6
|
require 'dashing-contrib/bottles/time'
|
6
7
|
require 'dotenv'
|
7
8
|
|
9
|
+
|
8
10
|
module DashingContrib
|
9
11
|
class << self
|
10
12
|
attr_writer :configuration
|
@@ -1,8 +1,7 @@
|
|
1
1
|
// Variables
|
2
2
|
// --------------------------
|
3
3
|
|
4
|
-
$fa-font-path: "
|
5
|
-
//$fa-font-path: "//netdna.bootstrapcdn.com/font-awesome/4.1.0/fonts" !default; // for referencing Bootstrap CDN font files directly
|
4
|
+
$fa-font-path: "//netdna.bootstrapcdn.com/font-awesome/4.1.0/fonts" !default; // for referencing Bootstrap CDN font files directly
|
6
5
|
$fa-css-prefix: fa !default;
|
7
6
|
$fa-version: "4.1.0" !default;
|
8
7
|
$fa-border-color: #eee !default;
|
@@ -0,0 +1,41 @@
|
|
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
|
+
````
|
@@ -0,0 +1 @@
|
|
1
|
+
class Dashing.KueStatus extends Dashing.Widget
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<h1 class="title" data-bind="title"></h1>
|
2
|
+
|
3
|
+
<ul>
|
4
|
+
<li data-foreach-metric="metrics">
|
5
|
+
<span class="label" data-bind="metric.label"></span>
|
6
|
+
<span class="value" data-bind="metric.value"></span>
|
7
|
+
</li>
|
8
|
+
</ul>
|
9
|
+
|
10
|
+
<p class="updated-at" data-bind="updatedAtMessage"></p>
|
Binary file
|
@@ -0,0 +1,68 @@
|
|
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
|
@@ -0,0 +1,86 @@
|
|
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
|
@@ -70,11 +70,11 @@ $tick-color: rgba(0, 0, 0, 0.4);
|
|
70
70
|
.rickshaw_legend {
|
71
71
|
position: absolute;
|
72
72
|
left: 0px;
|
73
|
-
bottom:
|
73
|
+
bottom: -3px;
|
74
74
|
white-space: nowrap;
|
75
75
|
overflow-x: hidden;
|
76
76
|
font-size: 15px;
|
77
|
-
height:
|
77
|
+
height: 30px;
|
78
78
|
|
79
79
|
ul {
|
80
80
|
margin: 0;
|
@@ -97,6 +97,7 @@ $tick-color: rgba(0, 0, 0, 0.4);
|
|
97
97
|
.label {
|
98
98
|
display: inline-block;
|
99
99
|
margin-left: 5px;
|
100
|
+
font-size: 12px;
|
100
101
|
}
|
101
102
|
}
|
102
103
|
|
@@ -0,0 +1,42 @@
|
|
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
|
+
## Settings
|
19
|
+
|
20
|
+
In `/jobs/sidekiq.rb` you need to configure the connection to your Redis server that backs Sidekiq.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require 'sidekiq/api'
|
24
|
+
|
25
|
+
redis_uri = "redis://:#{YOUR_REDIS_PASSWORD}@#{YOUR_REDIS_HOST}:#{YOUR_REDIS_PORT}"
|
26
|
+
|
27
|
+
Sidekiq.configure_client do |config|
|
28
|
+
config.redis = { url: redis_uri, namespace: 'myapp:namespace' }
|
29
|
+
end
|
30
|
+
|
31
|
+
SCHEDULER.every '10s' do
|
32
|
+
stats = Sidekiq::Stats.new
|
33
|
+
metrics = [
|
34
|
+
{label: 'Processed', value: stats.processed },
|
35
|
+
{label: 'Failed', value: stats.failed },
|
36
|
+
{label: 'Retries', value: stats.retry_size },
|
37
|
+
{label: 'Dead', value: stats.dead_size },
|
38
|
+
{label: 'Enqueued', value: stats.enqueued }
|
39
|
+
]
|
40
|
+
send_event('sidekiq', { metrics: metrics } )
|
41
|
+
end
|
42
|
+
```
|