sensu-plugins-influxdb-metrics-checker 0.5.0 → 0.6.0
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/CHANGELOG.md +7 -1
- data/README.md +3 -2
- data/bin/check-influxdb-metrics.rb +26 -12
- data/bin/time-management.rb +25 -0
- data/lib/sensu-plugins-influxdb-metrics-checker/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2faf768f52259477f77f590df56d99c8e99a9c4
|
4
|
+
data.tar.gz: 33c7bb5da5466dce940086afc2944242ff6b9815
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 535f53f71f815f6cfd18e413070b735fd0e80284f0228b0d8d659844f0fa3560a7d740011664b64d285b53c9117644ad6922abba7d8ac35870c6cce032a05d30
|
7
|
+
data.tar.gz: e0d5ef15e1f95cb094d2137a0b3da60cb888afa7722f84cdc358d78b4e2d525dbfb219c2695022d1c2c7c3d4ab280105406eca9e7a7adfcaced845810e7aa3b5
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
3
3
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
|
+
# [0.6.0] - 2017-02-01
|
7
|
+
- eleventh release
|
8
|
+
Using absolute time in `epoch seconds` instead of relative time `now`
|
9
|
+
|
6
10
|
# [0.5.0] - 2017-01-24
|
7
11
|
- tenth release
|
8
12
|
Changing from Percentage of Difference to Percentage of Change.
|
@@ -61,4 +65,6 @@ Leaving 5 minutes to the data to consolidate.
|
|
61
65
|
[0.3.4]: https://github.com/pliyosenpai/sensu-plugins-influxdb-metrics-checker/0.3.4...0.4.0
|
62
66
|
[0.4.0]: https://github.com/pliyosenpai/sensu-plugins-influxdb-metrics-checker/0.4.0...0.4.4
|
63
67
|
[0.4.4]: https://github.com/pliyosenpai/sensu-plugins-influxdb-metrics-checker/0.4.4...0.4.8
|
64
|
-
[0.4.8]: https://github.com/pliyosenpai/sensu-plugins-influxdb-metrics-checker/0.4.8...
|
68
|
+
[0.4.8]: https://github.com/pliyosenpai/sensu-plugins-influxdb-metrics-checker/0.4.8...0.5.0
|
69
|
+
[0.5.0]: https://github.com/pliyosenpai/sensu-plugins-influxdb-metrics-checker/0.5.0...0.6.0
|
70
|
+
[0.6.0]: https://github.com/pliyosenpai/sensu-plugins-influxdb-metrics-checker/0.6.0...HEAD
|
data/README.md
CHANGED
@@ -11,10 +11,11 @@ We chose to do it as a Sensu plugin because it comes with Handlers that will all
|
|
11
11
|
The result is that now we are able to experiment with our metrics and alerts, giving us a better understanding of whats going on in our systems.
|
12
12
|
|
13
13
|
## What it does
|
14
|
-
The script will compare the values of yesterday at this time minus
|
14
|
+
The script will compare the values of yesterday at this time minus period, with the values of today at this time minus period.
|
15
|
+
Being period a default value of 20 minutes.
|
15
16
|
It will calculate the percentage of difference and will act on that.
|
16
17
|
You will be able to set a threshold of warning and critical values where your program will act.
|
17
|
-
It will also leave it
|
18
|
+
It will also leave it 5 minutes to aggregate the data in influxdb, so we are more precise.
|
18
19
|
|
19
20
|
## Components
|
20
21
|
There is just one script that you can find at
|
@@ -9,6 +9,7 @@ require 'uri'
|
|
9
9
|
require 'json'
|
10
10
|
require 'base64'
|
11
11
|
require 'addressable/uri'
|
12
|
+
require './time-management'
|
12
13
|
|
13
14
|
class CheckInfluxDbMetrics < Sensu::Plugin::Check::CLI
|
14
15
|
option :host,
|
@@ -83,7 +84,7 @@ class CheckInfluxDbMetrics < Sensu::Plugin::Check::CLI
|
|
83
84
|
long: '--period=VALUE',
|
84
85
|
description: 'Filter by a given day period in minutes',
|
85
86
|
proc: proc { |l| l.to_i },
|
86
|
-
default:
|
87
|
+
default: 20
|
87
88
|
|
88
89
|
option :triangulate,
|
89
90
|
long: '--triangulate=VALUE',
|
@@ -99,15 +100,28 @@ class CheckInfluxDbMetrics < Sensu::Plugin::Check::CLI
|
|
99
100
|
default: 2
|
100
101
|
|
101
102
|
BASE_QUERY = 'SELECT sum("value") from '.freeze
|
102
|
-
|
103
|
-
|
103
|
+
TIME_MANAGER = TimeManagement.new
|
104
|
+
|
105
|
+
def today_start_period
|
106
|
+
TIME_MANAGER.period_epoch(Time.now, TIME_MANAGER.today_start_period)
|
107
|
+
end
|
108
|
+
|
109
|
+
def yesterday_start_period
|
110
|
+
TIME_MANAGER.period_epoch(Time.now, TIME_MANAGER.yesterday_start_period)
|
111
|
+
end
|
104
112
|
|
105
113
|
def yesterday_end_period
|
106
|
-
config[:period] +
|
114
|
+
decrease = config[:period] + TIME_MANAGER.yesterday_start_period
|
115
|
+
TIME_MANAGER.period_epoch(Time.now, decrease)
|
107
116
|
end
|
108
117
|
|
109
118
|
def today_end_period
|
110
|
-
config[:period] +
|
119
|
+
decrease = config[:period] + TIME_MANAGER.today_start_period
|
120
|
+
TIME_MANAGER.period_epoch(Time.now, decrease)
|
121
|
+
end
|
122
|
+
|
123
|
+
def epoch_time(time)
|
124
|
+
time.to_i.to_s
|
111
125
|
end
|
112
126
|
|
113
127
|
def base_query_with_metricname(metric)
|
@@ -135,8 +149,8 @@ class CheckInfluxDbMetrics < Sensu::Plugin::Check::CLI
|
|
135
149
|
config[:applyfilterbothqueries].nil? ? '' : " AND \"#{config[:tag]}\" =~ /#{config[:filter]}/"
|
136
150
|
end
|
137
151
|
|
138
|
-
def
|
139
|
-
query = base_query_with_metricname(metric) + ' WHERE time >
|
152
|
+
def query_for_a_period_timespan(metric, start_period, end_period, istriangulated)
|
153
|
+
query = base_query_with_metricname(metric) + ' WHERE time > ' + end_period.to_s + 's AND time < ' + start_period.to_s + 's'
|
140
154
|
query + add_filter_when_needed(istriangulated)
|
141
155
|
end
|
142
156
|
|
@@ -149,7 +163,7 @@ class CheckInfluxDbMetrics < Sensu::Plugin::Check::CLI
|
|
149
163
|
end
|
150
164
|
|
151
165
|
def query_encoded_for_a_period(metric, start_period, end_period, istriangulated)
|
152
|
-
query =
|
166
|
+
query = query_for_a_period_timespan(metric, start_period, end_period, istriangulated)
|
153
167
|
encode_parameters(query)
|
154
168
|
end
|
155
169
|
|
@@ -172,7 +186,7 @@ class CheckInfluxDbMetrics < Sensu::Plugin::Check::CLI
|
|
172
186
|
end
|
173
187
|
|
174
188
|
def today_metrics
|
175
|
-
today_info = metrics(config[:metric],
|
189
|
+
today_info = metrics(config[:metric], today_start_period, today_end_period, false)
|
176
190
|
@today_metric_count = validate_metrics_and_count(today_info)
|
177
191
|
if @today_metric_count > 0
|
178
192
|
series = read_series_from_metrics(today_info)
|
@@ -184,7 +198,7 @@ class CheckInfluxDbMetrics < Sensu::Plugin::Check::CLI
|
|
184
198
|
end
|
185
199
|
|
186
200
|
def yesterday_metrics
|
187
|
-
yesterday_info = metrics(config[:metric],
|
201
|
+
yesterday_info = metrics(config[:metric], yesterday_start_period, yesterday_end_period, false)
|
188
202
|
@yesterday_metric_count = validate_metrics_and_count(yesterday_info)
|
189
203
|
if @yesterday_metric_count > 0
|
190
204
|
series = read_series_from_metrics(yesterday_info)
|
@@ -196,7 +210,7 @@ class CheckInfluxDbMetrics < Sensu::Plugin::Check::CLI
|
|
196
210
|
end
|
197
211
|
|
198
212
|
def today_triangulated_metrics
|
199
|
-
today_triangulated_info = metrics(config[:triangulate],
|
213
|
+
today_triangulated_info = metrics(config[:triangulate], today_start_period, today_end_period, true)
|
200
214
|
@today_triangulated_metric_count = validate_metrics_and_count(today_triangulated_info)
|
201
215
|
if @today_triangulated_metric_count > 0
|
202
216
|
series = read_series_from_metrics(today_triangulated_info)
|
@@ -208,7 +222,7 @@ class CheckInfluxDbMetrics < Sensu::Plugin::Check::CLI
|
|
208
222
|
end
|
209
223
|
|
210
224
|
def yesterday_triangulated_metrics
|
211
|
-
yesterday_triangulated_info = metrics(config[:triangulate],
|
225
|
+
yesterday_triangulated_info = metrics(config[:triangulate], yesterday_start_period, yesterday_end_period, true)
|
212
226
|
@yesterday_triangulated_metric_count = validate_metrics_and_count(yesterday_triangulated_info)
|
213
227
|
if @yesterday_triangulated_metric_count > 0
|
214
228
|
series = read_series_from_metrics(yesterday_triangulated_info)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class TimeManagement
|
2
|
+
TODAY_START_PERIOD = 5
|
3
|
+
YESTERDAY_START_PERIOD = 1445 # starts counting 1445 minutes before now() [ yesterday - 5 minutes] to match with today_query_for_a_period start_period
|
4
|
+
|
5
|
+
def today_start_period
|
6
|
+
TODAY_START_PERIOD
|
7
|
+
end
|
8
|
+
|
9
|
+
def yesterday_start_period
|
10
|
+
YESTERDAY_START_PERIOD
|
11
|
+
end
|
12
|
+
|
13
|
+
def period_seconds(a_given_day_period)
|
14
|
+
a_given_day_period * 60
|
15
|
+
end
|
16
|
+
|
17
|
+
def period_epoch(time, a_given_period)
|
18
|
+
period = time - period_seconds(a_given_period)
|
19
|
+
epoch_time(period)
|
20
|
+
end
|
21
|
+
|
22
|
+
def epoch_time(time)
|
23
|
+
time.to_i.to_s
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-influxdb-metrics-checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juanjo Guerrero Cerezuela
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01
|
11
|
+
date: 2017-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -202,6 +202,7 @@ description: This plugin retrieves metrics and evaluate them. Aiming to track ou
|
|
202
202
|
email: "<pliyosan@gmail.com>"
|
203
203
|
executables:
|
204
204
|
- check-influxdb-metrics.rb
|
205
|
+
- time-management.rb
|
205
206
|
extensions: []
|
206
207
|
extra_rdoc_files: []
|
207
208
|
files:
|
@@ -209,6 +210,7 @@ files:
|
|
209
210
|
- LICENSE
|
210
211
|
- README.md
|
211
212
|
- bin/check-influxdb-metrics.rb
|
213
|
+
- bin/time-management.rb
|
212
214
|
- lib/sensu-plugins-influxdb-metrics-checker.rb
|
213
215
|
- lib/sensu-plugins-influxdb-metrics-checker/version.rb
|
214
216
|
homepage: https://github.com/pliyosenpai/sensu-plugins-influxdb-metrics-checker
|