sensu-plugin-app-insights 0.1.0 → 0.2.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 +3 -0
- data/README.md +50 -2
- data/bin/query-check.rb +27 -9
- data/lib/sensu-plugin-app-insights/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b287dcda6555ade196e110e9505b94268091f52
|
4
|
+
data.tar.gz: 0053bdd0babc7c3ac50a15a06490fe9ef2344439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d6b65a7bb821e0ce867601c201f6f4c417de1e47e994ac62837e2db37ecb3e6d87ecbfbefe86dc713926172ca53a01043393416f8721a54e2f3c34db1695cb4
|
7
|
+
data.tar.gz: 4e96eb6cb9444f51081d2c620a02e5e79b857e1aaa326de49f646428a6ad0435347c8f4b7607f448ba75936cc9ee4ab05434621c37042bc41333384eeccc0d89
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,2 +1,50 @@
|
|
1
|
-
|
2
|
-
sensu
|
1
|
+
[](https://travis-ci.org/ve-interactive/sensu-plugin-app-insights)
|
2
|
+
[](https://badge.fury.io/rb/sensu-plugin-app-insights)
|
3
|
+
|
4
|
+
# Sensu plugin for application insights
|
5
|
+
This is a pugin for application insights it add capabilities for sensu to use the application insights api in order to create alerts.
|
6
|
+
|
7
|
+
# Installation Instructions
|
8
|
+
## Gems
|
9
|
+
|
10
|
+
Installing via gem is the preferred method if one exists.
|
11
|
+
|
12
|
+
### Standard Installation
|
13
|
+
|
14
|
+
`gem install sensu-plugin-app-insights`
|
15
|
+
|
16
|
+
Note: If the gem has an alpha tag then you will need to use the –prerelease flag or the gem will not be found.
|
17
|
+
|
18
|
+
### Bundle
|
19
|
+
|
20
|
+
Add _sensu-plugin-app-insights_ to your Gemfile and run `bundle install` or `bundle update`
|
21
|
+
|
22
|
+
### Chef
|
23
|
+
|
24
|
+
#### Using the Sensu sensu_gem LWRP
|
25
|
+
```
|
26
|
+
sensu_gem 'sensu-plugin-app-insights' do
|
27
|
+
version '0.1.0'
|
28
|
+
end
|
29
|
+
```
|
30
|
+
#### Using the Chef package resource
|
31
|
+
```
|
32
|
+
gem_package 'sensu-plugin-app-insights' do
|
33
|
+
version '0.1.0'
|
34
|
+
end
|
35
|
+
```
|
36
|
+
### Puppet
|
37
|
+
|
38
|
+
#### Using the Puppet sensu_gem package provider
|
39
|
+
```
|
40
|
+
package { 'sensu-plugin-app-insights':
|
41
|
+
ensure => '0.1.0',
|
42
|
+
provider => sensu_gem,
|
43
|
+
}
|
44
|
+
```
|
45
|
+
### Ansible
|
46
|
+
|
47
|
+
```
|
48
|
+
- gem: name=sensu-plugin-app-insights version=0.1.0 state=present executable=/opt/sensu/embedded/bin/gem
|
49
|
+
```
|
50
|
+
|
data/bin/query-check.rb
CHANGED
@@ -58,12 +58,24 @@ class QueryCheck < Sensu::Plugin::Check::CLI
|
|
58
58
|
option :query,
|
59
59
|
short: '-q /file/with/query or https://fileUrl',
|
60
60
|
long: '--query /file/with/query or https://fileUrl',
|
61
|
+
description: 'Query can be expressed as a path to a file a url that will return the raw query or directly inline.',
|
61
62
|
required: true
|
62
|
-
option :resultColumn,
|
63
|
-
|
64
|
-
|
65
|
-
option :
|
66
|
-
|
63
|
+
option :resultColumn,
|
64
|
+
short: '-r COLUMN_NAME',
|
65
|
+
long: '--resultColumn COLUMN_NAME'
|
66
|
+
option :warningExpression,
|
67
|
+
short: '-w WARNING_EXPRESSION value > 20',
|
68
|
+
long: '--warning WARNING_EXPRESSION value > 20'
|
69
|
+
option :criticalExpression,
|
70
|
+
short: '-c CRITICAL_EXPRESSION value > 20',
|
71
|
+
long: '--critical CRITICAL_EXPRESSION value > 20'
|
72
|
+
option :message,
|
73
|
+
short: '-m MESSAGE',
|
74
|
+
long: '--message MESSAGE'
|
75
|
+
option :timeout,
|
76
|
+
short: '-t SECS',
|
77
|
+
proc: proc(&:to_i),
|
78
|
+
default: 60
|
67
79
|
|
68
80
|
def run
|
69
81
|
uri = URI.parse(config[:apiUrl])
|
@@ -116,7 +128,7 @@ class QueryCheck < Sensu::Plugin::Check::CLI
|
|
116
128
|
|
117
129
|
def get_query(query)
|
118
130
|
post_body = ''
|
119
|
-
if query =~ /\A#{URI
|
131
|
+
if query =~ /\A#{URI.regexp(%w(https http))}\z/
|
120
132
|
uri = URI.parse(query)
|
121
133
|
http_query = Net::HTTP.new(uri.host, uri.port)
|
122
134
|
if uri.scheme == 'https'
|
@@ -131,10 +143,12 @@ class QueryCheck < Sensu::Plugin::Check::CLI
|
|
131
143
|
critical "http code: #{res_query.code}: body: #{res_query.body}"
|
132
144
|
end
|
133
145
|
post_body = res_query.body
|
134
|
-
|
146
|
+
elsif File.exist?(query)
|
135
147
|
post_body = IO.readlines(query).join
|
148
|
+
else
|
149
|
+
post_body = query
|
136
150
|
end
|
137
|
-
|
151
|
+
URI.encode(post_body)
|
138
152
|
end
|
139
153
|
|
140
154
|
def validate_result(json)
|
@@ -146,8 +160,12 @@ class QueryCheck < Sensu::Plugin::Check::CLI
|
|
146
160
|
rows.each_with_index do |row, _index|
|
147
161
|
values = extract_value(row, columns)
|
148
162
|
value = row[column_index]
|
163
|
+
if values.nil? || value.nil?
|
164
|
+
critical 'unable to extract values'
|
165
|
+
end
|
166
|
+
|
149
167
|
if config[:warningExpression]
|
150
|
-
if instance_eval
|
168
|
+
if instance_eval config[:warningExpression]
|
151
169
|
if config[:message]
|
152
170
|
warning_message.push instance_eval config[:message]
|
153
171
|
else
|