Class: Check

Inherits:
CloudstackNagios::Base show all
Defined in:
lib/cloudstack-nagios/commands/check.rb

Constant Summary

Constants included from CloudstackNagios::Helper

CloudstackNagios::Helper::RETURN_CODES

Instance Attribute Summary

Attributes inherited from CloudstackNagios::Base

#config

Instance Method Summary collapse

Methods inherited from CloudstackNagios::Base

exit_on_failure?

Methods included from CloudstackNagios::Helper

#check_data, #cs_routers, #exit_with_failure, #load_template

Instance Method Details

#async_jobsObject



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/cloudstack-nagios/commands/check.rb', line 69

def async_jobs
   jobs = client.send_request('command' => 'listAsyncJobs', 'listall' => 'true')['asyncjobs']
   outstanding_jobs = jobs.select {|job| job['jobstatus'] == 0 }
   if outstanding_jobs.size < options[:warning]
     code = 0
   elsif outstanding_jobs.size < options[:critical]
     code = 1
   else 
     code = 2
   end 
   puts "async_jobs #{RETURN_CODES[code]} - jobs = #{outstanding_jobs.size} | jobs=#{outstanding_jobs.size}"
end

#storage_poolObject



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cloudstack-nagios/commands/check.rb', line 46

def storage_pool
   pool = client.list_storage_pools(name: options[:pool_name], zone: options[:zone]).first
   data = check_data(
      pool['disksizetotal'] * options[:over_provisioning],
      pool['disksizeallocated'].to_f,
      options[:warning],
      options[:critical]
   )
   puts "storage_pool #{options[:pool_name]} #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{pool['disksizeused']}"
   exit data[0]
end