Class: Nagios::Splunk::CLI

Inherits:
Object
  • Object
show all
Includes:
Mixlib::CLI
Defined in:
lib/nagios/splunk/cli.rb

Instance Method Summary collapse

Instance Method Details

#run(argv = ARGV) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/nagios/splunk/cli.rb', line 39

def run(argv = ARGV)
  parse_options(argv)

  client = RestClient.new(config[:server_url])
  splunk = Check.new(client)

  begin
    if config[:pool]
      status, message = splunk.pool_usage(config[:pool], config[:warn], config[:crit])
    else
      status, message = splunk.license_usage(config[:warn], config[:crit], config[:stack_id])
    end
  rescue Nagios::Splunk::Exception => e
    message = e.message
    status = 3
  end

  puts message
  status
end