sensu-plugins-azurerm 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3ca54b410d852ba9abc57052a70d81e1f058b57
4
- data.tar.gz: 595f6416241a2bd7ca671aa7f265cfaf0aebba03
3
+ metadata.gz: f64abc5f248cc77f5fac058d2a0ae1c1bbf5d8cd
4
+ data.tar.gz: 002b3616bf8fe69d3eb0ba3342b3b0f56a678c5f
5
5
  SHA512:
6
- metadata.gz: 91b62be8ce38c10ccd128a46476bed13a86fa612da0464ddc9ffac8c21662a209fc584f064adb6aa52cb419141453b51e08c38c2419d8ef1a7db7a24fea1522e
7
- data.tar.gz: b082134bf173d15daac8b39036854669a3b22ca6798d0fd5ac0cd10efe8200e51d09d91aeeba85d3a778ff58a25010d7ff9fd2ce7ee03f295baa72296da34d1e
6
+ metadata.gz: 58bf2d82e569a834da181226e69364e42fe0f514d6a92b5f21ed7437b3f247ec5878f30863825dbd22d34ae82511b770ec7623844eadbccfc4fe4016b058410e
7
+ data.tar.gz: 9900e040280568af5adbf9f27f4d097b1ff8b4ee14f6edf81fa64760d721b5ff47ef8b2d1118a0bacbe6c6c0b6b220f12534778cf657d7b07ce7a48edae588fb
@@ -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.2 - 2016-11-23
7
+ ### Added
8
+ - Virtual Network Gateways:
9
+ - Check to ensure a given Virtual Network Gateway is Connected
10
+ - Metrics exposed for a given Virtual Network Gateway
11
+
6
12
  ## 0.0.1 - 2016-11-18
7
13
  ### Added
8
14
  - initial release
data/README.md CHANGED
@@ -10,11 +10,17 @@
10
10
 
11
11
  - check-azurerm-core-usage.rb
12
12
  - check-azurerm-virtual-machines-usage.rb
13
+ - check-azurerm-virtual-network-gateway-connected.rb
14
+ - metric-azurerm-virtual-network-gateway-usage.rb
13
15
 
14
16
 
15
17
  ## Files
16
18
 
17
19
  * /bin/check-azurerm-core-usage.rb
20
+ * /bin/check-azurerm-virtual-machines-usage.rb
21
+ * /bin/check-azurerm-virtual-network-gateway-connected.rb
22
+ * /bin/metric-azurerm-virtual-network-gateway-usage.rb
23
+
18
24
 
19
25
  ## Usage
20
26
 
@@ -56,6 +62,47 @@
56
62
  -critical_percentage 90
57
63
  ```
58
64
 
65
+
66
+ **check-azurerm-virtual-network-gateway-connected.rb**
67
+ ```
68
+ ./check-azurerm-virtual-network-gateway-connected.rb -r "resourcegroup" -n "gatewayname"
69
+
70
+ ./check-azurerm-virtual-network-gateway-connected.rb
71
+ -t "00000000-0000-0000-0000-000000000000"
72
+ -c "00000000-0000-0000-0000-000000000000"
73
+ -S "00000000-0000-0000-0000-000000000000"
74
+ -s "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
75
+ -r "resourcegroup" -n "gatewayname"
76
+
77
+ ./check-azurerm-virtual-network-gateway-connected.rb
78
+ -tenant "00000000-0000-0000-0000-000000000000"
79
+ -client "00000000-0000-0000-0000-000000000000"
80
+ -clientSecret "00000000-0000-0000-0000-000000000000"
81
+ -subscription_id "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
82
+ -resourceGroup "resourcegroup"
83
+ -name "gatewayname"
84
+ ```
85
+
86
+ **metric-azurerm-virtual-network-gateway-usagerb**
87
+ ```
88
+ ./metric-azurerm-virtual-network-gateway-usage.rb -r "resourcegroup" -n "gatewayname"
89
+
90
+ ./metric-azurerm-virtual-network-gateway-usage.rb
91
+ -t "00000000-0000-0000-0000-000000000000"
92
+ -c "00000000-0000-0000-0000-000000000000"
93
+ -S "00000000-0000-0000-0000-000000000000"
94
+ -s "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
95
+ -r "resourcegroup" -n "gatewayname"
96
+
97
+ ./metric-azurerm-virtual-network-gateway-usage.rb
98
+ -tenant "00000000-0000-0000-0000-000000000000"
99
+ -client "00000000-0000-0000-0000-000000000000"
100
+ -clientSecret "00000000-0000-0000-0000-000000000000"
101
+ -subscription_id "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
102
+ -resourceGroup "resourcegroup"
103
+ -name "gatewayname"
104
+ ```
105
+
59
106
  ## Installation
60
107
 
61
108
  [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
@@ -45,7 +45,7 @@ require 'sensu-plugin/check/cli'
45
45
  require 'sensu-plugins-azurerm'
46
46
  require 'azure_mgmt_compute'
47
47
 
48
- class AzureRMCoreUsage < Sensu::Plugin::Check::CLI
48
+ class CheckAzureRMCoreUsage < Sensu::Plugin::Check::CLI
49
49
  include SensuPluginsAzureRM
50
50
 
51
51
  option :tenant_id,
@@ -94,9 +94,9 @@ class AzureRMCoreUsage < Sensu::Plugin::Check::CLI
94
94
  subscriptionId = config[:subscription_id]
95
95
  location = config[:location]
96
96
 
97
- common = Common.new()
97
+ common = ComputeUsage.new()
98
98
 
99
- usageClient = common.buildClient(tenantId, clientId, clientSecret, subscriptionId)
99
+ usageClient = common.buildUsageOperationClient(tenantId, clientId, clientSecret, subscriptionId)
100
100
  result = common.retrieveUsageStats(usageClient, location, 'cores')
101
101
 
102
102
  current_usage = result.current_value
@@ -45,7 +45,7 @@ require 'sensu-plugin/check/cli'
45
45
  require 'sensu-plugins-azurerm'
46
46
  require 'azure_mgmt_compute'
47
47
 
48
- class AzureRMVMUsage < Sensu::Plugin::Check::CLI
48
+ class CheckAzureRMVMUsage < Sensu::Plugin::Check::CLI
49
49
  include SensuPluginsAzureRM
50
50
 
51
51
  option :tenant_id,
@@ -94,9 +94,9 @@ class AzureRMVMUsage < Sensu::Plugin::Check::CLI
94
94
  subscriptionId = config[:subscription_id]
95
95
  location = config[:location]
96
96
 
97
- common = Common.new()
97
+ common = ComputeUsage.new()
98
98
 
99
- usageClient = common.buildClient(tenantId, clientId, clientSecret, subscriptionId)
99
+ usageClient = common.buildUsageOperationClient(tenantId, clientId, clientSecret, subscriptionId)
100
100
  result = common.retrieveUsageStats(usageClient, location, 'virtualMachines')
101
101
 
102
102
  current_usage = result.current_value
@@ -0,0 +1,115 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-azurerm-virtual-network-gateway-connected
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin checks the specified Virtual Network Gateway is connected.
7
+ # Firing a Critical alert if this is not.
8
+ #
9
+ # OUTPUT:
10
+ # plain-text
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: azure_mgmt_network
17
+ # gem: sensu-plugin
18
+ #
19
+ # USAGE:
20
+ # ./check-azurerm-virtual-network-gateway-connected.rb -r "resourcegroup" -n "gatewayname"
21
+ #
22
+ # ./check-azurerm-virtual-network-gateway-connected.rb
23
+ # -t "00000000-0000-0000-0000-000000000000"
24
+ # -c "00000000-0000-0000-0000-000000000000"
25
+ # -S "00000000-0000-0000-0000-000000000000"
26
+ # -s "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
27
+ # -r "resourcegroup" -n "gatewayname"
28
+ #
29
+ # ./check-azurerm-virtual-network-gateway-connected.rb
30
+ # -tenant "00000000-0000-0000-0000-000000000000"
31
+ # -client "00000000-0000-0000-0000-000000000000"
32
+ # -clientSecret "00000000-0000-0000-0000-000000000000"
33
+ # -subscription_id "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
34
+ # -resourceGroup "resourcegroup"
35
+ # -name "gatewayname"
36
+ #
37
+ # NOTES:
38
+ #
39
+ # LICENSE:
40
+ # Tom Harvey
41
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
42
+ # for details.
43
+ #
44
+
45
+ require 'sensu-plugin/check/cli'
46
+ require 'sensu-plugins-azurerm'
47
+ require 'azure_mgmt_network'
48
+
49
+ class CheckAzureRMVirtualNetworkGatewayConnected < Sensu::Plugin::Check::CLI
50
+ include SensuPluginsAzureRM
51
+
52
+ option :tenant_id,
53
+ description: 'ARM Tenant ID. Either set ENV[\'ARM_TENANT_ID\'] or provide it as an option',
54
+ short: '-t ID',
55
+ long: '--tenant ID',
56
+ default: ENV['ARM_TENANT_ID'] # TODO: can we pull these out from the Check too?
57
+
58
+ option :client_id,
59
+ description: 'ARM Client ID. Either set ENV[\'ARM_CLIENT_ID\'] or provide it as an option',
60
+ short: '-c ID',
61
+ long: '--client ID',
62
+ default: ENV['ARM_CLIENT_ID']
63
+
64
+ option :client_secret,
65
+ description: 'ARM Client Secret. Either set ENV[\'ARM_CLIENT_SECRET\'] or provide it as an option',
66
+ short: '-s SECRET',
67
+ long: '--clientSecret SECRET',
68
+ default: ENV['ARM_CLIENT_SECRET']
69
+
70
+ option :subscription_id,
71
+ description: 'ARM Subscription ID',
72
+ short: '-S ID',
73
+ long: '--subscription ID',
74
+ default: ENV['ARM_SUBSCRIPTION_ID']
75
+
76
+ option :resource_group_name,
77
+ description: 'Azure Resource Group Name',
78
+ short: '-r RESOURCEGROUP',
79
+ long: '--resourceGroup RESOURCEGROUP'
80
+
81
+ option :name,
82
+ description: 'Azure Virtual Network Connection Gateway Name',
83
+ short: '-n NAME',
84
+ long: '--name NAME'
85
+
86
+ def run
87
+ tenantId = config[:tenant_id]
88
+ clientId = config[:client_id]
89
+ clientSecret = config[:client_secret]
90
+ subscriptionId = config[:subscription_id]
91
+
92
+ resource_group_name = config[:resource_group_name]
93
+ name = config[:name]
94
+
95
+ usage = NetworkUsage.new()
96
+
97
+ networkClient = usage.buildVirtualNetworkClient(tenantId, clientId, clientSecret, subscriptionId)
98
+ result = networkClient.get(resource_group_name, name)
99
+
100
+ connection_state = result.connection_status
101
+ inbound = result.ingress_bytes_transferred
102
+ outbound = result.egress_bytes_transferred
103
+ message = "State is '#{connection_state}'. Usage is #{inbound} in / #{outbound} out"
104
+ if result.connection_status.casecmp("connected") == 0
105
+ ok message
106
+ else
107
+ critical message
108
+ end
109
+
110
+ rescue => e
111
+ puts "Error: exception: #{e}"
112
+ critical
113
+ end
114
+
115
+ end
@@ -0,0 +1,116 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # metric-azurerm-virtual-network-gateway-usage
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin exposes the Virtual Network Gateway Ingress & Egress values as Metric's
7
+ #
8
+ # OUTPUT:
9
+ # plain-text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: azure_mgmt_network
16
+ # gem: sensu-plugin
17
+ #
18
+ # USAGE:
19
+ # ./metric-azurerm-virtual-network-gateway-usage.rb -r "resourcegroup" -n "gatewayname"
20
+ #
21
+ # ./metric-azurerm-virtual-network-gateway-usage.rb
22
+ # -t "00000000-0000-0000-0000-000000000000"
23
+ # -c "00000000-0000-0000-0000-000000000000"
24
+ # -S "00000000-0000-0000-0000-000000000000"
25
+ # -s "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
26
+ # -r "resourcegroup" -n "gatewayname"
27
+ #
28
+ # ./metric-azurerm-virtual-network-gateway-usage.rb
29
+ # -tenant "00000000-0000-0000-0000-000000000000"
30
+ # -client "00000000-0000-0000-0000-000000000000"
31
+ # -clientSecret "00000000-0000-0000-0000-000000000000"
32
+ # -subscription_id "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234"
33
+ # -resourceGroup "resourcegroup"
34
+ # -name "gatewayname"
35
+ #
36
+ # NOTES:
37
+ #
38
+ # LICENSE:
39
+ # Tom Harvey
40
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
41
+ # for details.
42
+ #
43
+
44
+ require 'sensu-plugin/check/cli'
45
+ require 'sensu-plugins-azurerm'
46
+ require 'azure_mgmt_network'
47
+
48
+ class MetricAzureRMVirtualNetworkGatewayUsage < 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'] # TODO: can we pull these out from the Check too?
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
+ short: '-r RESOURCEGROUP',
78
+ long: '--resourceGroup RESOURCEGROUP'
79
+
80
+ option :name,
81
+ description: 'Azure Virtual Network Connection Gateway Name',
82
+ short: '-n NAME',
83
+ long: '--name NAME'
84
+
85
+ def run
86
+ tenantId = config[:tenant_id]
87
+ clientId = config[:client_id]
88
+ clientSecret = config[:client_secret]
89
+ subscriptionId = config[:subscription_id]
90
+
91
+ resource_group_name = config[:resource_group_name]
92
+ name = config[:name]
93
+
94
+ usage = NetworkUsage.new()
95
+
96
+ networkClient = usage.buildVirtualNetworkClient(tenantId, clientId, clientSecret, subscriptionId)
97
+ result = networkClient.get(resource_group_name, name)
98
+
99
+ inbound = result.ingress_bytes_transferred
100
+ outbound = result.egress_bytes_transferred
101
+
102
+ timestamp = Time.now.utc.to_i
103
+ scheme = config[:scheme]
104
+ name = [scheme, resource_group_name, name].join('.').tr(' ', '_').tr('{}', '').tr('[]', '')
105
+ inboundName = [name, "inbound"].join('.')
106
+ outboundName = [name, "outbound"].join('.')
107
+
108
+ output inboundName, inbound, timestamp
109
+ output outboundName, outbound, timestamp
110
+
111
+ rescue => e
112
+ puts "Error: exception: #{e}"
113
+ critical
114
+ end
115
+
116
+ end
@@ -1,2 +1,3 @@
1
- require 'sensu-plugins-azurerm/common'
1
+ require 'sensu-plugins-azurerm/compute_usage'
2
+ require 'sensu-plugins-azurerm/network_usage'
2
3
  require 'sensu-plugins-azurerm/version'
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsAzureRM
2
2
 
3
- class Common
3
+ class ComputeUsage
4
4
 
5
- def buildClient(tenant_id, client_id, secret, subscription_id)
5
+ def buildUsageOperationClient(tenant_id, client_id, secret, subscription_id)
6
6
  token_provider = MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, secret)
7
7
  credentials = MsRest::TokenCredentials.new(token_provider)
8
8
  client = Azure::ARM::Compute::ComputeManagementClient.new(credentials)
@@ -0,0 +1,16 @@
1
+ module SensuPluginsAzureRM
2
+
3
+ class NetworkUsage
4
+
5
+ def buildVirtualNetworkClient(tenant_id, client_id, secret, subscription_id)
6
+ token_provider = MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, secret)
7
+ credentials = MsRest::TokenCredentials.new(token_provider)
8
+ client = Azure::ARM::Network::NetworkManagementClient.new(credentials)
9
+ client.subscription_id = subscription_id
10
+
11
+ usageClient = Azure::ARM::Network::VirtualNetworkGatewayConnections.new(client)
12
+ usageClient
13
+ end
14
+
15
+ end
16
+ end
@@ -2,7 +2,7 @@ module SensuPluginsAzureRM
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 2
6
6
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
8
8
  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.1
4
+ version: 0.0.2
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-11-21 00:00:00.000000000 Z
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: azure_mgmt_compute
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: azure_mgmt_network
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: ms_rest_azure
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -183,12 +197,17 @@ email: <github@ibuildstuff.co.uk>
183
197
  executables:
184
198
  - check-azurerm-core-usage.rb
185
199
  - check-azurerm-virtual-machines-usage.rb
200
+ - check-azurerm-virtual-network-gateway-connected.rb
201
+ - metric-azurerm-virtual-network-gateway-usage.rb
186
202
  extensions: []
187
203
  extra_rdoc_files: []
188
204
  files:
189
205
  - bin/check-azurerm-core-usage.rb
190
206
  - bin/check-azurerm-virtual-machines-usage.rb
191
- - lib/sensu-plugins-azurerm/common.rb
207
+ - bin/check-azurerm-virtual-network-gateway-connected.rb
208
+ - bin/metric-azurerm-virtual-network-gateway-usage.rb
209
+ - lib/sensu-plugins-azurerm/compute_usage.rb
210
+ - lib/sensu-plugins-azurerm/network_usage.rb
192
211
  - lib/sensu-plugins-azurerm/version.rb
193
212
  - lib/sensu-plugins-azurerm.rb
194
213
  - LICENSE