sensu-plugins-prometheus-checks 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15cd7d76255a3a2adf5cb172f8b26acb03e9a2c1
4
+ data.tar.gz: 5a578d3762002f51ff38b77ece996702cf8f1ef7
5
+ SHA512:
6
+ metadata.gz: 1c90a943322b568fe5bd8d6bd328997a1bfda04b809cbf1386d6bd9b4fd7caf93874bb6881371a17aee9c924bd882ab8dc37aca7ee6ec8ef2e0f387127377a2d
7
+ data.tar.gz: 1d6093efe57459be4c41dadb7fad79de289060f7021a92bf186e793951320dd3b5d40aae4500253afd0c56db063ba64bca15fc650161483b4947fcbc04281376
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --backtrace
2
+ --format documentation
3
+ --color
@@ -0,0 +1,16 @@
1
+ Metrics:
2
+ Enabled: false
3
+ AllCops:
4
+ Exclude:
5
+ - 'test.rb'
6
+ - '*.gemspec'
7
+ - 'Gemfile'
8
+ - 'Rakefile'
9
+ - 'vendor/**/*'
10
+
11
+ Style/GlobalVars:
12
+ Exclude:
13
+ - 'spec/**/*.rb'
14
+
15
+ Style/FrozenStringLiteralComment:
16
+ Enabled: false
@@ -0,0 +1 @@
1
+ 2.3.3
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ SimpleCov.minimum_coverage 100
4
+
5
+ SimpleCov.start do
6
+ add_filter '/spec/'
7
+ add_group 'lib', 'lib'
8
+ end
@@ -0,0 +1,16 @@
1
+ sudo: required
2
+
3
+ language: ruby
4
+
5
+ services:
6
+ - docker
7
+
8
+ script:
9
+ - /bin/bash ./test.sh
10
+
11
+ deploy:
12
+ provider: rubygems
13
+ api_key:
14
+ secure: jcfJuW8IX7qBLIq2wyeXYvq3n4swwGUfs/Gk2IRkmo9AwbbTaNmzbNJgedEueKdNWbaMoW+cVPKWGuY2X7pIETQBsBm2TIJb4s/Y4hv/zGR8GyyHTVZsmX1BrW7tFWTpR16VZZdtql9T21eoTGs302QieE5b+k/iFfvXR6maaGUtLd32YA6QKGJ6WoTIVqhwkdBzGWgseMI6g31JrHQjprHw3mJq4CoDZhwNDCF1+IFtdjEvMf5fuGqcs+duXjjJh1MYU5/dM/WpmT1zsPXCJGp2R59+hI0+4SF3c04o4xM4wIDhrp3q8K409Wy5rQHN+b9kV21sGnMJ1TFmZkarNhTAFxkd7XCXkqUyiOai3d8MZUBxrr0kM+GN0CbBhcc4IRB1+w4b16Hs1HffcVyBCsfsnNtC96TFSMddrQNWm6/UapKe5udcemPz2Kqcj+JawOVQ0cZDW0KtOOeEF13FQEg+uXmAUV6eP6T2oGTge5fY/3aFZp2FUCqnKRVBMGWFuP4LUfdE9EUmciO7PsyQaARJByV9niHUMws62TxY1IvuI2OQFDV+uGKPahWUSvvFkVgttcJDle1t3Qn+FsLEs5ZCXlUQQ0QK/CpZlcpRMZ9WuSNyY3RlaxjemA/w0XjUNneihYaZDISFz/VVpHqZYA15dD3QJuuw39Dvs0Nt7OQ=
15
+ on:
16
+ tags: true
@@ -0,0 +1,9 @@
1
+ FROM ruby:2.3-alpine
2
+
3
+ RUN apk update && apk add git g++ make
4
+
5
+ RUN mkdir /app
6
+ COPY . /app
7
+ WORKDIR /app
8
+
9
+ RUN bundle config --global frozen 1 && bundle install --no-deployment
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Schuberg Philis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,353 @@
1
+ # Sensu Kubernetes Prometheus Plugin
2
+
3
+ [![build status](https://api.travis-ci.org/schubergphilis/sensu-plugins-prometheus-checks.svg?branch=master)](https://travis-ci.org/schubergphilis/sensu-plugins-prometheus-checks)
4
+ [![codecov.io](https://codecov.io/github/schubergphilis/sensu-plugins-prometheus-checks/coverage.svg?branch=master)](https://codecov.io/gh/schubergphilis/sensu-plugins-prometheus-checks)
5
+ [![gem version](https://badge.fury.io/rb/sensu-plugins-prometheus-checks.svg)](http://badge.fury.io/rb/sensu-plugins-prometheus-checks)
6
+
7
+ ## Description
8
+ Sensu plugin designed to query prometheus data output from node-exporter
9
+
10
+ ## Usage
11
+ ```
12
+ check_prometheus.rb /path/to/config.yml
13
+
14
+ # Debug mode to output all json and blacklisted checks
15
+ PROM_DEBUG=true check_prometheus.rb /path/to/config.yml
16
+ ```
17
+
18
+ ## Development and testing
19
+
20
+ Dependencies: docker, docker-compose
21
+
22
+ To spinup a development stack and run the integration tests
23
+ ```
24
+ ruby test.rb
25
+ ```
26
+
27
+ Afterwards you can just run `rspec` to run the tests
28
+
29
+ To run the dockerized version (that gitlab-ci uses)
30
+ ```
31
+ bash test.sh
32
+ ```
33
+
34
+ ### Environment variables
35
+
36
+ <table>
37
+ <tr>
38
+ <th>Name</th>
39
+ <th>Example</th>
40
+ <th>Default</th>
41
+ <th>Description</th>
42
+ </tr>
43
+ <tr>
44
+ <td>PROM_DEBUG</td>
45
+ <td>true</td>
46
+ <td>false</td>
47
+ <td>Debug output instead of sending checks to sensu</td>
48
+ </tr>
49
+ <tr>
50
+ <td>PROMETHEUS_ENDPOINT</td>
51
+ <td>hostname:9090</td>
52
+ <td>localhost:9090</td>
53
+ <td>Connection string in the format address:port</td>
54
+ </tr>
55
+ <tr>
56
+ <td>SENSU_SOCKET_ADDRESS</td>
57
+ <td>hostname</td>
58
+ <td>localhost</td>
59
+ <td>Address used to connect to the sensu socket</td>
60
+ </tr>
61
+ <tr>
62
+ <td>SENSU_SOCKET_PORT</td>
63
+ <td>1234</td>
64
+ <td>3030</td>
65
+ <td>Port used to connect to the sensu socket</td>
66
+ </tr>
67
+ </table>
68
+
69
+
70
+ ### Config.yml
71
+ Check configuration is defined in the `config.yml` file under the key `checks`, and checks based on custom Prometheus queries are under `custom`. Example:
72
+
73
+ ``` yaml
74
+ config:
75
+ reported_by: sbppapik8s
76
+ occurrences: 3
77
+ domain: example.com
78
+ whitelist: sbppapik8s.*
79
+ use_default_source: false
80
+ checks:
81
+ - service:
82
+ name: kube-controller-manager.service
83
+ - check: load_per_cluster
84
+ host: sbppapik8s
85
+ cfg:
86
+ cluster: prometheus
87
+ warn: 1.0
88
+ crit: 2.0
89
+ source: sbppapik8s
90
+ custom:
91
+ - name: heartbeat
92
+ query: up
93
+ check:
94
+ type: equals
95
+ value: 1
96
+ msg:
97
+ 0: 'OK: Endpoint is alive and kicking'
98
+ 2: 'CRIT: Endpoints not reachable!'
99
+ ```
100
+
101
+ ## Checks
102
+
103
+ <table>
104
+ <tr>
105
+ <th>Name</th>
106
+ <th>Description</th>
107
+ </tr>
108
+ <tr>
109
+ <td>service</td>
110
+ <td>Checks if a systemd service is active</td>
111
+ </tr>
112
+ <tr>
113
+ <td>memory</td>
114
+ <td>Checks memory usage as a percentage</td>
115
+ </tr>
116
+ <tr>
117
+ <td>load_per_cpu</td>
118
+ <td>Checks cpu load divided by cpus</td>
119
+ </tr>
120
+ <tr>
121
+ <td>load_per_cluster</td>
122
+ <td>Checks cpu load of entire cluster divided by total cpus</td>
123
+ </tr>
124
+ <tr>
125
+ <td>load_per_cluster_minus_n</td>
126
+ <td>Checks cpu load of entire cluster divided by total cpus minus n failures</td>
127
+ </tr>
128
+ <tr>
129
+ <td>inode</td>
130
+ <td>Checks inode usage as a percentage per mountpoint</td>
131
+ </tr>
132
+ <tr>
133
+ <td>disk</td>
134
+ <td>Checks filesytem usage as a percentage per mountpoint</td>
135
+ </tr>
136
+ <tr>
137
+ <td>disk_all</td>
138
+ <td>Checks filesystem and inode usage of all mountpoints</td>
139
+ </tr>
140
+ <tr>
141
+ <td>predict_disk_all</td>
142
+ <td>Predicts if any of the disks in prometheus will be full in x days</td>
143
+ </tr>
144
+ </table>
145
+
146
+ ## Custom
147
+
148
+ <table>
149
+ <tr>
150
+ <th>Name</th>
151
+ <th>Example</th>
152
+ <th>Description</th>
153
+ </tr>
154
+ <tr>
155
+ <td>name</td>
156
+ <td>heartbeat</td>
157
+ <td>Custom check's name</td>
158
+ </tr>
159
+ <tr>
160
+ <td>query</td>
161
+ <td>up</td>
162
+ <td>Prometheus query</td>
163
+ </tr>
164
+ <tr>
165
+ <td>check.type</td>
166
+ <td>(equals|below|above)</td>
167
+ <td>Type of evaluation applied against value. Avilable: `equals`, `below` and `above`</td>
168
+ </tr>
169
+ <tr>
170
+ <td>check.value</td>
171
+ <td>1</td>
172
+ <td>Value to be compared against query results, using `check.type` evaluation</td>
173
+ </tr>
174
+ <tr>
175
+ <td>cfg.warn</td>
176
+ <td>33.00</td>
177
+ <td>Warning threshold level</td>
178
+ </tr>
179
+ <tr>
180
+ <td>cfg.crit</td>
181
+ <td>37.00</td>
182
+ <td>Critical threshold level.</td>
183
+ </tr>
184
+ <tr>
185
+ <td>msg.0</td>
186
+ <td>OK: heartbeat is up</td>
187
+ <td>Message to be used when `value` evaluation is sucessful.</td>
188
+ </tr>
189
+ <tr>
190
+ <td>msg.2</td>
191
+ <td>CRITICAL: heartbeat is down</td>
192
+ <td>Message to be used when not sucessful.</td>
193
+ </tr>
194
+ </table>
195
+
196
+ ## Global Configuration Options
197
+ <table>
198
+ <tr>
199
+ <th>Name</th>
200
+ <th>Example</th>
201
+ <th>Description</th>
202
+ </tr>
203
+ <tr>
204
+ <td>reported_by</td>
205
+ <td>sbppapik8s</td>
206
+ <td>hostname that shows up in sensu reported_by field</td>
207
+ </tr>
208
+ <tr>
209
+ <td>occurrences</td>
210
+ <td>3</td>
211
+ <td>amount of failures before sensu will send an alert</td>
212
+ </tr>
213
+ <tr>
214
+ <td>whitelist</td>
215
+ <td>sbppapik8s.*</td>
216
+ <td>regex used as a safety whitelist to make sure the source names are correct</td>
217
+ </tr>
218
+ <tr>
219
+ <td>use_default_source</td>
220
+ <td>false</td>
221
+ <td>When `true` the source of the events will be Sensu-Client's</td>
222
+ </tr>
223
+ </table>
224
+
225
+ ## Check Configuration Options
226
+ <table>
227
+ <tr>
228
+ <th>Name</th>
229
+ <th>Config</th>
230
+ <th>Example</th>
231
+ </tr>
232
+ <tr>
233
+ <td>service</td>
234
+ <td>
235
+ name: servicename<br>
236
+ state: active|deactivating|failed|inactive (default:active)<br>
237
+ state_required: 0|1 (default:1)
238
+ </td>
239
+ <td>name: test-service.service</td>
240
+ </tr>
241
+ <tr>
242
+ <td>memory</td>
243
+ <td>
244
+ warn: warning percentage<br>
245
+ crit: critical percentage
246
+ </td>
247
+ <td>
248
+ warn: 90 <br>
249
+ crit: 95
250
+ </td>
251
+ </tr>
252
+ <tr>
253
+ <td>load_per_cpu</td>
254
+ <td>
255
+ warn: warning percentage <br>
256
+ crit: critical percentage
257
+ </td>
258
+ <td>
259
+ warn: 90 <br>
260
+ crit: 95
261
+ </td>
262
+ </tr>
263
+ <tr>
264
+ <td>load_per_cluster</td>
265
+ <td>
266
+ cluster: cluster name <br>
267
+ warn: warning percentage <br>
268
+ crit: critical percentage <br>
269
+ source: name that shows in sensu
270
+ </td>
271
+ <td>
272
+ cluster: nodes <br>
273
+ warn: 90 <br>
274
+ crit: 95 <br>
275
+ source: sbppapik8s
276
+ </td>
277
+ </tr>
278
+ <tr>
279
+ <td>load_per_cluster_minus_n</td>
280
+ <td>
281
+ cluster: cluster name <br>
282
+ minus_n: amount of member failures <br>
283
+ warn: warning percentage <br>
284
+ crit: critical percentage <br>
285
+ source: name that shows in sensu
286
+ </td>
287
+ <td>
288
+ cluster: nodes <br>
289
+ minus_n: 1 <br>
290
+ warn: 90 <br>
291
+ crit: 95 <br>
292
+ source: sbppapik8s
293
+ </td>
294
+ </tr>
295
+ <tr>
296
+ <td>inode</td>
297
+ <td>
298
+ mount: mountpoint <br>
299
+ name: human readable name <br>
300
+ warn: warning percentage <br>
301
+ crit: critical percentage
302
+ </td>
303
+ <td>
304
+ mount: /var/lib/docker <br>
305
+ name: docker <br>
306
+ warn: 90 <br>
307
+ crit: 95
308
+ </td>
309
+ </tr>
310
+ <tr>
311
+ <td>disk</td>
312
+ <td>
313
+ mount: mountpoint <br>
314
+ name: human readable name <br>
315
+ warn: warning percentage <br>
316
+ crit: critical percentage
317
+ </td>
318
+ <td>
319
+ mount: /var/lib/docker <br>
320
+ name: docker <br>
321
+ warn: 90 <br>
322
+ crit: 95
323
+ </td>
324
+ </tr>
325
+ <tr>
326
+ <td>disk_all</td>
327
+ <td>
328
+ ignore_fs: regex of filesystems <br>
329
+ warn: warning percentage <br>
330
+ crit: critical percentage
331
+ </td>
332
+ <td>
333
+ ignore_fs: tmpfs <br>
334
+ warn: 90 <br>
335
+ crit: 95
336
+ </td>
337
+ </tr>
338
+ <tr>
339
+ <td>predict_disk_all</td>
340
+ <td>
341
+ range_vector: Prometheus range vector used for sample size of prediction
342
+ filter: prometheus filter to include/exclude disks<br>
343
+ days: prediction days
344
+ source: sensu name
345
+ </td>
346
+ <td>
347
+ range_vector: 24h <br>
348
+ filter: {mountpoint="/"}<br>
349
+ days: 14
350
+ source: sbppapik8s
351
+ </td>
352
+ </tr>
353
+ </table>