cloudstack-nagios 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/cloudstack-nagios/cli.rb +1 -2
- data/lib/cloudstack-nagios/commands/check.rb +12 -10
- data/lib/cloudstack-nagios/templates/cloudstack_routers_hosts.cfg.erb +15 -7
- data/lib/cloudstack-nagios/templates/cloudstack_routers_services.cfg.erb +47 -4
- data/lib/cloudstack-nagios/version.rb +1 -1
- metadata +1 -1
data/Gemfile.lock
CHANGED
@@ -8,8 +8,7 @@ module CloudstackNagios
|
|
8
8
|
map %w(-v --version) => :version
|
9
9
|
|
10
10
|
class_option :config,
|
11
|
-
default: File.join(Dir.home, '.cloudstack-nagios.yml'),
|
12
|
-
aliases: '-c',
|
11
|
+
default: ENV['HOME'] ? File.join(Dir.home, '.cloudstack-nagios.yml') : '',
|
13
12
|
desc: 'location of your cloudstack-nagios configuration file'
|
14
13
|
|
15
14
|
class_option :environment,
|
@@ -40,7 +40,7 @@ class Check < CloudstackNagios::Base
|
|
40
40
|
free = values[2].to_i
|
41
41
|
free_b = values[7].to_i
|
42
42
|
data = check_data(total, free_b, options[:warning], options[:critical])
|
43
|
-
puts "MEMORY #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{data[1]}% total=#{total}, free=#{free}, free_wo_buffers=#{free_b}"
|
43
|
+
puts "MEMORY #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{data[1]}% total=#{total}M, free=#{free}M, free_wo_buffers=#{free_b}M"
|
44
44
|
exit data[0]
|
45
45
|
end
|
46
46
|
|
@@ -52,11 +52,13 @@ class Check < CloudstackNagios::Base
|
|
52
52
|
option :warning,
|
53
53
|
desc: 'warning level',
|
54
54
|
type: :numeric,
|
55
|
-
default: 90
|
55
|
+
default: 90,
|
56
|
+
aliases: '-w'
|
56
57
|
option :critical,
|
57
58
|
desc: 'critical level',
|
58
59
|
type: :numeric,
|
59
|
-
default: 95
|
60
|
+
default: 95,
|
61
|
+
aliases: '-c'
|
60
62
|
option :ssh_key,
|
61
63
|
desc: 'ssh private key to use',
|
62
64
|
default: '/var/lib/cloud/management/.ssh/id_rsa'
|
@@ -65,7 +67,7 @@ class Check < CloudstackNagios::Base
|
|
65
67
|
type: :numeric,
|
66
68
|
default: 3922,
|
67
69
|
aliases: '-p'
|
68
|
-
def cpu
|
70
|
+
def cpu
|
69
71
|
host = SSHKit::Host.new("root@#{options[:host]}")
|
70
72
|
host.ssh_options = sshoptions(options[:ssh_key])
|
71
73
|
host.port = options[:port]
|
@@ -76,7 +78,7 @@ class Check < CloudstackNagios::Base
|
|
76
78
|
values = mpstat_output.scan(/\d+/)
|
77
79
|
usage = 100 - values[-1].to_f
|
78
80
|
data = check_data(100, usage, options[:warning], options[:critical])
|
79
|
-
puts "CPU #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{
|
81
|
+
puts "CPU #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{data[1]}%"
|
80
82
|
exit data[0]
|
81
83
|
end
|
82
84
|
|
@@ -152,17 +154,17 @@ class Check < CloudstackNagios::Base
|
|
152
154
|
r2 = capture(:cat, '/sys/class/net/eth0/statistics/rx_bytes').to_f
|
153
155
|
t2 = capture(:cat, '/sys/class/net/eth0/statistics/tx_bytes').to_f
|
154
156
|
end
|
155
|
-
rbps = (r2 - r1)
|
156
|
-
tbps = (t2 - t1)
|
157
|
-
data = check_data(
|
158
|
-
puts "NETWORK #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | rxbps=#{rbps.round(0)}, txbps=#{tbps.round(0)}"
|
157
|
+
rbps = (r2 - r1)
|
158
|
+
tbps = (t2 - t1)
|
159
|
+
data = check_data(1073741824, (1073741824 - rbps), options[:warning], options[:critical])
|
160
|
+
puts "NETWORK #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | rxbps=#{rbps.round(0)}B, txbps=#{tbps.round(0)}B"
|
159
161
|
exit data[0]
|
160
162
|
end
|
161
163
|
|
162
164
|
no_commands do
|
163
165
|
|
164
166
|
def check_data(total, usage, warning, critical)
|
165
|
-
usage_percent = 100.0 / total * usage
|
167
|
+
usage_percent = 100 - 100.0 / total.to_f * usage.to_f
|
166
168
|
code = 3
|
167
169
|
if usage_percent < warning
|
168
170
|
code = 0
|
@@ -3,22 +3,30 @@
|
|
3
3
|
# Host configuration file
|
4
4
|
#
|
5
5
|
# Created by:
|
6
|
-
# Date: <%=
|
6
|
+
# Date: <%= Time.new.strftime("%d.%m.%Y %H:%M:%S") -%>
|
7
7
|
# Version: Nagios 3.x config file
|
8
8
|
#
|
9
9
|
# --- DO NOT EDIT THIS FILE BY HAND ---
|
10
10
|
# cloudstack-cli will overwite all manual settings during the next update
|
11
11
|
#
|
12
12
|
###############################################################################
|
13
|
+
|
14
|
+
define hostgroup {
|
15
|
+
hostgroup_name Cloudstack-SystemVM
|
16
|
+
alias Cloudstack-SystemVM
|
17
|
+
register 1
|
18
|
+
}
|
19
|
+
|
13
20
|
<% routers.each do |router| -%>
|
14
21
|
<% if router['linklocalip'] -%>
|
15
22
|
define host {
|
16
|
-
host_name
|
17
|
-
display_name
|
18
|
-
address
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
host_name <%= router['name'] %>
|
24
|
+
display_name <%= router['name'] %> (<%= <%= router['linklocalip'] %>)<%= " - #{router['project']}" if router['project'] %><%= " - #{router['zonename'] %>
|
25
|
+
address <%= router['linklocalip'] %>
|
26
|
+
use Linux-Host,host-pnp
|
27
|
+
hostgroups Cloudstack-SystemVM
|
28
|
+
check_command check-host-alive
|
29
|
+
register 1
|
22
30
|
}
|
23
31
|
<% end -%>
|
24
32
|
<% end -%>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# Host configuration file
|
5
5
|
#
|
6
6
|
# Created by:
|
7
|
-
# Date: <%=
|
7
|
+
# Date: <%= Time.new.strftime("%d.%m.%Y %H:%M:%S") -%>
|
8
8
|
# Version: Nagios 3.x config file
|
9
9
|
#
|
10
10
|
# --- DO NOT EDIT THIS FILE BY HAND ---
|
@@ -14,7 +14,25 @@
|
|
14
14
|
|
15
15
|
define command {
|
16
16
|
command_name cs-nagios_check-memory
|
17
|
-
command_line cs-nagios check memory -H $HOSTADDRESS$ -w $ARG1$ -c $
|
17
|
+
command_line /usr/local/bin/cs-nagios check memory -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config /var/icinga/.cloudstack-nagios.yml
|
18
|
+
register 1
|
19
|
+
}
|
20
|
+
|
21
|
+
define command {
|
22
|
+
command_name cs-nagios_check-cpu
|
23
|
+
command_line /usr/local/bin/cs-nagios check cpu -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config /var/icinga/.cloudstack-nagios.yml
|
24
|
+
register 1
|
25
|
+
}
|
26
|
+
|
27
|
+
define command {
|
28
|
+
command_name cs-nagios_check-network
|
29
|
+
command_line /usr/local/bin/cs-nagios check network -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config /var/icinga/.cloudstack-nagios.yml
|
30
|
+
register 1
|
31
|
+
}
|
32
|
+
|
33
|
+
define command {
|
34
|
+
command_name cs-nagios_check-rootfsrw
|
35
|
+
command_line /usr/local/bin/cs-nagios check rootfs_rw -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ --config /var/icinga/.cloudstack-nagios.yml
|
18
36
|
register 1
|
19
37
|
}
|
20
38
|
|
@@ -22,12 +40,38 @@ define service {
|
|
22
40
|
hostgroup_name Cloudstack-SystemVM
|
23
41
|
service_description Memory
|
24
42
|
display_name Memory
|
25
|
-
servicegroups Cloudstack-SystemVM
|
26
43
|
use Generic-Service,service-pnp
|
27
44
|
check_command cs-nagios_check-memory!80!90
|
28
45
|
register 1
|
29
46
|
}
|
30
47
|
|
48
|
+
define service {
|
49
|
+
hostgroup_name Cloudstack-SystemVM
|
50
|
+
service_description CPU
|
51
|
+
display_name CPU
|
52
|
+
use Generic-Service,service-pnp
|
53
|
+
check_command cs-nagios_check-cpu!80!90
|
54
|
+
register 1
|
55
|
+
}
|
56
|
+
|
57
|
+
define service {
|
58
|
+
hostgroup_name Cloudstack-SystemVM
|
59
|
+
service_description Network
|
60
|
+
display_name Network
|
61
|
+
use Generic-Service,service-pnp
|
62
|
+
check_command cs-nagios_check-network!80!90
|
63
|
+
register 1
|
64
|
+
}
|
65
|
+
|
66
|
+
define service {
|
67
|
+
hostgroup_name Cloudstack-SystemVM
|
68
|
+
service_description RootFS rw
|
69
|
+
display_name RootFS rw
|
70
|
+
use Generic-Service,service-pnp
|
71
|
+
check_command cs-nagios_check-rootfsrw!80!90
|
72
|
+
register 1
|
73
|
+
}
|
74
|
+
|
31
75
|
###############################################################################
|
32
76
|
#
|
33
77
|
# Host configuration file
|
@@ -35,4 +79,3 @@ define service {
|
|
35
79
|
# END OF FILE
|
36
80
|
#
|
37
81
|
###############################################################################
|
38
|
-
|