sensu-plugins-azurerm 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +44 -0
- data/bin/check-azurerm-service-bus-subscription.rb +115 -0
- data/bin/check-azurerm-service-bus-topic-size.rb +135 -0
- data/bin/metric-azurerm-service-bus-subscription-message-count.rb +1 -1
- data/lib/sensu-plugins-azurerm/servicebus_usage.rb +11 -1
- data/lib/sensu-plugins-azurerm/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b82240f818c79805f33a399f39760129f92c93f
|
4
|
+
data.tar.gz: 639fdd79a0656839f48a7a550736cb1e6a7490f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c3ebe480735f0af56e5ef153d725f065e0ffc6173a8ad7f87857e74a1db06191be1a5e311bfa17a4df8ca065a262fb8a108460617b6aaff66bbe3a78fea0bec
|
7
|
+
data.tar.gz: 8a1a75a14423cb85d5722a81f27867be648b2c3f0897b0a510d5c47b0f0a0128700fb53fd736a10d0447e6aa569942c7d44d7722b2f34336fea4836431ce4e8b
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@ 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.0.5 - 2016-12-05
|
7
|
+
### Added
|
8
|
+
- Checks for
|
9
|
+
- ServiceBus subscription
|
10
|
+
- ServiceBus topic size
|
11
|
+
|
6
12
|
## 0.0.4 - 2016-12-04
|
7
13
|
### Added
|
8
14
|
- Checks for the following Quota's:
|
data/README.md
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
- check-azurerm-network-security-groups-usage.rb
|
20
20
|
- check-azurerm-public-ip-addresses-usage.rb
|
21
21
|
- check-azurerm-route-tables-usage.rb
|
22
|
+
- check-azurerm-service-bus-subscription.rb
|
23
|
+
- check-azurerm-service-bus-topic-size.rb
|
22
24
|
- check-azurerm-static-public-ip-addresses-usage.rb
|
23
25
|
- check-azurerm-virtual-machines-usage.rb
|
24
26
|
- check-azurerm-virtual-network-gateway-connected.rb
|
@@ -40,6 +42,8 @@
|
|
40
42
|
* /bin/check-azurerm-network-security-groups-usage.rb
|
41
43
|
* /bin/check-azurerm-public-ip-addresses-usage.rb
|
42
44
|
* /bin/check-azurerm-route-tables-usage.rb
|
45
|
+
* /bin/check-azurerm-service-bus-subscription.rb
|
46
|
+
* /bin/check-azurerm-service-bus-topic-size.rb
|
43
47
|
* /bin/check-azurerm-static-public-ip-addresses-usage.rb
|
44
48
|
* /bin/check-azurerm-virtual-machines-usage.rb
|
45
49
|
* /bin/check-azurerm-virtual-network-gateway-connected.rb
|
@@ -298,6 +302,46 @@
|
|
298
302
|
-critical_percentage 90
|
299
303
|
```
|
300
304
|
|
305
|
+
**check-azurerm-service-bus-subscription.rb**
|
306
|
+
```
|
307
|
+
./check-azurerm-service-bus-subscription.rb
|
308
|
+
--resourceGroup "resourcegroup"
|
309
|
+
--namespace "namespace"
|
310
|
+
--topic "topic"
|
311
|
+
--subscriptionName "subscriptionName"
|
312
|
+
|
313
|
+
./check-azurerm-service-bus-subscription.rb
|
314
|
+
-t "00000000-0000-0000-0000-000000000000"
|
315
|
+
-c "00000000-0000-0000-0000-000000000000"
|
316
|
+
-S "00000000-0000-0000-0000-000000000000"
|
317
|
+
-s "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
|
318
|
+
--resourceGroup "resourcegroup"
|
319
|
+
--namespace "namespace"
|
320
|
+
--topic "topic"
|
321
|
+
--subscriptionName "subscriptionName"
|
322
|
+
```
|
323
|
+
|
324
|
+
**check-azurerm-service-bus-topic-size.rb**
|
325
|
+
```
|
326
|
+
./check-azurerm-service-bus-topic-size.rb
|
327
|
+
--resourceGroup "resourcegroup"
|
328
|
+
--namespace "namespace"
|
329
|
+
--topic "topic"
|
330
|
+
-w 60
|
331
|
+
-c 80
|
332
|
+
|
333
|
+
./check-azurerm-service-bus-topic-size.rb
|
334
|
+
-t "00000000-0000-0000-0000-000000000000"
|
335
|
+
-c "00000000-0000-0000-0000-000000000000"
|
336
|
+
-S "00000000-0000-0000-0000-000000000000"
|
337
|
+
-s "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
|
338
|
+
--resourceGroup "resourcegroup"
|
339
|
+
--namespace "namespace"
|
340
|
+
--topic "topic"
|
341
|
+
-w 60
|
342
|
+
-c 80
|
343
|
+
```
|
344
|
+
|
301
345
|
**check-azurerm-virtual-machines-usage.rb**
|
302
346
|
```
|
303
347
|
./check-azurerm-virtual-machines-usage.rb -l "westeurope" -w 80 -c 90
|
@@ -0,0 +1,115 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-azurerm-service-bus-subscription
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin asserts that a given Service Bus Subscription exists
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain-text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: azure_mgmt_service_bus
|
16
|
+
# gem: sensu-plugin
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
#
|
20
|
+
# ./check-azurerm-service-bus-subscription.rb
|
21
|
+
# --resourceGroup "resourcegroup"
|
22
|
+
# --namespace "namespace"
|
23
|
+
# --topic "topic"
|
24
|
+
# --subscriptionName "subscriptionName"
|
25
|
+
#
|
26
|
+
# ./check-azurerm-service-bus-subscription.rb
|
27
|
+
# -t "00000000-0000-0000-0000-000000000000"
|
28
|
+
# -c "00000000-0000-0000-0000-000000000000"
|
29
|
+
# -S "00000000-0000-0000-0000-000000000000"
|
30
|
+
# -s "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
|
31
|
+
# --resourceGroup "resourcegroup"
|
32
|
+
# --namespace "namespace"
|
33
|
+
# --topic "topic"
|
34
|
+
# --subscriptionName "subscriptionName"
|
35
|
+
#
|
36
|
+
# NOTES:
|
37
|
+
#
|
38
|
+
# LICENSE:
|
39
|
+
# Andy Royle
|
40
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
41
|
+
# for details.
|
42
|
+
#
|
43
|
+
|
44
|
+
require 'azure_mgmt_service_bus'
|
45
|
+
require 'sensu-plugin/check/cli'
|
46
|
+
require 'sensu-plugins-azurerm'
|
47
|
+
|
48
|
+
class CheckAzureRMServiceBusSubscription < Sensu::Plugin::Check::CLI
|
49
|
+
include SensuPluginsAzureRM
|
50
|
+
|
51
|
+
option :tenant_id,
|
52
|
+
description: 'ARM Tenant ID. Either set ENV[\'ARM_TENANT_ID\'] or provide it as an option',
|
53
|
+
short: '-t ID',
|
54
|
+
long: '--tenant ID',
|
55
|
+
default: ENV['ARM_TENANT_ID']
|
56
|
+
|
57
|
+
option :client_id,
|
58
|
+
description: 'ARM Client ID. Either set ENV[\'ARM_CLIENT_ID\'] or provide it as an option',
|
59
|
+
short: '-c ID',
|
60
|
+
long: '--client ID',
|
61
|
+
default: ENV['ARM_CLIENT_ID']
|
62
|
+
|
63
|
+
option :client_secret,
|
64
|
+
description: 'ARM Client Secret. Either set ENV[\'ARM_CLIENT_SECRET\'] or provide it as an option',
|
65
|
+
short: '-s SECRET',
|
66
|
+
long: '--clientSecret SECRET',
|
67
|
+
default: ENV['ARM_CLIENT_SECRET']
|
68
|
+
|
69
|
+
option :subscription_id,
|
70
|
+
description: 'ARM Subscription ID',
|
71
|
+
short: '-S ID',
|
72
|
+
long: '--subscription ID',
|
73
|
+
default: ENV['ARM_SUBSCRIPTION_ID']
|
74
|
+
|
75
|
+
option :resource_group_name,
|
76
|
+
description: 'Azure Resource Group Name',
|
77
|
+
long: '--resourceGroup RESOURCEGROUP'
|
78
|
+
|
79
|
+
option :namespace_name,
|
80
|
+
description: 'Azure Service Bus Namespace Name',
|
81
|
+
long: '--namespaceName NAMESPACE'
|
82
|
+
|
83
|
+
option :topic_name,
|
84
|
+
description: 'Azure Service Bus Topic Name',
|
85
|
+
long: '--topicName TOPIC'
|
86
|
+
|
87
|
+
option :subscription_name,
|
88
|
+
description: 'Azure Service Bus Topic Name',
|
89
|
+
long: '--subscriptionName TOPIC'
|
90
|
+
|
91
|
+
def run
|
92
|
+
tenant_id = config[:tenant_id]
|
93
|
+
client_id = config[:client_id]
|
94
|
+
client_secret = config[:client_secret]
|
95
|
+
subscription_id = config[:subscription_id]
|
96
|
+
|
97
|
+
resource_group_name = config[:resource_group_name]
|
98
|
+
namespace_name = config[:namespace_name]
|
99
|
+
topic_name = config[:topic_name]
|
100
|
+
subscription_name = config[:subscription_name]
|
101
|
+
|
102
|
+
service_bus_client = ServiceBusUsage.new.build_service_bus_subscription_client(tenant_id, client_id, client_secret, subscription_id)
|
103
|
+
result = service_bus_client.get(resource_group_name, namespace_name, topic_name, subscription_name)
|
104
|
+
|
105
|
+
if result.nil?
|
106
|
+
critical "Subscription '#{config[:subscription_name]}' not found in topic '#{config[:topic_name]}'"
|
107
|
+
else
|
108
|
+
ok "Subscription '#{config[:subscription_name]}' was found in topic '#{config[:topic_name]}'"
|
109
|
+
end
|
110
|
+
|
111
|
+
rescue => e
|
112
|
+
puts "Error: exception: #{e}"
|
113
|
+
critical
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-azurerm-service-bus-topic-size
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin checks a given Service Bus Topic percentage used with warning/critical thresholds
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain-text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: azure_mgmt_service_bus
|
16
|
+
# gem: sensu-plugin
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
#
|
20
|
+
# ./check-azurerm-service-bus-topic-size.rb
|
21
|
+
# --resourceGroup "resourcegroup"
|
22
|
+
# --namespace "namespace"
|
23
|
+
# --topic "topic"
|
24
|
+
# -w 60
|
25
|
+
# -c 80
|
26
|
+
#
|
27
|
+
# ./check-azurerm-service-bus-topic-size.rb
|
28
|
+
# -t "00000000-0000-0000-0000-000000000000"
|
29
|
+
# -c "00000000-0000-0000-0000-000000000000"
|
30
|
+
# -S "00000000-0000-0000-0000-000000000000"
|
31
|
+
# -s "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
|
32
|
+
# --resourceGroup "resourcegroup"
|
33
|
+
# --namespace "namespace"
|
34
|
+
# --topic "topic"
|
35
|
+
# -w 60
|
36
|
+
# -c 80
|
37
|
+
#
|
38
|
+
# NOTES:
|
39
|
+
#
|
40
|
+
# LICENSE:
|
41
|
+
# Andy Royle
|
42
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
43
|
+
# for details.
|
44
|
+
#
|
45
|
+
|
46
|
+
require 'azure_mgmt_service_bus'
|
47
|
+
require 'sensu-plugin/check/cli'
|
48
|
+
require 'sensu-plugins-azurerm'
|
49
|
+
|
50
|
+
class CheckAzureRMServiceBusTopicSize < Sensu::Plugin::Check::CLI
|
51
|
+
include SensuPluginsAzureRM
|
52
|
+
|
53
|
+
option :tenant_id,
|
54
|
+
description: 'ARM Tenant ID. Either set ENV[\'ARM_TENANT_ID\'] or provide it as an option',
|
55
|
+
short: '-t ID',
|
56
|
+
long: '--tenant ID',
|
57
|
+
default: ENV['ARM_TENANT_ID']
|
58
|
+
|
59
|
+
option :client_id,
|
60
|
+
description: 'ARM Client ID. Either set ENV[\'ARM_CLIENT_ID\'] or provide it as an option',
|
61
|
+
short: '-c ID',
|
62
|
+
long: '--client ID',
|
63
|
+
default: ENV['ARM_CLIENT_ID']
|
64
|
+
|
65
|
+
option :client_secret,
|
66
|
+
description: 'ARM Client Secret. Either set ENV[\'ARM_CLIENT_SECRET\'] or provide it as an option',
|
67
|
+
short: '-s SECRET',
|
68
|
+
long: '--clientSecret SECRET',
|
69
|
+
default: ENV['ARM_CLIENT_SECRET']
|
70
|
+
|
71
|
+
option :subscription_id,
|
72
|
+
description: 'ARM Subscription ID',
|
73
|
+
short: '-S ID',
|
74
|
+
long: '--subscription ID',
|
75
|
+
default: ENV['ARM_SUBSCRIPTION_ID']
|
76
|
+
|
77
|
+
option :resource_group_name,
|
78
|
+
description: 'Azure Resource Group Name',
|
79
|
+
long: '--resourceGroup RESOURCEGROUP'
|
80
|
+
|
81
|
+
option :namespace_name,
|
82
|
+
description: 'Azure Service Bus Namespace Name',
|
83
|
+
long: '--namespaceName NAMESPACE'
|
84
|
+
|
85
|
+
option :topic_name,
|
86
|
+
description: 'Azure Service Bus Topic Name',
|
87
|
+
long: '--topicName TOPIC'
|
88
|
+
|
89
|
+
option :warning_percentage,
|
90
|
+
description: 'Warning Percentage threshold for filter',
|
91
|
+
short: '-w PERCENTAGE',
|
92
|
+
long: '--warning PERCENTAGE',
|
93
|
+
proc: proc { |l| l.to_f }
|
94
|
+
|
95
|
+
option :critical_percentage,
|
96
|
+
description: 'Critical Percentage threshold for filter',
|
97
|
+
short: '-c PERCENTAGE',
|
98
|
+
long: '--critical PERCENTAGE',
|
99
|
+
proc: proc { |l| l.to_f }
|
100
|
+
|
101
|
+
def run
|
102
|
+
tenant_id = config[:tenant_id]
|
103
|
+
client_id = config[:client_id]
|
104
|
+
client_secret = config[:client_secret]
|
105
|
+
subscription_id = config[:subscription_id]
|
106
|
+
|
107
|
+
resource_group_name = config[:resource_group_name]
|
108
|
+
namespace_name = config[:namespace_name]
|
109
|
+
topic_name = config[:topic_name]
|
110
|
+
|
111
|
+
warning_percentage = config[:warning_percentage]
|
112
|
+
critical_percentage = config[:critical_percentage]
|
113
|
+
|
114
|
+
service_bus_client = ServiceBusUsage.new.build_service_bus_topic_client(tenant_id, client_id, client_secret, subscription_id)
|
115
|
+
result = service_bus_client.get(resource_group_name, namespace_name, topic_name)
|
116
|
+
|
117
|
+
max_size_in_bytes = result.max_size_in_megabytes * 1024 * 1024
|
118
|
+
current_size = result.size_in_bytes
|
119
|
+
percentage_used = (current_size.to_f / max_size_in_bytes.to_f) * 100
|
120
|
+
|
121
|
+
message = "Current size of topic '#{topic_name}' is #{percentage_used}"
|
122
|
+
|
123
|
+
if percentage_used >= critical_percentage
|
124
|
+
critical message
|
125
|
+
elsif percentage_used >= warning_percentage
|
126
|
+
warning message
|
127
|
+
else
|
128
|
+
ok message
|
129
|
+
end
|
130
|
+
|
131
|
+
rescue => e
|
132
|
+
puts "Error: exception: #{e}"
|
133
|
+
critical
|
134
|
+
end
|
135
|
+
end
|
@@ -115,7 +115,7 @@ class MetricAzureRMServiceBusSubscriptionMessageCount < Sensu::Plugin::Metric::C
|
|
115
115
|
topic_name = config[:topic_name]
|
116
116
|
subscription_name = config[:subscription_name]
|
117
117
|
|
118
|
-
service_bus_client = ServiceBusUsage.new.
|
118
|
+
service_bus_client = ServiceBusUsage.new.build_service_bus_subscription_client(tenant_id, client_id, client_secret, subscription_id)
|
119
119
|
result = service_bus_client.get(resource_group_name, namespace_name, topic_name, subscription_name)
|
120
120
|
|
121
121
|
count = result.message_count
|
@@ -1,13 +1,23 @@
|
|
1
1
|
module SensuPluginsAzureRM
|
2
2
|
class ServiceBusUsage
|
3
|
-
def
|
3
|
+
def get_client(tenant_id, client_id, secret, subscription_id)
|
4
4
|
token_provider = MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, secret)
|
5
5
|
credentials = MsRest::TokenCredentials.new(token_provider)
|
6
6
|
client = Azure::ARM::ServiceBus::ServiceBusManagementClient.new(credentials)
|
7
7
|
client.subscription_id = subscription_id
|
8
|
+
client
|
9
|
+
end
|
8
10
|
|
11
|
+
def build_service_bus_subscription_client(tenant_id, client_id, secret, subscription_id)
|
12
|
+
client = get_client(tenant_id, client_id, secret, subscription_id)
|
9
13
|
usage_client = Azure::ARM::ServiceBus::Subscriptions.new(client)
|
10
14
|
usage_client
|
11
15
|
end
|
16
|
+
|
17
|
+
def build_service_bus_topic_client(tenant_id, client_id, secret, subscription_id)
|
18
|
+
client = get_client(tenant_id, client_id, secret, subscription_id)
|
19
|
+
usage_client = Azure::ARM::ServiceBus::Topics.new(client)
|
20
|
+
usage_client
|
21
|
+
end
|
12
22
|
end
|
13
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-azurerm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Harvey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: azure_mgmt_compute
|
@@ -221,6 +221,8 @@ executables:
|
|
221
221
|
- check-azurerm-network-security-groups-usage.rb
|
222
222
|
- check-azurerm-public-ip-addresses-usage.rb
|
223
223
|
- check-azurerm-route-tables-usage.rb
|
224
|
+
- check-azurerm-service-bus-subscription.rb
|
225
|
+
- check-azurerm-service-bus-topic-size.rb
|
224
226
|
- check-azurerm-static-public-ip-addresses-usage.rb
|
225
227
|
- check-azurerm-virtual-machines-usage.rb
|
226
228
|
- check-azurerm-virtual-network-gateway-connected.rb
|
@@ -246,6 +248,8 @@ files:
|
|
246
248
|
- bin/check-azurerm-network-security-groups-usage.rb
|
247
249
|
- bin/check-azurerm-public-ip-addresses-usage.rb
|
248
250
|
- bin/check-azurerm-route-tables-usage.rb
|
251
|
+
- bin/check-azurerm-service-bus-subscription.rb
|
252
|
+
- bin/check-azurerm-service-bus-topic-size.rb
|
249
253
|
- bin/check-azurerm-static-public-ip-addresses-usage.rb
|
250
254
|
- bin/check-azurerm-virtual-machines-usage.rb
|
251
255
|
- bin/check-azurerm-virtual-network-gateway-connected.rb
|