bin/check-redis-memory.rb in sensu-plugins-redis-1.4.0 vs bin/check-redis-memory.rb in sensu-plugins-redis-2.0.0
- old
+ new
@@ -50,15 +50,15 @@
long: '--critmem KB',
description: "Allocated KB of Redis memory on which we'll issue a CRITICAL",
proc: proc(&:to_i),
required: true
- option :crit_conn,
- long: '--crit-conn-failure',
- boolean: true,
- description: 'Critical instead of warning on connection failure',
- default: false
+ option :conn_failure_status,
+ long: '--conn-failure-status EXIT_STATUS',
+ description: 'Returns the following exit status for Redis connection failures',
+ default: 'unknown',
+ in: %w(unknown warning critical)
def run
options = if config[:socket]
{ path: socket }
else
@@ -77,13 +77,8 @@
warning "Redis running on #{config[:host]}:#{config[:port]} is above the WARNING limit: #{used_memory}KB used / #{warn_memory}KB limit"
else
ok "Redis memory usage: #{used_memory}KB is below defined limits"
end
rescue
- message = "Could not connect to Redis server on #{config[:host]}:#{config[:port]}"
- if config[:crit_conn]
- critical message
- else
- warning message
- end
+ send(config[:conn_failure_status], "Could not connect to Redis server on #{config[:host]}:#{config[:port]}")
end
end