bin/check-rds.rb in sensu-plugins-aws-0.0.1.alpha.2 vs bin/check-rds.rb in sensu-plugins-aws-0.0.1
- old
+ new
@@ -41,11 +41,10 @@
# Copyright 2014 github.com/y13i
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.
#
-require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'sensu-plugin/check/cli'
require 'aws-sdk'
require 'time'
class CheckRDS < Sensu::Plugin::Check::CLI
@@ -187,33 +186,33 @@
return if @db_instance.availability_zone_name == expected_az
flag_alert severity, "; AZ is #{@db_instance.availability_zone_name} (expected #{expected_az})"
end
def check_cpu(severity, expected_lower_than)
- @cpu_metric ||= cloud_watch_metric 'CPUUtilization'
+ @cpu_metric ||= cloud_watch_metric 'CPUUtilization'
@cpu_metric_value ||= latest_value @cpu_metric, 'Percent'
return if @cpu_metric_value < expected_lower_than
- flag_alert severity, "; CPUUtilization is #{sprintf '%.2f', @cpu_metric_value}% (expected lower than #{expected_lower_than}%)"
+ flag_alert severity, "; CPUUtilization is #{sprintf '%.2f', @cpu_metric_value}% (expected lower than #{expected_lower_than}%)" # rubocop:disable all
end
def check_memory(severity, expected_lower_than)
- @memory_metric ||= cloud_watch_metric 'FreeableMemory'
- @memory_metric_value ||= latest_value @memory_metric, 'Bytes'
- @memory_total_bytes ||= memory_total_bytes @db_instance.db_instance_class
- @memory_usage_bytes ||= @memory_total_bytes - @memory_metric_value
+ @memory_metric ||= cloud_watch_metric 'FreeableMemory'
+ @memory_metric_value ||= latest_value @memory_metric, 'Bytes'
+ @memory_total_bytes ||= memory_total_bytes @db_instance.db_instance_class
+ @memory_usage_bytes ||= @memory_total_bytes - @memory_metric_value
@memory_usage_percentage ||= @memory_usage_bytes / @memory_total_bytes * 100
return if @memory_usage_percentage < expected_lower_than
- flag_alert severity, "; Memory usage is #{sprintf '%.2f', @memory_usage_percentage}% (expected lower than #{expected_lower_than}%)"
+ flag_alert severity, "; Memory usage is #{sprintf '%.2f', @memory_usage_percentage}% (expected lower than #{expected_lower_than}%)" # rubocop:disable all
end
def check_disk(severity, expected_lower_than)
- @disk_metric ||= cloud_watch_metric 'FreeStorageSpace'
- @disk_metric_value ||= latest_value @disk_metric, 'Bytes'
- @disk_total_bytes ||= @db_instance.allocated_storage * 1024**3
- @disk_usage_bytes ||= @disk_total_bytes - @disk_metric_value
+ @disk_metric ||= cloud_watch_metric 'FreeStorageSpace'
+ @disk_metric_value ||= latest_value @disk_metric, 'Bytes'
+ @disk_total_bytes ||= @db_instance.allocated_storage * 1024**3
+ @disk_usage_bytes ||= @disk_total_bytes - @disk_metric_value
@disk_usage_percentage ||= @disk_usage_bytes / @disk_total_bytes * 100
return if @disk_usage_percentage < expected_lower_than
- flag_alert severity, "; Disk usage is #{sprintf '%.2f', @disk_usage_percentage}% (expected lower than #{expected_lower_than}%)"
+ flag_alert severity, "; Disk usage is #{sprintf '%.2f', @disk_usage_percentage}% (expected lower than #{expected_lower_than}%)" # rubocop:disable all
end
def run
if config[:db_instance_id].nil? || config[:db_instance_id].empty?
unknown 'No DB instance provided. See help for usage details'