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, #storage_pools

Instance Method Details

#async_jobsObject



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 < 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



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: options[:pool_name], zone: options[:zone]).first
   # calculate overprovisioning only for network file systems
   total_size = case pool['type']
   when 'NetworkFilesystem'
      pool['disksizetotal'] * options[:over_provisioning]
   else
      pool['disksizetotal']
   end
   data = check_data(
      total_size,
      pool['disksizeallocated'].to_f,
      options[:warning],
      options[:critical]
   )
   puts "storage_pool #{options[:pool_name]} #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{pool['disksizeused']} usage_perc=#{data[1]}%"
   exit data[0]
end