bin/check-ceph.rb in sensu-plugins-ceph-0.0.4 vs bin/check-ceph.rb in sensu-plugins-ceph-0.0.5
- old
+ new
@@ -62,10 +62,16 @@
description: 'Optional cluster name',
short: '-c NAME',
long: '--cluster',
proc: proc { |c| " --cluster=#{c}" }
+ option :name,
+ description: 'Optional client name',
+ short: '-n NAME',
+ long: '--name',
+ proc: proc { |n| " --name=#{n}" }
+
option :timeout,
description: 'Timeout (default 10)',
short: '-t SEC',
long: '--timeout',
proc: proc(&:to_i),
@@ -89,16 +95,17 @@
short: '-o',
long: '--osd-tree',
boolean: true,
default: false
- def run_cmd(cmd) # rubocop:disable all
+ def run_cmd(cmd)
pipe, status = nil
begin
cmd += config[:cluster] if config[:cluster]
cmd += config[:keyring] if config[:keyring]
cmd += config[:monitor] if config[:monitor]
+ cmd += config[:name] if config[:name]
cmd += ' 2>&1'
Timeout.timeout(config[:timeout]) do
pipe = IO.popen(cmd)
Process.wait(pipe.pid)
status = $CHILD_STATUS.exitstatus
@@ -134,10 +141,10 @@
else
result
end
end
- def run # rubocop:disable all
+ def run
result = check_ceph_health
ok result if result.start_with?('HEALTH_OK')
result = strip_warns(result) if config[:ignore_flags]
result += run_cmd('ceph osd tree') if config[:osd_tree]