cloudstack-nagios 0.14.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.ruby-version +1 -0
- data/Gemfile.lock +5 -5
- data/README.md +16 -3
- data/cloudstack-nagios.gemspec +3 -3
- data/lib/cloudstack-nagios/commands/check.rb +8 -7
- data/lib/cloudstack-nagios/commands/nagios_config.rb +4 -2
- data/lib/cloudstack-nagios/commands/router.rb +3 -127
- data/lib/cloudstack-nagios/commands/system_vm.rb +191 -0
- data/lib/cloudstack-nagios/helper.rb +4 -0
- data/lib/cloudstack-nagios/templates/cloudstack_system_vm_hosts.cfg.erb +15 -0
- data/lib/cloudstack-nagios/templates/cloudstack_system_vm_services.cfg.erb +84 -0
- data/lib/cloudstack-nagios/version.rb +1 -1
- metadata +50 -30
- checksums.yaml +0 -7
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p392
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cloudstack-nagios (0.
|
5
|
-
cloudstack_client (~> 0.
|
4
|
+
cloudstack-nagios (0.15.0)
|
5
|
+
cloudstack_client (~> 0.7, >= 0.7.1)
|
6
6
|
erubis (~> 2.7.0)
|
7
7
|
highline (~> 1.6.20)
|
8
8
|
sshkit (~> 1.3.0)
|
@@ -11,7 +11,7 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
cloudstack_client (0.
|
14
|
+
cloudstack_client (0.7.1)
|
15
15
|
erubis (2.7.0)
|
16
16
|
highline (1.6.21)
|
17
17
|
json (1.8.1)
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
net-ssh (>= 2.6.5)
|
20
20
|
net-ssh (2.9.1)
|
21
21
|
rake (10.3.2)
|
22
|
-
rdoc (4.1.
|
22
|
+
rdoc (4.1.2)
|
23
23
|
json (~> 1.4)
|
24
24
|
sshkit (1.3.0)
|
25
25
|
net-scp (>= 1.1.2)
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
term-ansicolor (1.3.0)
|
29
29
|
tins (~> 1.0)
|
30
30
|
thor (0.19.1)
|
31
|
-
tins (1.3.
|
31
|
+
tins (1.3.3)
|
32
32
|
|
33
33
|
PLATFORMS
|
34
34
|
ruby
|
data/README.md
CHANGED
@@ -76,6 +76,8 @@ hostgroups
|
|
76
76
|
zone_hosts
|
77
77
|
router_hosts
|
78
78
|
router_services
|
79
|
+
system_vm_hosts
|
80
|
+
system_vm_services
|
79
81
|
capacities
|
80
82
|
async_jobs
|
81
83
|
storage_pools
|
@@ -85,22 +87,33 @@ storage_pools
|
|
85
87
|
|
86
88
|
For all vm checks access to the cloudstack management network is required in order to run the ckecks via ssh or snmp.
|
87
89
|
|
88
|
-
####
|
90
|
+
#### Types
|
91
|
+
|
92
|
+
cloudstack-nagios differentiates between 2 different types of system vm's:
|
93
|
+
* routers: `cs-nagios check router`
|
94
|
+
* secondary storage vms and console proxies: `cs-nagios check system_vm`
|
95
|
+
|
96
|
+
#### Checks
|
89
97
|
|
90
98
|
The following checks are available:
|
91
99
|
|
100
|
+
General Checks
|
92
101
|
* memory - measure memory usage in percents
|
93
102
|
* cpu - measure cpu usage in percent
|
94
103
|
* network - measure network usage
|
95
|
-
*
|
104
|
+
* fs_rw - check if the root file system is writeable
|
105
|
+
* rootfs_rw - check if the root file system is writeable (wrapper for fs_rw with mount point /)
|
96
106
|
* disk_usage - check the diks space usage of the root volume
|
107
|
+
|
108
|
+
Checks for routers
|
97
109
|
* conntrack_connections, check the number of conntrack connections and set proper limits if needed
|
98
110
|
* active_ftp - make sure conntrack_ftp and nf_nat_ftp modules are loaded and enable it if needed
|
99
111
|
|
100
|
-
|
112
|
+
Examples:
|
101
113
|
|
102
114
|
```sh
|
103
115
|
$ cs-nagios check system_vm network --host 10.100.9.161
|
116
|
+
$ cs-nagios check router active_ftp --host 10.100.9.177
|
104
117
|
```
|
105
118
|
|
106
119
|
#### Enabling snmpd checks for system vms
|
data/cloudstack-nagios.gemspec
CHANGED
@@ -22,10 +22,10 @@ Gem::Specification.new do |gem|
|
|
22
22
|
|
23
23
|
gem.add_development_dependency('rdoc')
|
24
24
|
gem.add_development_dependency('rake', '~> 10.3.1')
|
25
|
-
|
26
|
-
gem.add_dependency('cloudstack_client', '~> 0.
|
25
|
+
|
26
|
+
gem.add_dependency('cloudstack_client', '~> 0.7', '>= 0.7.1')
|
27
27
|
gem.add_dependency('thor', '~> 0.19.1')
|
28
28
|
gem.add_dependency('erubis', '~> 2.7.0')
|
29
29
|
gem.add_dependency('sshkit', '~> 1.3.0')
|
30
30
|
gem.add_dependency('highline', '~> 1.6.20')
|
31
|
-
end
|
31
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "cloudstack-nagios/commands/system_vm"
|
1
2
|
require "cloudstack-nagios/commands/router"
|
2
3
|
require "cloudstack-nagios/commands/capacity"
|
3
4
|
|
@@ -33,13 +34,13 @@ class Check < CloudstackNagios::Base
|
|
33
34
|
desc "router SUBCOMMAND ...ARGS", "router checks"
|
34
35
|
subcommand :router, Router
|
35
36
|
|
36
|
-
desc "
|
37
|
-
subcommand :
|
37
|
+
desc "system_vm SUBCOMMAND ...ARGS", "system vm checks"
|
38
|
+
subcommand :system_vm, SystemVm
|
38
39
|
|
39
|
-
desc "
|
40
|
+
desc "capacity SUBCOMMAND ...ARGS", "capacity checks"
|
40
41
|
subcommand :capacity, Capacity
|
41
42
|
|
42
|
-
desc "
|
43
|
+
desc "storage_pool", "check capacity of storage_pool"
|
43
44
|
option :pool_name, required: true
|
44
45
|
option :zone
|
45
46
|
option :over_provisioning, type: :numeric, default: 1.0,
|
@@ -81,9 +82,9 @@ class Check < CloudstackNagios::Base
|
|
81
82
|
code = 0
|
82
83
|
elsif outstanding_jobs.size < options[:critical]
|
83
84
|
code = 1
|
84
|
-
else
|
85
|
+
else
|
85
86
|
code = 2
|
86
|
-
end
|
87
|
+
end
|
87
88
|
puts "async_jobs #{RETURN_CODES[code]} - jobs = #{outstanding_jobs.size} | jobs=#{outstanding_jobs.size}"
|
88
89
|
end
|
89
|
-
end
|
90
|
+
end
|
@@ -31,6 +31,7 @@ class NagiosConfig < CloudstackNagios::Base
|
|
31
31
|
end
|
32
32
|
|
33
33
|
routers = configs.include?("router_hosts") ? cs_routers : nil
|
34
|
+
system_vms = configs.include?("system_vm_hosts") ? cs_system_vms : nil
|
34
35
|
pools = configs.include?("storage_pools") ? storage_pools : nil
|
35
36
|
zones = client.list_zones
|
36
37
|
config_name = configs.size == 1 ?
|
@@ -51,6 +52,7 @@ class NagiosConfig < CloudstackNagios::Base
|
|
51
52
|
template = load_template(tmpl_file)
|
52
53
|
output += template.result(
|
53
54
|
routers: routers,
|
55
|
+
system_vms: system_vms,
|
54
56
|
bin_path: bin_path,
|
55
57
|
if_speed: options[:if_speed],
|
56
58
|
config_file: options[:config],
|
@@ -78,7 +80,7 @@ class NagiosConfig < CloudstackNagios::Base
|
|
78
80
|
no_commands do
|
79
81
|
|
80
82
|
def get_configs(configs = [])
|
81
|
-
all_configs = %w(hostgroups zone_hosts router_hosts router_services capacities async_jobs storage_pools)
|
83
|
+
all_configs = %w(hostgroups zone_hosts router_hosts router_services system_vm_hosts system_vm_services capacities async_jobs storage_pools)
|
82
84
|
if configs.size == 0
|
83
85
|
return all_configs
|
84
86
|
else
|
@@ -102,4 +104,4 @@ class NagiosConfig < CloudstackNagios::Base
|
|
102
104
|
end
|
103
105
|
end
|
104
106
|
|
105
|
-
end
|
107
|
+
end
|
@@ -1,117 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "cloudstack-nagios/commands/system_vm"
|
2
2
|
|
3
|
-
class Router <
|
4
|
-
|
5
|
-
desc "memory HOST", "check memory on host"
|
6
|
-
def memory
|
7
|
-
begin
|
8
|
-
host = systemvm_host
|
9
|
-
free_output = ""
|
10
|
-
on host do |h|
|
11
|
-
free_output = capture(:free)
|
12
|
-
end
|
13
|
-
values = free_output.scan(/\d+/)
|
14
|
-
total = values[0].to_i
|
15
|
-
free = values[2].to_i
|
16
|
-
free_b = values[7].to_i
|
17
|
-
data = check_data(total, total - free_b, options[:warning], options[:critical])
|
18
|
-
puts "MEMORY #{RETURN_CODES[data[0]]} - usage = #{data[1]}% (#{((total - free_b)/1024.0).round(0)}/#{(total/1024.0).round(0)}MB) | \
|
19
|
-
usage=#{data[1]}% total=#{total}M free=#{free}M free_wo_buffers=#{free_b}M".gsub(/\s+/, " ")
|
20
|
-
exit data[0]
|
21
|
-
rescue => e
|
22
|
-
exit_with_failure(e)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
desc "cpu", "check memory on host"
|
27
|
-
def cpu
|
28
|
-
begin
|
29
|
-
host = systemvm_host
|
30
|
-
mpstat_output = ""
|
31
|
-
on host do |h|
|
32
|
-
mpstat_output = capture(:mpstat)
|
33
|
-
end
|
34
|
-
values = mpstat_output.scan(/\d+\.\d+/)
|
35
|
-
usage = 100 - values[-1].to_f
|
36
|
-
data = check_data(100, usage, options[:warning], options[:critical])
|
37
|
-
puts "CPU #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{data[1]}%"
|
38
|
-
exit data[0]
|
39
|
-
rescue => e
|
40
|
-
exit_with_failure(e)
|
41
|
-
end
|
42
|
-
end
|
3
|
+
class Router < SystemVm
|
43
4
|
|
44
5
|
desc "rootfs_rw", "check if the rootfs is read/writeable on host"
|
45
6
|
def rootfs_rw
|
46
|
-
|
47
|
-
host = systemvm_host
|
48
|
-
test_file = '/rootdiskcheck.txt'
|
49
|
-
rootfs_rw = false
|
50
|
-
on host do |h|
|
51
|
-
rootfs_rw = execute(:touch, test_file)
|
52
|
-
execute(:rm, '-f', test_file)
|
53
|
-
end
|
54
|
-
rescue SSHKit::Command::Failed
|
55
|
-
rootfs_rw = false
|
56
|
-
rescue => e
|
57
|
-
exit_with_failure(e)
|
58
|
-
end
|
59
|
-
status = rootfs_rw ? 0 : 2
|
60
|
-
puts "ROOTFS_RW #{rootfs_rw ? 'OK - rootfs writeable' : 'CRITICAL - rootfs NOT writeable'}"
|
61
|
-
exit status
|
62
|
-
end
|
63
|
-
|
64
|
-
desc "disk_usage", "check the disk space usage of the root volume"
|
65
|
-
option :partition, desc: "The partition to check", default: '/', aliases: '-P'
|
66
|
-
def disk_usage
|
67
|
-
begin
|
68
|
-
host = systemvm_host
|
69
|
-
partition = options[:partition]
|
70
|
-
proc_out = ""
|
71
|
-
on host do |h|
|
72
|
-
proc_out = capture(:df, '-l', partition)
|
73
|
-
end
|
74
|
-
match = proc_out.match(/.*\s(\d+)%\s.*/)
|
75
|
-
if match
|
76
|
-
usage = match[1]
|
77
|
-
data = check_data(100, usage, options[:warning], options[:critical])
|
78
|
-
puts "DISK_USAGE #{RETURN_CODES[data[0]]} (Partition #{options[:partition]}) - usage = #{data[1]}% | usage=#{data[1]}%"
|
79
|
-
exit data[0]
|
80
|
-
else
|
81
|
-
puts "DISK_USAGE UNKNOWN"
|
82
|
-
end
|
83
|
-
rescue => e
|
84
|
-
exit_with_failure(e)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
desc "network", "check network usage on host"
|
89
|
-
option :interface,
|
90
|
-
desc: 'network interface to probe',
|
91
|
-
default: 'eth0',
|
92
|
-
aliases: '-i'
|
93
|
-
option :if_speed,
|
94
|
-
desc: 'network interface speed in bits per second',
|
95
|
-
type: :numeric,
|
96
|
-
default: 1000000,
|
97
|
-
aliases: '-s'
|
98
|
-
def network
|
99
|
-
begin
|
100
|
-
host = systemvm_host
|
101
|
-
stats_path = "/sys/class/net/#{options[:interface]}/statistics"
|
102
|
-
rx_bytes, tx_bytes = ""
|
103
|
-
on host do |h|
|
104
|
-
rx_bytes = capture("cat #{stats_path}/rx_bytes;sleep 1;cat #{stats_path}/rx_bytes").lines.to_a
|
105
|
-
tx_bytes = capture("cat #{stats_path}/tx_bytes;sleep 1;cat #{stats_path}/tx_bytes").lines.to_a
|
106
|
-
end
|
107
|
-
rbps = (rx_bytes[1].to_i - rx_bytes[0].to_i) * 8
|
108
|
-
tbps = (tx_bytes[1].to_i - tx_bytes[0].to_i) * 8
|
109
|
-
data = check_data(options[:if_speed], rbps, options[:warning], options[:critical])
|
110
|
-
puts "NETWORK #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{data[1]}% rxbps=#{rbps.round(0)} txbps=#{tbps.round(0)}"
|
111
|
-
exit data[0]
|
112
|
-
rescue => e
|
113
|
-
exit_with_failure(e)
|
114
|
-
end
|
7
|
+
invoke :fs_rw
|
115
8
|
end
|
116
9
|
|
117
10
|
desc "conntrack_connections", "check the number of conntrack connections"
|
@@ -168,21 +61,4 @@ class Router < CloudstackNagios::Base
|
|
168
61
|
exit status
|
169
62
|
end
|
170
63
|
|
171
|
-
no_commands do
|
172
|
-
|
173
|
-
def systemvm_host
|
174
|
-
unless options[:host]
|
175
|
-
say "Error: --host/-H option is required for this check.", :red
|
176
|
-
exit 1
|
177
|
-
end
|
178
|
-
# suppress sshkit output to stdout
|
179
|
-
SSHKit.config.output_verbosity = Logger::FATAL
|
180
|
-
host = SSHKit::Host.new("root@#{options[:host]}")
|
181
|
-
host.ssh_options = sshoptions(options[:ssh_key])
|
182
|
-
host.port = options[:ssh_port]
|
183
|
-
host
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
187
|
-
|
188
64
|
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'sshkit/dsl'
|
2
|
+
|
3
|
+
class SystemVm < CloudstackNagios::Base
|
4
|
+
|
5
|
+
desc "memory HOST", "check memory on host"
|
6
|
+
def memory
|
7
|
+
begin
|
8
|
+
host = systemvm_host
|
9
|
+
free_output = ""
|
10
|
+
on host do |h|
|
11
|
+
free_output = capture(:free)
|
12
|
+
end
|
13
|
+
values = free_output.scan(/\d+/)
|
14
|
+
total = values[0].to_i
|
15
|
+
free = values[2].to_i
|
16
|
+
free_b = values[7].to_i
|
17
|
+
data = check_data(total, total - free_b, options[:warning], options[:critical])
|
18
|
+
puts "MEMORY #{RETURN_CODES[data[0]]} - usage = #{data[1]}% (#{((total - free_b)/1024.0).round(0)}/#{(total/1024.0).round(0)}MB) | \
|
19
|
+
usage=#{data[1]}% total=#{total}M free=#{free}M free_wo_buffers=#{free_b}M".gsub(/\s+/, " ")
|
20
|
+
exit data[0]
|
21
|
+
rescue => e
|
22
|
+
exit_with_failure(e)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "cpu", "check memory on host"
|
27
|
+
def cpu
|
28
|
+
begin
|
29
|
+
host = systemvm_host
|
30
|
+
mpstat_output = ""
|
31
|
+
on host do |h|
|
32
|
+
mpstat_output = capture(:mpstat)
|
33
|
+
end
|
34
|
+
values = mpstat_output.scan(/\d+\.\d+/)
|
35
|
+
usage = 100 - values[-1].to_f
|
36
|
+
data = check_data(100, usage, options[:warning], options[:critical])
|
37
|
+
puts "CPU #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{data[1]}%"
|
38
|
+
exit data[0]
|
39
|
+
rescue => e
|
40
|
+
exit_with_failure(e)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "fs_rw", "check if the rootfs is read/writeable on host"
|
45
|
+
option :mount_point, desc: "The mount point to check", default: '/', aliases: '-m'
|
46
|
+
def fs_rw
|
47
|
+
begin
|
48
|
+
host = systemvm_host
|
49
|
+
test_file = File.join(options[:mount_point], 'rootdiskcheck.txt')
|
50
|
+
fs_rw = false
|
51
|
+
on host do |h|
|
52
|
+
fs_rw = execute(:touch, test_file)
|
53
|
+
execute(:rm, '-f', test_file)
|
54
|
+
end
|
55
|
+
rescue SSHKit::Command::Failed
|
56
|
+
fs_rw = false
|
57
|
+
rescue => e
|
58
|
+
exit_with_failure(e)
|
59
|
+
end
|
60
|
+
status = fs_rw ? 0 : 2
|
61
|
+
puts "FS_RW #{fs_rw ?
|
62
|
+
"OK - file system (#{options[:mount_point]}) writeable" :
|
63
|
+
"CRITICAL - file system (#{options[:mount_point]}) NOT writeable"}"
|
64
|
+
exit status
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "disk_usage", "check the disk space usage of the root volume"
|
68
|
+
option :partition, desc: "The partition to check", default: '/', aliases: '-P'
|
69
|
+
def disk_usage
|
70
|
+
begin
|
71
|
+
host = systemvm_host
|
72
|
+
partition = options[:partition]
|
73
|
+
proc_out = ""
|
74
|
+
on host do |h|
|
75
|
+
proc_out = capture(:df, '-l', partition)
|
76
|
+
end
|
77
|
+
match = proc_out.match(/.*\s(\d+)%\s.*/)
|
78
|
+
if match
|
79
|
+
usage = match[1]
|
80
|
+
data = check_data(100, usage, options[:warning], options[:critical])
|
81
|
+
puts "DISK_USAGE #{RETURN_CODES[data[0]]} (Partition #{options[:partition]}) - usage = #{data[1]}% | usage=#{data[1]}%"
|
82
|
+
exit data[0]
|
83
|
+
else
|
84
|
+
puts "DISK_USAGE UNKNOWN"
|
85
|
+
end
|
86
|
+
rescue => e
|
87
|
+
exit_with_failure(e)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
desc "network", "check network usage on host"
|
92
|
+
option :interface,
|
93
|
+
desc: 'network interface to probe',
|
94
|
+
default: 'eth0',
|
95
|
+
aliases: '-i'
|
96
|
+
option :if_speed,
|
97
|
+
desc: 'network interface speed in bits per second',
|
98
|
+
type: :numeric,
|
99
|
+
default: 1000000,
|
100
|
+
aliases: '-s'
|
101
|
+
def network
|
102
|
+
begin
|
103
|
+
host = systemvm_host
|
104
|
+
stats_path = "/sys/class/net/#{options[:interface]}/statistics"
|
105
|
+
rx_bytes, tx_bytes = ""
|
106
|
+
on host do |h|
|
107
|
+
rx_bytes = capture("cat #{stats_path}/rx_bytes;sleep 1;cat #{stats_path}/rx_bytes").lines.to_a
|
108
|
+
tx_bytes = capture("cat #{stats_path}/tx_bytes;sleep 1;cat #{stats_path}/tx_bytes").lines.to_a
|
109
|
+
end
|
110
|
+
rbps = (rx_bytes[1].to_i - rx_bytes[0].to_i) * 8
|
111
|
+
tbps = (tx_bytes[1].to_i - tx_bytes[0].to_i) * 8
|
112
|
+
data = check_data(options[:if_speed], rbps, options[:warning], options[:critical])
|
113
|
+
puts "NETWORK #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{data[1]}% rxbps=#{rbps.round(0)} txbps=#{tbps.round(0)}"
|
114
|
+
exit data[0]
|
115
|
+
rescue => e
|
116
|
+
exit_with_failure(e)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
desc "conntrack_connections", "check the number of conntrack connections"
|
121
|
+
def conntrack_connections
|
122
|
+
begin
|
123
|
+
host = systemvm_host
|
124
|
+
default_max = 1000000
|
125
|
+
netfilter_path = "/proc/sys/net/netfilter/"
|
126
|
+
current, max = 0
|
127
|
+
on host do |h|
|
128
|
+
max = capture("cat #{netfilter_path}nf_conntrack_max").to_i
|
129
|
+
current = capture("cat #{netfilter_path}nf_conntrack_count").to_i
|
130
|
+
end
|
131
|
+
if max < default_max
|
132
|
+
on host do |h|
|
133
|
+
execute :echo, "#{default_max} > #{netfilter_path}nf_conntrack_max"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
data = check_data(max, current, options[:warning], options[:critical])
|
137
|
+
puts "CONNTRACK_CONNECTIONS #{RETURN_CODES[data[0]]} - usage = #{data[1]}% (#{current.round(0)}/#{max.round(0)}) | usage=#{data[1]}% current=#{current.round(0)} max=#{max.round(0)}"
|
138
|
+
exit data[0]
|
139
|
+
rescue => e
|
140
|
+
exit_with_failure(e)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
desc "active_ftp", "make sure conntrack_ftp and nf_nat_ftp modules are loaded"
|
145
|
+
def active_ftp
|
146
|
+
begin
|
147
|
+
host = systemvm_host
|
148
|
+
active_ftp_enabled = false
|
149
|
+
modules = %w(nf_conntrack_ftp, nf_nat_ftp)
|
150
|
+
on host do |h|
|
151
|
+
lsmod = capture(:lsmod)
|
152
|
+
active_ftp_enabled = lsmod.include?('nf_conntrack_ftp') &&
|
153
|
+
lsmod.include?('nf_nat_ftp')
|
154
|
+
unless active_ftp_enabled
|
155
|
+
# load the modules in the kernel
|
156
|
+
execute(:modprobe, 'nf_conntrack_ftp')
|
157
|
+
execute(:modprobe, 'nf_nat_ftp')
|
158
|
+
# load the modules at next server boot
|
159
|
+
execute(:echo, '"nf_conntrack_ftp" >> /etc/modules')
|
160
|
+
execute(:echo, '"nf_nat_ftp" >> /etc/modules')
|
161
|
+
active_ftp_enabled = true
|
162
|
+
end
|
163
|
+
end
|
164
|
+
rescue SSHKit::Command::Failed
|
165
|
+
active_ftp_enabled = false
|
166
|
+
rescue => e
|
167
|
+
exit_with_failure(e)
|
168
|
+
end
|
169
|
+
status = active_ftp_enabled ? 0 : 2
|
170
|
+
puts "ACTIVE_FTP #{active_ftp_enabled ? 'OK - active_ftp enabled' : 'CRITICAL - active_ftp NOT enabled'}"
|
171
|
+
exit status
|
172
|
+
end
|
173
|
+
|
174
|
+
no_commands do
|
175
|
+
|
176
|
+
def systemvm_host
|
177
|
+
unless options[:host]
|
178
|
+
say "Error: --host/-H option is required for this check.", :red
|
179
|
+
exit 1
|
180
|
+
end
|
181
|
+
# suppress sshkit output to stdout
|
182
|
+
SSHKit.config.output_verbosity = Logger::FATAL
|
183
|
+
host = SSHKit::Host.new("root@#{options[:host]}")
|
184
|
+
host.ssh_options = sshoptions(options[:ssh_key])
|
185
|
+
host.port = options[:ssh_port]
|
186
|
+
host
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
@@ -18,6 +18,10 @@ module CloudstackNagios
|
|
18
18
|
routers += client.list_routers(projectid: -1, status: 'Running')
|
19
19
|
end
|
20
20
|
|
21
|
+
def cs_system_vms
|
22
|
+
vms = client.list_system_vms
|
23
|
+
end
|
24
|
+
|
21
25
|
def storage_pools
|
22
26
|
storage_pools = client.list_storage_pools.select do |pool|
|
23
27
|
pool['state'].downcase == 'up'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
<% system_vms.each do |vm| -%>
|
3
|
+
<% if vm['privateip'] -%>
|
4
|
+
define host {
|
5
|
+
host_name <%= vm['name'] %>
|
6
|
+
display_name <%= vm['name'] %> (<%= vm['privateip'] %>) - <%= vm['zonename'] %>
|
7
|
+
address <%= vm['privateip'] %>
|
8
|
+
use Linux-Host,host-pnp
|
9
|
+
hostgroups CloudstackSystemVm
|
10
|
+
check_command check-host-alive
|
11
|
+
register 1
|
12
|
+
}
|
13
|
+
|
14
|
+
<% end -%>
|
15
|
+
<% end -%>
|
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
define command {
|
3
|
+
command_name cs-nagios_check_systemvm-memory
|
4
|
+
command_line <%= bin_path -%>cs-nagios check system_vm memory -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
|
5
|
+
register 1
|
6
|
+
}
|
7
|
+
|
8
|
+
define command {
|
9
|
+
command_name cs-nagios_check_systemvm-cpu
|
10
|
+
command_line <%= bin_path -%>cs-nagios check system_vm cpu -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
|
11
|
+
register 1
|
12
|
+
}
|
13
|
+
|
14
|
+
define command {
|
15
|
+
command_name cs-nagios_check_systemvm-network
|
16
|
+
command_line <%= bin_path -%>cs-nagios check system_vm network -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --if-speed <%= if_speed %> --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
|
17
|
+
register 1
|
18
|
+
}
|
19
|
+
|
20
|
+
define command {
|
21
|
+
command_name cs-nagios_check_systemvm-fsrw
|
22
|
+
command_line <%= bin_path -%>cs-nagios check system_vm fs_rw -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
|
23
|
+
register 1
|
24
|
+
}
|
25
|
+
|
26
|
+
define command {
|
27
|
+
command_name cs-nagios_check_systemvm-diskusage
|
28
|
+
command_line <%= bin_path -%>cs-nagios check system_vm disk_usage -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -P $ARG3$ --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
|
29
|
+
register 1
|
30
|
+
}
|
31
|
+
|
32
|
+
define service {
|
33
|
+
hostgroup_name CloudstackSystemVm
|
34
|
+
service_description Cloudstack Virtual System VM Memory
|
35
|
+
display_name Cloudstack Virtual System VM Memory
|
36
|
+
use Generic-Service,service-pnp
|
37
|
+
check_command cs-nagios_check_systemvm-memory!80!90
|
38
|
+
register 1
|
39
|
+
}
|
40
|
+
|
41
|
+
define service {
|
42
|
+
hostgroup_name CloudstackSystemVm
|
43
|
+
service_description Cloudstack Virtual System VM CPU
|
44
|
+
display_name Cloudstack Virtual System VM CPU
|
45
|
+
use Generic-Service,service-pnp
|
46
|
+
check_command cs-nagios_check_systemvm-cpu!80!90
|
47
|
+
register 1
|
48
|
+
}
|
49
|
+
|
50
|
+
define service {
|
51
|
+
hostgroup_name CloudstackSystemVm
|
52
|
+
service_description Cloudstack Virtual System VM Network
|
53
|
+
display_name Cloudstack Virtual System VM Network
|
54
|
+
use Generic-Service,service-pnp
|
55
|
+
check_command cs-nagios_check_systemvm-network!80!90
|
56
|
+
register 1
|
57
|
+
}
|
58
|
+
|
59
|
+
define service {
|
60
|
+
hostgroup_name CloudstackSystemVm
|
61
|
+
service_description Cloudstack Virtual System VM RootFS rw
|
62
|
+
display_name Cloudstack Virtual System VM RootFS rw
|
63
|
+
use Generic-Service,service-pnp
|
64
|
+
check_command cs-nagios_check_systemvm-rootfsrw!80!90
|
65
|
+
register 1
|
66
|
+
}
|
67
|
+
|
68
|
+
define service {
|
69
|
+
hostgroup_name CloudstackSystemVm
|
70
|
+
service_description Cloudstack Virtual System VM DiskUsageRoot
|
71
|
+
display_name Cloudstack Virtual System VM DiskUsage Root
|
72
|
+
use Generic-Service,service-pnp
|
73
|
+
check_command cs-nagios_check_systemvm-diskusage!80!90!/
|
74
|
+
register 1
|
75
|
+
}
|
76
|
+
|
77
|
+
define service {
|
78
|
+
hostgroup_name CloudstackSystemVm
|
79
|
+
service_description Cloudstack Virtual System VMDiskUsageVar
|
80
|
+
display_name Cloudstack Virtual System VM DiskUsage Var
|
81
|
+
use Generic-Service,service-pnp
|
82
|
+
check_command cs-nagios_check_systemvm-diskusage!80!90!/var
|
83
|
+
register 1
|
84
|
+
}
|
metadata
CHANGED
@@ -1,117 +1,132 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudstack-nagios
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Nik Wolfgramm
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rdoc
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: 10.3.1
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: 10.3.1
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: cloudstack_client
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
48
|
-
- -
|
53
|
+
version: '0.7'
|
54
|
+
- - ! '>='
|
49
55
|
- !ruby/object:Gem::Version
|
50
|
-
version: 0.
|
56
|
+
version: 0.7.1
|
51
57
|
type: :runtime
|
52
58
|
prerelease: false
|
53
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
54
61
|
requirements:
|
55
|
-
- -
|
62
|
+
- - ~>
|
56
63
|
- !ruby/object:Gem::Version
|
57
|
-
version: '0.
|
58
|
-
- -
|
64
|
+
version: '0.7'
|
65
|
+
- - ! '>='
|
59
66
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.
|
67
|
+
version: 0.7.1
|
61
68
|
- !ruby/object:Gem::Dependency
|
62
69
|
name: thor
|
63
70
|
requirement: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
64
72
|
requirements:
|
65
|
-
- -
|
73
|
+
- - ~>
|
66
74
|
- !ruby/object:Gem::Version
|
67
75
|
version: 0.19.1
|
68
76
|
type: :runtime
|
69
77
|
prerelease: false
|
70
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
71
80
|
requirements:
|
72
|
-
- -
|
81
|
+
- - ~>
|
73
82
|
- !ruby/object:Gem::Version
|
74
83
|
version: 0.19.1
|
75
84
|
- !ruby/object:Gem::Dependency
|
76
85
|
name: erubis
|
77
86
|
requirement: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
78
88
|
requirements:
|
79
|
-
- -
|
89
|
+
- - ~>
|
80
90
|
- !ruby/object:Gem::Version
|
81
91
|
version: 2.7.0
|
82
92
|
type: :runtime
|
83
93
|
prerelease: false
|
84
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
85
96
|
requirements:
|
86
|
-
- -
|
97
|
+
- - ~>
|
87
98
|
- !ruby/object:Gem::Version
|
88
99
|
version: 2.7.0
|
89
100
|
- !ruby/object:Gem::Dependency
|
90
101
|
name: sshkit
|
91
102
|
requirement: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
92
104
|
requirements:
|
93
|
-
- -
|
105
|
+
- - ~>
|
94
106
|
- !ruby/object:Gem::Version
|
95
107
|
version: 1.3.0
|
96
108
|
type: :runtime
|
97
109
|
prerelease: false
|
98
110
|
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
99
112
|
requirements:
|
100
|
-
- -
|
113
|
+
- - ~>
|
101
114
|
- !ruby/object:Gem::Version
|
102
115
|
version: 1.3.0
|
103
116
|
- !ruby/object:Gem::Dependency
|
104
117
|
name: highline
|
105
118
|
requirement: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
106
120
|
requirements:
|
107
|
-
- -
|
121
|
+
- - ~>
|
108
122
|
- !ruby/object:Gem::Version
|
109
123
|
version: 1.6.20
|
110
124
|
type: :runtime
|
111
125
|
prerelease: false
|
112
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
113
128
|
requirements:
|
114
|
-
- -
|
129
|
+
- - ~>
|
115
130
|
- !ruby/object:Gem::Version
|
116
131
|
version: 1.6.20
|
117
132
|
description: cloudstack-nagios generates nagios configuration and checks for monitoring
|
@@ -123,7 +138,8 @@ executables:
|
|
123
138
|
extensions: []
|
124
139
|
extra_rdoc_files: []
|
125
140
|
files:
|
126
|
-
-
|
141
|
+
- .gitignore
|
142
|
+
- .ruby-version
|
127
143
|
- Gemfile
|
128
144
|
- Gemfile.lock
|
129
145
|
- LICENSE.txt
|
@@ -138,6 +154,7 @@ files:
|
|
138
154
|
- lib/cloudstack-nagios/commands/nagios_config.rb
|
139
155
|
- lib/cloudstack-nagios/commands/router.rb
|
140
156
|
- lib/cloudstack-nagios/commands/snmpd_config.rb
|
157
|
+
- lib/cloudstack-nagios/commands/system_vm.rb
|
141
158
|
- lib/cloudstack-nagios/files/create_cs_router_config.sh
|
142
159
|
- lib/cloudstack-nagios/files/snmpd.conf
|
143
160
|
- lib/cloudstack-nagios/helper.rb
|
@@ -147,6 +164,8 @@ files:
|
|
147
164
|
- lib/cloudstack-nagios/templates/cloudstack_router_hosts.cfg.erb
|
148
165
|
- lib/cloudstack-nagios/templates/cloudstack_router_services.cfg.erb
|
149
166
|
- lib/cloudstack-nagios/templates/cloudstack_storage_pools.cfg.erb
|
167
|
+
- lib/cloudstack-nagios/templates/cloudstack_system_vm_hosts.cfg.erb
|
168
|
+
- lib/cloudstack-nagios/templates/cloudstack_system_vm_services.cfg.erb
|
150
169
|
- lib/cloudstack-nagios/templates/cloudstack_zone_hosts.cfg.erb
|
151
170
|
- lib/cloudstack-nagios/templates/footer.cfg.erb
|
152
171
|
- lib/cloudstack-nagios/templates/header.cfg.erb
|
@@ -155,27 +174,28 @@ files:
|
|
155
174
|
homepage: https://github.com/swisstxt/cloudstack-nagios
|
156
175
|
licenses:
|
157
176
|
- MIT
|
158
|
-
metadata: {}
|
159
177
|
post_install_message:
|
160
178
|
rdoc_options:
|
161
|
-
-
|
162
|
-
-
|
179
|
+
- --line-numbers
|
180
|
+
- --inline-source
|
163
181
|
require_paths:
|
164
182
|
- lib
|
165
183
|
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
none: false
|
166
185
|
requirements:
|
167
|
-
- -
|
186
|
+
- - ! '>='
|
168
187
|
- !ruby/object:Gem::Version
|
169
188
|
version: 1.9.3
|
170
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
+
none: false
|
171
191
|
requirements:
|
172
|
-
- -
|
192
|
+
- - ! '>='
|
173
193
|
- !ruby/object:Gem::Version
|
174
194
|
version: '0'
|
175
195
|
requirements: []
|
176
196
|
rubyforge_project:
|
177
|
-
rubygems_version:
|
197
|
+
rubygems_version: 1.8.23
|
178
198
|
signing_key:
|
179
|
-
specification_version:
|
199
|
+
specification_version: 3
|
180
200
|
summary: cloudstack-nagios CloudStack monitoring tools for nagios
|
181
201
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 944d22aba5a8a1b41bcfdd7d6ae63ca86af3d082
|
4
|
-
data.tar.gz: cfc0d40ecc78b6ab5cf50de2a8be47f3160a9a94
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 37869a07b4fb19e67a8f8f24ae58bafda2230260f0f7383fae1762d850ebf8ac8e533649b70dac74704d4222262bd2fd47e2757d9a38808d4b7e4039d8b9c79d
|
7
|
-
data.tar.gz: 12b065a279fdee3e75e7cd5c3cbd461665bf4fd2760fb43d3bd2078db15183f636384fdd385718128e87ba873919f10b002629903857d7a1cf2bae48d3fdfe5a
|