bin/check-rds.rb in sensu-plugins-aws-2.4.3 vs bin/check-rds.rb in sensu-plugins-aws-3.0.0

- old
+ new

@@ -26,10 +26,13 @@ # check-rds -i sensu-admin-db --cpu-critical-over 90 --statistics maximum --period 3600 # # Warning if DatabaseConnections are over 100, critical over 120 # check-rds -i sensu-admin-db --connections-critical-over 120 --connections-warning-over 100 --statistics maximum --period 3600 # +# Warning if IOPS are over 100, critical over 200 +# check-rds -i sensu-admin-db --iops-critical-over 200 --iops-warning-over 100 --period 300 +# # Warning if memory usage is over 80%, maximum of last 2 hour # specifying "minimum" is intended actually since memory usage is calculated from CloudWatch "FreeableMemory" metric. # check-rds -i sensu-admin-db --memory-warning-over 80 --statistics minimum --period 7200 # # Disk usage, same as memory @@ -108,11 +111,11 @@ %w(warning critical).each do |severity| option :"availability_zone_#{severity}", long: "--availability-zone-#{severity} AZ", description: "Trigger a #{severity} if availability zone is different than given argument" - %w(cpu memory disk connections).each do |item| + %w(cpu memory disk connections iops).each do |item| option :"#{item}_#{severity}_over", long: "--#{item}-#{severity}-over N", proc: proc(&:to_f), description: "Trigger a #{severity} if #{item} usage is over a percentage" end @@ -244,10 +247,20 @@ @connections_metric_value ||= latest_value @connections_metric return if @connections_metric_value < expected_lower_than flag_alert severity, "; DatabaseConnections are #{sprintf '%d', @connections_metric_value} (expected lower than #{expected_lower_than})" end + def check_iops(severity, expected_lower_than) + @read_iops_metric ||= cloud_watch_metric 'ReadIOPS', 'Count/Second' + @read_iops_metric_value ||= latest_value @read_iops_metric + @write_iops_metric ||= cloud_watch_metric 'WriteIOPS', 'Count/Second' + @write_iops_metric_value ||= latest_value @write_iops_metric + @iops_metric_value ||= @read_iops_metric_value + @write_iops_metric_value + return if @iops_metric_value < expected_lower_than + flag_alert severity, "; IOPS are #{sprintf '%d', @iops_metric_value} (expected lower than #{expected_lower_than})" + end + def run if config[:db_instance_id].nil? || config[:db_instance_id].empty? unknown 'No DB instance provided. See help for usage details' end @@ -259,15 +272,15 @@ } @severities.keys.each do |severity| check_az severity, config[:"availability_zone_#{severity}"] if config[:"availability_zone_#{severity}"] - %w(cpu memory disk connections).each do |item| + %w(cpu memory disk connections iops).each do |item| send "check_#{item}", severity, config[:"#{item}_#{severity}_over"] if config[:"#{item}_#{severity}_over"] end end - if %w(cpu memory disk connections).any? { |item| %w(warning critical).any? { |severity| config[:"#{item}_#{severity}_over"] } } + if %w(cpu memory disk connections iops).any? { |item| %w(warning critical).any? { |severity| config[:"#{item}_#{severity}_over"] } } @message += "(#{config[:statistics].to_s.capitalize} within #{config[:period]}s " @message += "between #{config[:end_time] - config[:period]} to #{config[:end_time]})" end if @severities[:critical]