sensu-plugins-aws 10.1.1 → 10.1.2
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 +9 -0
- data/bin/check-asg-instances-created.rb +1 -1
- data/bin/check-asg-instances-inservice.rb +2 -2
- data/bin/check-beanstalk-elb-metric.rb +1 -1
- data/bin/check-beanstalk-health.rb +4 -4
- data/bin/check-cloudfront-tag.rb +2 -2
- data/bin/check-cloudwatch-alarm.rb +1 -2
- data/bin/check-cloudwatch-alarms.rb +1 -2
- data/bin/check-configservice-rules.rb +1 -1
- data/bin/check-dynamodb-capacity.rb +4 -4
- data/bin/check-dynamodb-throttle.rb +4 -4
- data/bin/check-ec2-cpu_balance.rb +2 -2
- data/bin/check-ec2-filter.rb +1 -1
- data/bin/check-ec2-network.rb +1 -1
- data/bin/check-ecs-service-health.rb +2 -2
- data/bin/check-elb-certs.rb +2 -2
- data/bin/check-elb-health-fog.rb +3 -3
- data/bin/check-elb-health-sdk.rb +1 -1
- data/bin/check-elb-health.rb +3 -3
- data/bin/check-elb-latency.rb +3 -3
- data/bin/check-elb-nodes.rb +1 -1
- data/bin/check-elb-sum-requests.rb +3 -3
- data/bin/check-emr-cluster.rb +1 -1
- data/bin/check-eni-status.rb +2 -2
- data/bin/check-instance-events.rb +5 -4
- data/bin/check-instance-health.rb +1 -1
- data/bin/check-instance-reachability.rb +1 -1
- data/bin/check-instances-count.rb +1 -1
- data/bin/check-kms-key.rb +1 -1
- data/bin/check-rds-events.rb +2 -3
- data/bin/check-rds-pending.rb +1 -1
- data/bin/check-rds.rb +5 -5
- data/bin/check-redshift-events.rb +2 -2
- data/bin/check-route.rb +1 -1
- data/bin/check-route53-domain-expiration.rb +3 -4
- data/bin/check-s3-bucket.rb +1 -1
- data/bin/check-s3-object.rb +3 -3
- data/bin/check-s3-tag.rb +2 -2
- data/bin/check-ses-limit.rb +1 -1
- data/bin/check-subnet-ip-consumption.rb +8 -3
- data/bin/check-trustedadvisor-service-limits.rb +1 -1
- data/bin/check-vpc-nameservers.rb +1 -1
- data/bin/check-vpc-vpn.rb +2 -2
- data/bin/handler-ec2_node.rb +1 -1
- data/bin/handler-scale-asg-down.rb +2 -2
- data/bin/handler-scale-asg-up.rb +2 -2
- data/bin/handler-sns.rb +1 -1
- data/bin/metrics-autoscaling-instance-count.rb +1 -1
- data/bin/metrics-billing.rb +1 -2
- data/bin/metrics-ec2-count.rb +1 -2
- data/bin/metrics-ec2-filter.rb +1 -1
- data/bin/metrics-elasticache.rb +2 -1
- data/bin/metrics-elb-full.rb +1 -1
- data/bin/metrics-emr-steps.rb +1 -1
- data/bin/metrics-rds.rb +1 -1
- data/bin/metrics-s3.rb +5 -3
- data/bin/metrics-sqs.rb +1 -1
- data/lib/sensu-plugins-aws/common.rb +4 -1
- data/lib/sensu-plugins-aws/version.rb +1 -1
- metadata +35 -35
data/bin/check-kms-key.rb
CHANGED
|
@@ -57,7 +57,7 @@ class CheckKMSKey < Sensu::Plugin::Check::CLI
|
|
|
57
57
|
return kms_client.describe_key(key_id: id)['key_metadata']['enabled']
|
|
58
58
|
rescue Aws::KMS::Errors::NotFoundException
|
|
59
59
|
critical 'Key doesnt exist'
|
|
60
|
-
rescue => e
|
|
60
|
+
rescue StandardError => e
|
|
61
61
|
unknown "Failed to check key #{id}: #{e}"
|
|
62
62
|
end
|
|
63
63
|
|
data/bin/check-rds-events.rb
CHANGED
|
@@ -90,7 +90,7 @@ class CheckRDSEvents < Sensu::Plugin::Check::CLI
|
|
|
90
90
|
maint_clusters = []
|
|
91
91
|
aws_regions = rds_regions
|
|
92
92
|
|
|
93
|
-
unless config[:aws_region].casecmp('all')
|
|
93
|
+
unless config[:aws_region].casecmp('all').zero?
|
|
94
94
|
if aws_regions.include? config[:aws_region]
|
|
95
95
|
aws_regions.clear.push(config[:aws_region])
|
|
96
96
|
else
|
|
@@ -131,8 +131,7 @@ class CheckRDSEvents < Sensu::Plugin::Check::CLI
|
|
|
131
131
|
cluster_name_long = "#{cluster_name} (#{r}) #{events_record[:events][-1][:message]}"
|
|
132
132
|
maint_clusters.push(cluster_name_long)
|
|
133
133
|
end
|
|
134
|
-
|
|
135
|
-
rescue => e
|
|
134
|
+
rescue StandardError => e
|
|
136
135
|
unknown "An error occurred processing AWS RDS API (#{r}): #{e.message}"
|
|
137
136
|
end
|
|
138
137
|
end
|
data/bin/check-rds-pending.rb
CHANGED
|
@@ -52,7 +52,7 @@ class CheckRDSEvents < Sensu::Plugin::Check::CLI
|
|
|
52
52
|
pending_record[:pending_maintenance_actions].each do |response|
|
|
53
53
|
maint_clusters.push(response[:pending_maintenance_action_details])
|
|
54
54
|
end
|
|
55
|
-
rescue => e
|
|
55
|
+
rescue StandardError => e
|
|
56
56
|
unknown "An error occurred processing AWS RDS API: #{e.message}"
|
|
57
57
|
end
|
|
58
58
|
|
data/bin/check-rds.rb
CHANGED
|
@@ -118,12 +118,12 @@ class CheckRDS < Sensu::Plugin::Check::CLI
|
|
|
118
118
|
description: 'Continue if CloudWatch provides no metrics for the time period',
|
|
119
119
|
default: false
|
|
120
120
|
|
|
121
|
-
%w
|
|
121
|
+
%w[warning critical].each do |severity|
|
|
122
122
|
option :"availability_zone_#{severity}",
|
|
123
123
|
long: "--availability-zone-#{severity} AZ",
|
|
124
124
|
description: "Trigger a #{severity} if availability zone is different than given argument"
|
|
125
125
|
|
|
126
|
-
%w
|
|
126
|
+
%w[cpu memory disk connections iops].each do |item|
|
|
127
127
|
option :"#{item}_#{severity}_over",
|
|
128
128
|
long: "--#{item}-#{severity}-over N",
|
|
129
129
|
proc: proc(&:to_f),
|
|
@@ -335,16 +335,16 @@ class CheckRDS < Sensu::Plugin::Check::CLI
|
|
|
335
335
|
warning: false
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
@severities.
|
|
338
|
+
@severities.each_key do |severity|
|
|
339
339
|
message += check_az severity, config[:"availability_zone_#{severity}"], instance if config[:"availability_zone_#{severity}"]
|
|
340
340
|
|
|
341
|
-
%w
|
|
341
|
+
%w[cpu memory disk connections iops].each do |item|
|
|
342
342
|
result = send "check_#{item}", severity, config[:"#{item}_#{severity}_over"] if config[:"#{item}_#{severity}_over"]
|
|
343
343
|
message += result unless result.nil?
|
|
344
344
|
end
|
|
345
345
|
end
|
|
346
346
|
|
|
347
|
-
if %w
|
|
347
|
+
if %w[cpu memory disk connections iops].any? { |item| %w[warning critical].any? { |severity| config[:"#{item}_#{severity}_over"] } }
|
|
348
348
|
message += "(#{config[:statistics].to_s.capitalize} within #{config[:period]}s "
|
|
349
349
|
message += "between #{config[:end_time] - config[:period]} to #{config[:end_time]})"
|
|
350
350
|
end
|
|
@@ -81,7 +81,7 @@ class CheckRedshiftEvents < Sensu::Plugin::Check::CLI
|
|
|
81
81
|
|
|
82
82
|
# throw unknown message if the user passed us a missing instance
|
|
83
83
|
def check_missing_instances(instances)
|
|
84
|
-
missing_instances = instances.
|
|
84
|
+
missing_instances = instances.reject { |i| all_clusters.include?(i) }
|
|
85
85
|
unknown("Passed instance(s): #{missing_instances.join(',')} not found") unless missing_instances.empty?
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -110,7 +110,7 @@ class CheckRedshiftEvents < Sensu::Plugin::Check::CLI
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
maint_clusters = clusters_in_maint(all_clusters)
|
|
113
|
-
rescue => e
|
|
113
|
+
rescue StandardError => e
|
|
114
114
|
unknown "An error occurred processing AWS Redshift API: #{e.message}"
|
|
115
115
|
end
|
|
116
116
|
|
data/bin/check-route.rb
CHANGED
|
@@ -55,8 +55,8 @@ class CheckRoute53DomainExpiration < Sensu::Plugin::Check::CLI
|
|
|
55
55
|
begin
|
|
56
56
|
domains = r53.list_domains.domains
|
|
57
57
|
domains.each do |domain|
|
|
58
|
-
expiration = DateTime.parse(domain.expiry.to_s)
|
|
59
|
-
days_until_expiration = (expiration - DateTime.now).to_i
|
|
58
|
+
expiration = DateTime.parse(domain.expiry.to_s) # rubocop: disable Style/DateTime
|
|
59
|
+
days_until_expiration = (expiration - DateTime.now).to_i # rubocop: disable Style/DateTime
|
|
60
60
|
if days_until_expiration <= config[:crit]
|
|
61
61
|
crit_domains[domain] = days_until_expiration
|
|
62
62
|
elsif days_until_expiration <= config[:warn]
|
|
@@ -71,8 +71,7 @@ class CheckRoute53DomainExpiration < Sensu::Plugin::Check::CLI
|
|
|
71
71
|
else
|
|
72
72
|
ok 'No domains are expiring soon'
|
|
73
73
|
end
|
|
74
|
-
|
|
75
|
-
rescue => e
|
|
74
|
+
rescue StandardError => e
|
|
76
75
|
unknown "An error occurred communicating with the Route53 API: #{e.message}"
|
|
77
76
|
end
|
|
78
77
|
end
|
data/bin/check-s3-bucket.rb
CHANGED
|
@@ -79,7 +79,7 @@ class CheckS3Bucket < Sensu::Plugin::Check::CLI
|
|
|
79
79
|
ok "Bucket #{config[:bucket_name]} found"
|
|
80
80
|
rescue Aws::S3::Errors::NotFound => _
|
|
81
81
|
critical "Bucket #{config[:bucket_name]} not found"
|
|
82
|
-
rescue => e
|
|
82
|
+
rescue StandardError => e
|
|
83
83
|
critical "Bucket #{config[:bucket_name]} - #{e.message}"
|
|
84
84
|
end
|
|
85
85
|
end
|
data/bin/check-s3-object.rb
CHANGED
|
@@ -168,14 +168,14 @@ class CheckS3Object < Sensu::Plugin::Check::CLI
|
|
|
168
168
|
size = output.contents[0].size
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
-
[
|
|
171
|
+
%i[critical warning].each do |level|
|
|
172
172
|
run_check('age', level, age, key_fullname, 'S3 object %s is %s seconds old (bucket %s)')
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
if size.zero?
|
|
176
176
|
critical "S3 object #{key_fullname} is empty (bucket #{config[:bucket_name]})" unless config[:ok_zero_size]
|
|
177
177
|
else
|
|
178
|
-
[
|
|
178
|
+
%i[critical warning].each do |level|
|
|
179
179
|
run_check('size', level, size, key_fullname, 'S3 %s object\'size : %s octets (bucket %s)')
|
|
180
180
|
end
|
|
181
181
|
end
|
|
@@ -183,7 +183,7 @@ class CheckS3Object < Sensu::Plugin::Check::CLI
|
|
|
183
183
|
ok("S3 object #{key_fullname} exists in bucket #{config[:bucket_name]}")
|
|
184
184
|
rescue Aws::S3::Errors::NotFound => _
|
|
185
185
|
critical "S3 object #{key_fullname} not found in bucket #{config[:bucket_name]}"
|
|
186
|
-
rescue => e
|
|
186
|
+
rescue StandardError => e
|
|
187
187
|
critical "S3 object #{key_fullname} in bucket #{config[:bucket_name]} - #{e.message} - #{e.backtrace}"
|
|
188
188
|
end
|
|
189
189
|
end
|
data/bin/check-s3-tag.rb
CHANGED
|
@@ -54,7 +54,7 @@ class CheckS3Tag < Sensu::Plugin::Check::CLI
|
|
|
54
54
|
if keys.sort & tags.sort != tags.sort
|
|
55
55
|
missing_tags.push bucket.name
|
|
56
56
|
end
|
|
57
|
-
rescue
|
|
57
|
+
rescue StandardError
|
|
58
58
|
missing_tags.push bucket.name
|
|
59
59
|
end
|
|
60
60
|
end
|
|
@@ -64,7 +64,7 @@ class CheckS3Tag < Sensu::Plugin::Check::CLI
|
|
|
64
64
|
else
|
|
65
65
|
critical("Missing tags in #{missing_tags}")
|
|
66
66
|
end
|
|
67
|
-
rescue => e
|
|
67
|
+
rescue StandardError => e
|
|
68
68
|
critical "Error: #{e.message} - #{e.backtrace}"
|
|
69
69
|
end
|
|
70
70
|
end
|
data/bin/check-ses-limit.rb
CHANGED
|
@@ -93,7 +93,7 @@ class CheckSubnetIpConsumption < Sensu::Plugin::Check::CLI
|
|
|
93
93
|
|
|
94
94
|
return '<no alias>' if iam_account_alias.empty? || iam_account_alias.nil?
|
|
95
95
|
return iam_account_alias
|
|
96
|
-
rescue => e
|
|
96
|
+
rescue StandardError => e
|
|
97
97
|
unknown "An error occured while using AWS IAM to collect the account alias: #{e.message}"
|
|
98
98
|
end
|
|
99
99
|
end
|
|
@@ -165,7 +165,7 @@ class CheckSubnetIpConsumption < Sensu::Plugin::Check::CLI
|
|
|
165
165
|
vpc_friendly_name: vpc_friendly_name)
|
|
166
166
|
end
|
|
167
167
|
end
|
|
168
|
-
rescue => e
|
|
168
|
+
rescue StandardError => e
|
|
169
169
|
unknown "An error occurred processing AWS EC2: #{e.message}"
|
|
170
170
|
end
|
|
171
171
|
|
|
@@ -175,10 +175,12 @@ class CheckSubnetIpConsumption < Sensu::Plugin::Check::CLI
|
|
|
175
175
|
else
|
|
176
176
|
# Compose alert messages at the configured verbosity
|
|
177
177
|
alert_msg = []
|
|
178
|
-
|
|
178
|
+
# TODO: Come back and re-asses Rubocop rule, following it's suggestion actually breaks the code
|
|
179
|
+
# rubocop:disable Style/FormatStringToken
|
|
179
180
|
verbosity0 = '%{subnet} at %{percent}%% [%{vpc}]'
|
|
180
181
|
verbosity1 = '%{subnet} at %{percent}%% (%{consumed}/%{total}) [%{vpc}]'
|
|
181
182
|
verbosity2 = '%{subnet} (%{cidr} in %{az}) at %{percent}%% (%{consumed}/%{total}) [%{vpc}]'
|
|
183
|
+
# rubocop:enable Style/FormatStringToken
|
|
182
184
|
|
|
183
185
|
case config[:verbosity]
|
|
184
186
|
when 0
|
|
@@ -208,8 +210,11 @@ class CheckSubnetIpConsumption < Sensu::Plugin::Check::CLI
|
|
|
208
210
|
end
|
|
209
211
|
|
|
210
212
|
# Throw critical alert with optional account alias display
|
|
213
|
+
# TODO: Come back and re-asses Rubocop rule, following it's suggestion actually breaks the code
|
|
214
|
+
# rubocop:disable Style/FormatStringToken
|
|
211
215
|
alert_prefix = '%{count} subnets in %{region} exceeding %{threshold}%% IP consumption threshold: %{alerts}'
|
|
212
216
|
alert_prefix_with_alias = '%{count} subnets in %{alias} (%{region}) exceeding %{threshold}%% IP consumption threshold: %{alerts}'
|
|
217
|
+
# rubocop:enable Style/FormatStringToken
|
|
213
218
|
|
|
214
219
|
case config[:show_account_alias]
|
|
215
220
|
when true
|
|
@@ -69,7 +69,7 @@ class CheckTrustedAdvisorServiceLimits < Sensu::Plugin::Check::CLI
|
|
|
69
69
|
sl_msg = "#{sl_service} (#{sl_region}) #{sl_description} #{sl_usage} out of #{sl_limit}"
|
|
70
70
|
service_limit_msg.push(sl_msg)
|
|
71
71
|
end
|
|
72
|
-
rescue => e
|
|
72
|
+
rescue StandardError => e
|
|
73
73
|
unknown "An error occurred processing AWS TrustedAdvisor API: #{e.message}"
|
|
74
74
|
end
|
|
75
75
|
|
|
@@ -65,7 +65,7 @@ class CheckVpcNameservers < Sensu::Plugin::Check::CLI
|
|
|
65
65
|
options.dhcp_options.each do |option|
|
|
66
66
|
option.dhcp_configurations.each do |map|
|
|
67
67
|
next if map.key != 'domain-name-servers'
|
|
68
|
-
map.
|
|
68
|
+
map.each_value do |value|
|
|
69
69
|
ip = value.value
|
|
70
70
|
config[:queries].each do |query|
|
|
71
71
|
begin
|
data/bin/check-vpc-vpn.rb
CHANGED
|
@@ -65,13 +65,13 @@ class CheckAwsVpcVpnConnections < Sensu::Plugin::Check::CLI
|
|
|
65
65
|
begin
|
|
66
66
|
ec2 = Aws::EC2::Client.new
|
|
67
67
|
vpn_info = ec2.describe_vpn_connections(vpn_connection_ids: [config[:vpn_id]]).vpn_connections
|
|
68
|
-
down_connections = vpn_info.first.vgw_telemetry.
|
|
68
|
+
down_connections = vpn_info.first.vgw_telemetry.reject { |x| x.status == 'UP' }
|
|
69
69
|
results = { down_count: down_connections.count }
|
|
70
70
|
results[:down_connection_status] = down_connections.map { |x| "#{x.outside_ip_address} => #{x.status_message.empty? ? 'none' : x.status_message}" }
|
|
71
71
|
results[:connection_name] = vpn_info[0].tags.find { |x| x.key == 'Name' }.value
|
|
72
72
|
rescue Aws::EC2::Errors::ServiceError
|
|
73
73
|
warning "The vpnConnection ID '#{config[:vpn_id]}' does not exist"
|
|
74
|
-
rescue => e
|
|
74
|
+
rescue StandardError => e
|
|
75
75
|
warning e.backtrace.join(' ')
|
|
76
76
|
end
|
|
77
77
|
results
|
data/bin/handler-ec2_node.rb
CHANGED
|
@@ -184,7 +184,7 @@ class Ec2Node < Sensu::Handler
|
|
|
184
184
|
ec2 = Aws::EC2::Client.new(region: region)
|
|
185
185
|
settings['ec2_node'] = {} unless settings['ec2_node']
|
|
186
186
|
instance_states = @event['client']['ec2_states'] || settings['ec2_node']['ec2_states'] || ['shutting-down', 'terminated', 'stopping', 'stopped']
|
|
187
|
-
instance_reasons = @event['client']['ec2_state_reasons'] || settings['ec2_node']['ec2_state_reasons'] || %w
|
|
187
|
+
instance_reasons = @event['client']['ec2_state_reasons'] || settings['ec2_node']['ec2_state_reasons'] || %w[Client.UserInitiatedShutdown Server.SpotInstanceTermination Client.InstanceInitiatedShutdown]
|
|
188
188
|
|
|
189
189
|
begin
|
|
190
190
|
# Finding the instance
|
|
@@ -97,10 +97,10 @@ class AsgScaler < Sensu::Handler
|
|
|
97
97
|
resp = resp.sub(' UTC', '+00:00')
|
|
98
98
|
|
|
99
99
|
# Time of last autoscaling event
|
|
100
|
-
aws = DateTime.iso8601(resp)
|
|
100
|
+
aws = DateTime.iso8601(resp) # rubocop: disable Style/DateTime
|
|
101
101
|
|
|
102
102
|
# Current System Time
|
|
103
|
-
now = DateTime.now.new_offset(0)
|
|
103
|
+
now = DateTime.now.new_offset(0) # rubocop: disable Style/DateTime
|
|
104
104
|
diff = (now - aws).to_f # This produces time since last event in days
|
|
105
105
|
diff = diff * 24 * 60 # This produces the time since last event in minutes
|
|
106
106
|
diff > cooldown_period.to_f
|
data/bin/handler-scale-asg-up.rb
CHANGED
|
@@ -97,10 +97,10 @@ class AsgScaler < Sensu::Handler
|
|
|
97
97
|
resp = resp.sub(' UTC', '+00:00')
|
|
98
98
|
|
|
99
99
|
# Time of last autoscaling event
|
|
100
|
-
aws = DateTime.iso8601(resp)
|
|
100
|
+
aws = DateTime.iso8601(resp) # rubocop: disable Style/DateTime
|
|
101
101
|
|
|
102
102
|
# Current System Time
|
|
103
|
-
now = DateTime.now.new_offset(0)
|
|
103
|
+
now = DateTime.now.new_offset(0) # rubocop: disable Style/DateTime
|
|
104
104
|
diff = (now - aws).to_f # This produces time since last event in days
|
|
105
105
|
diff = diff * 24 * 60 # This produces the time since last event in minutes
|
|
106
106
|
diff > cooldown_period.to_f
|
data/bin/handler-sns.rb
CHANGED
data/bin/metrics-billing.rb
CHANGED
|
@@ -89,8 +89,7 @@ class BillingMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
89
89
|
)
|
|
90
90
|
output "#{config[:scheme]}.total.#{service_name}", r[:datapoints][0].maximum, r[:datapoints][0][:timestamp].to_i unless r[:datapoints][0].nil?
|
|
91
91
|
end
|
|
92
|
-
|
|
93
|
-
rescue => e
|
|
92
|
+
rescue StandardError => e
|
|
94
93
|
critical "Error: exception: #{e}"
|
|
95
94
|
end
|
|
96
95
|
ok
|
data/bin/metrics-ec2-count.rb
CHANGED
data/bin/metrics-ec2-filter.rb
CHANGED
data/bin/metrics-elasticache.rb
CHANGED
|
@@ -107,7 +107,8 @@ class ElasticMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
def run
|
|
110
|
-
|
|
110
|
+
# TODO: come back and refactor
|
|
111
|
+
elasticaches.describe_cache_clusters.cache_clusters.each do |elasticache| # rubocop:disable Metrics/BlockLength)
|
|
111
112
|
if elasticache.engine.include? 'redis'
|
|
112
113
|
if config[:statistic] == ''
|
|
113
114
|
default_statistic_per_metric = {
|
data/bin/metrics-elb-full.rb
CHANGED
|
@@ -137,7 +137,7 @@ class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
137
137
|
output graphitepath + ".#{key}", value[:sum] || value[:average], value[:timestamp].to_i
|
|
138
138
|
end
|
|
139
139
|
end
|
|
140
|
-
rescue => e
|
|
140
|
+
rescue StandardError => e
|
|
141
141
|
critical "Error: exception: #{e}"
|
|
142
142
|
end
|
|
143
143
|
ok
|
data/bin/metrics-emr-steps.rb
CHANGED
|
@@ -54,7 +54,7 @@ class EMRStepMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
54
54
|
steps.count { |step| step.status.state == status }
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
STATUS = %w
|
|
57
|
+
STATUS = %w[PENDING RUNNING COMPLETED CANCELLED FAILED INTERRUPTED].freeze
|
|
58
58
|
|
|
59
59
|
def cluster_steps(emr, cluster_id, data)
|
|
60
60
|
steps = emr.list_steps(
|
data/bin/metrics-rds.rb
CHANGED
|
@@ -132,7 +132,7 @@ class RDSMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
132
132
|
config[:scheme] + '.' + rdsname
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
statistic_type.
|
|
135
|
+
statistic_type.each_key do |key, _value|
|
|
136
136
|
r = cloud_watch_metric key, rdsname
|
|
137
137
|
result[full_scheme + '.' + key] = r[:datapoints][0] unless r[:datapoints][0].nil?
|
|
138
138
|
end
|
data/bin/metrics-s3.rb
CHANGED
|
@@ -46,6 +46,8 @@ class S3Metrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
46
46
|
long: '--scheme SCHEME',
|
|
47
47
|
default: 'sensu.aws.s3.buckets'
|
|
48
48
|
|
|
49
|
+
def bucket_size(size_size = 'bytes'); end
|
|
50
|
+
|
|
49
51
|
def run
|
|
50
52
|
begin
|
|
51
53
|
s3 = Aws::S3::Client.new(aws_config)
|
|
@@ -54,7 +56,8 @@ class S3Metrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
54
56
|
cw = Aws::CloudWatch::Client.new(aws_config)
|
|
55
57
|
|
|
56
58
|
now = Time.now
|
|
57
|
-
|
|
59
|
+
# TODO: come back and refactor this
|
|
60
|
+
list_buckets.buckets.each do |bucket| # rubocop:disable Metrics/BlockLength)
|
|
58
61
|
bucket_name = bucket.name.tr('.', '_')
|
|
59
62
|
bucket_size_bytes = cw.get_metric_statistics(
|
|
60
63
|
namespace: 'AWS/S3',
|
|
@@ -96,8 +99,7 @@ class S3Metrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
96
99
|
)
|
|
97
100
|
output "#{config[:scheme]}.#{bucket_name}.number_of_objects", number_of_objects[:datapoints][0].average, now.to_i unless number_of_objects[:datapoints][0].nil?
|
|
98
101
|
end
|
|
99
|
-
|
|
100
|
-
rescue => e
|
|
102
|
+
rescue StandardError => e
|
|
101
103
|
critical "Error: exception: #{e}"
|
|
102
104
|
end
|
|
103
105
|
ok
|