Class: Check
- Inherits:
-
CloudstackNagios::Base
- Object
- Thor
- CloudstackNagios::Base
- Check
- 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
Instance Method Summary collapse
Methods inherited from CloudstackNagios::Base
Methods included from CloudstackNagios::Helper
#check_data, #cs_routers, #exit_with_failure, #load_template, #storage_pools
Instance Method Details
#async_jobs ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/cloudstack-nagios/commands/check.rb', line 77 def async_jobs jobs = client.send_request('command' => 'listAsyncJobs', 'listall' => 'true')['asyncjobs'] outstanding_jobs = jobs.select {|job| job['jobstatus'] == 0 } if outstanding_jobs.size < [:warning] code = 0 elsif outstanding_jobs.size < [:critical] code = 1 else code = 2 end puts "async_jobs #{RETURN_CODES[code]} - jobs = #{outstanding_jobs.size} | jobs=#{outstanding_jobs.size}" end |
#storage_pool ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cloudstack-nagios/commands/check.rb', line 47 def storage_pool pool = client.list_storage_pools(name: [:pool_name], zone: [:zone]).first # calculate overprovisioning only for network file systems total_size = case pool['type'] when 'NetworkFilesystem' pool['disksizetotal'] * [:over_provisioning] else pool['disksizetotal'] end data = check_data( total_size, pool['disksizeallocated'].to_f, [:warning], [:critical] ) puts "storage_pool #{[:pool_name]} #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{pool['disksizeused']} usage_perc=#{data[1]}%" exit data[0] end |