Class: NagiosConfig

Inherits:
CloudstackNagios::Base show all
Defined in:
lib/cloudstack-nagios/commands/nagios_config.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

#api_hostsObject



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

def api_hosts
  service_template = load_template(options[:template])
  puts service_template.result(
    zones: client.list_zones,
    bin_path: bin_path,
    config_file: options[:config],
    date: date_string
  )
end

#asyncjobs_servicesObject



97
98
99
100
101
102
103
104
# File 'lib/cloudstack-nagios/commands/nagios_config.rb', line 97

def asyncjobs_services
  service_template = load_template(options[:template])
  puts service_template.result(
    bin_path: bin_path,
    config_file: options[:config],
    date: date_string
  )
end

#capacity_servicesObject



82
83
84
85
86
87
88
89
90
# File 'lib/cloudstack-nagios/commands/nagios_config.rb', line 82

def capacity_services
  service_template = load_template(options[:template])
  puts service_template.result(
    capacity_types: Capacity::CAPACITY_TYPES,
    bin_path: bin_path,
    config_file: options[:config],
    date: date_string
  )
end

#generate_allObject



6
7
8
9
10
11
12
# File 'lib/cloudstack-nagios/commands/nagios_config.rb', line 6

def generate_all
  commands = %w(router_hosts router_services api_hosts storage_pool_services capacity_services asyncjobs_services)
  commands.each do |command|
    invoke "nagios_config:#{command}"
    puts
  end
end

#router_hostsObject



19
20
21
22
23
24
25
# File 'lib/cloudstack-nagios/commands/nagios_config.rb', line 19

def router_hosts
  host_template = load_template(options[:template])
  puts host_template.result(
    routers: cs_routers,
    date: date_string
  )
end

#router_servicesObject



32
33
34
35
36
37
38
39
40
# File 'lib/cloudstack-nagios/commands/nagios_config.rb', line 32

def router_services
  service_template = load_template(options[:template])
  puts service_template.result(
    routers: cs_routers,
    bin_path: bin_path,
    config_file: options[:config],
    date: date_string
  )
end

#storage_pool_servicesObject



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/cloudstack-nagios/commands/nagios_config.rb', line 63

def storage_pool_services
  service_template = load_template(options[:template])
  storage_pools = client.list_storage_pools.select do |pool| 
    pool['state'].downcase == 'up'
  end
  puts service_template.result(
    storage_pools: storage_pools,
    over_provisioning: options[:over_provisioning],
    bin_path: bin_path,
    config_file: options[:config],
    date: date_string
  )
end