cloudstack-nagios 0.15.2 → 0.16.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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudstack-nagios (0.15.0)
4
+ cloudstack-nagios (0.16.0)
5
5
  cloudstack_client (~> 0.7, >= 0.7.1)
6
6
  erubis (~> 2.7.0)
7
7
  highline (~> 1.6.20)
data/README.md CHANGED
@@ -155,6 +155,16 @@ Example:
155
155
  $ cs-nagios check async_jobs
156
156
  ```
157
157
 
158
+ ### Snapshot checks
159
+
160
+ Checks for snapshots which are not in state 'BakedUp' for a certain amount of time.
161
+
162
+ Example:
163
+
164
+ ```sh
165
+ $ cs-nagios check snapshots
166
+ ```
167
+
158
168
  ## References
159
169
 
160
170
  * [Cloudstack API documentation](http://cloudstack.apache.org/docs/api/apidocs-4.2/TOC_Root_Admin.html)
@@ -86,5 +86,44 @@ class Check < CloudstackNagios::Base
86
86
  code = 2
87
87
  end
88
88
  puts "async_jobs #{RETURN_CODES[code]} - jobs = #{outstanding_jobs.size} | jobs=#{outstanding_jobs.size}"
89
+ exit code
90
+ end
91
+
92
+ desc "snapshots", "check for failed snapshots (not in state 'BakedUp' for x hours)"
93
+ option :warning,
94
+ desc: 'warning level',
95
+ type: :numeric,
96
+ default: 12,
97
+ aliases: '-w'
98
+ option :critical,
99
+ desc: 'critical level',
100
+ type: :numeric,
101
+ default: 24,
102
+ aliases: '-c'
103
+ def snapshots
104
+ snapshots = []
105
+ snapshots << client.send_request('command' => 'listSnapshots', 'projectid' => '-1')['snapshot']
106
+ snapshots << client.send_request('command' => 'listSnapshots')['snapshot']
107
+ snapshots.compact!.flatten!
108
+ not_backed_up = snapshots.select{|s| s['state'] != 'BackedUp' }
109
+
110
+ warnings = []
111
+ critical = []
112
+
113
+ not_backed_up.each do |s|
114
+ age = (Time.now - Time.parse(s['created'])) / 3600
115
+ warnings << s if age > options[:warning]
116
+ critical << s if age > options[:critical]
117
+ end
118
+
119
+ code = if critical.size > 0
120
+ 2
121
+ elsif warnings.size > 0
122
+ 1
123
+ else
124
+ 0
125
+ end
126
+ puts "snapshots #{RETURN_CODES[code]} - warnings = #{warnings.size}, critical = #{critical.size} | warnings=#{warnings.size} critical=#{critical.size}"
127
+ exit code
89
128
  end
90
129
  end
@@ -80,7 +80,7 @@ class NagiosConfig < CloudstackNagios::Base
80
80
  no_commands do
81
81
 
82
82
  def get_configs(configs = [])
83
- all_configs = %w(hostgroups zone_hosts router_hosts router_services system_vm_hosts system_vm_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 snapshots storage_pools)
84
84
  if configs.size == 0
85
85
  return all_configs
86
86
  else
@@ -41,12 +41,12 @@ class SystemVm < CloudstackNagios::Base
41
41
  end
42
42
  end
43
43
 
44
- desc "fs_rw", "check if the rootfs is read/writeable on host"
44
+ desc "fs_rw", "check if a certain mount point is read/writeable on host"
45
45
  option :mount_point, desc: "The mount point to check", default: '/', aliases: '-m'
46
46
  def fs_rw
47
47
  begin
48
48
  host = systemvm_host
49
- test_file = File.join(options[:mount_point], 'rootdiskcheck.txt')
49
+ test_file = File.join(options[:mount_point], 'cs_nagios_diskcheck.txt')
50
50
  fs_rw = false
51
51
  on host do |h|
52
52
  fs_rw = execute(:touch, test_file)
@@ -58,12 +58,36 @@ class SystemVm < CloudstackNagios::Base
58
58
  exit_with_failure(e)
59
59
  end
60
60
  status = fs_rw ? 0 : 2
61
- puts "FS_RW #{fs_rw ?
61
+ puts fs_rw ?
62
62
  "OK - file system (#{options[:mount_point]}) writeable" :
63
- "CRITICAL - file system (#{options[:mount_point]}) NOT writeable"}"
63
+ "CRITICAL - file system (#{options[:mount_point]}) NOT writeable"
64
64
  exit status
65
65
  end
66
66
 
67
+ desc "secstor_rw", "check if all secstorage mounts are read/writeable on host"
68
+ def secstor_rw
69
+ host = systemvm_host
70
+ mounts = {}
71
+ on host do |h|
72
+ entries = capture(:mount, '|grep -cim1 SecStorage') rescue ''
73
+ entries.each_line do |nfs_mount|
74
+ mount_point = nfs_mount[/.* on (.*) type .*/, 1]
75
+ test_file = File.join(mount_point, 'cs_nagios_diskcheck.txt')
76
+ fs_rw = execute(:touch, test_file) rescue false
77
+ mounts[mount_point] = fs_rw
78
+ execute(:rm, '-f', test_file) if fs_rw
79
+ end
80
+ end
81
+ fs_ro = mounts.select {|key,value| value != true}
82
+ status = fs_ro.size == 0 ? 0 : 2
83
+ puts status == 0 ?
84
+ "OK - all sec_stor mounts are writeable" :
85
+ "CRITICAL - some sec_stor mounts are NOT writeable (#{fs_ro.keys.join(', ')})"
86
+ exit status
87
+ rescue => e
88
+ exit_with_failure(e)
89
+ end
90
+
67
91
  desc "disk_usage", "check the disk space usage of the root volume"
68
92
  option :partition, desc: "The partition to check", default: '/', aliases: '-P'
69
93
  def disk_usage
@@ -10,6 +10,6 @@ define service {
10
10
  service_description Cloudstack Async Jobs
11
11
  display_name Cloudstack Async Jobs
12
12
  use Generic-Service,service-pnp
13
- check_command cs-nagios_check-asyncjobs!80!90
13
+ check_command cs-nagios_check-asyncjobs!5!10
14
14
  register 1
15
15
  }
@@ -16,3 +16,9 @@ define hostgroup {
16
16
  alias CloudstackSystemVm
17
17
  register 1
18
18
  }
19
+
20
+ define hostgroup {
21
+ hostgroup_name CloudstackSSVM
22
+ alias CloudstackSSVM
23
+ register 1
24
+ }
@@ -70,8 +70,8 @@ define service {
70
70
 
71
71
  define service {
72
72
  hostgroup_name CloudstackRouter
73
- service_description Cloudstack Virtual Router RootFS rw
74
- display_name Cloudstack Virtual Router RootFS rw
73
+ service_description Cloudstack Virtual Router RootFS r/w
74
+ display_name Cloudstack Virtual Router RootFS r/w
75
75
  use Generic-Service,service-pnp
76
76
  check_command cs-nagios_check-rootfsrw!80!90
77
77
  register 1
@@ -79,7 +79,7 @@ define service {
79
79
 
80
80
  define service {
81
81
  hostgroup_name CloudstackRouter
82
- service_description Cloudstack Virtual RouterDiskUsageRoot
82
+ service_description Cloudstack Virtual Router DiskUsageRoot
83
83
  display_name Cloudstack Virtual Router DiskUsage Root
84
84
  use Generic-Service,service-pnp
85
85
  check_command cs-nagios_check-diskusage!80!90!/
@@ -88,7 +88,7 @@ define service {
88
88
 
89
89
  define service {
90
90
  hostgroup_name CloudstackRouter
91
- service_description Cloudstack Virtual RouterDiskUsageVar
91
+ service_description Cloudstack Virtual Router DiskUsageVar
92
92
  display_name Cloudstack Virtual Router DiskUsage Var
93
93
  use Generic-Service,service-pnp
94
94
  check_command cs-nagios_check-diskusage!80!90!/var
@@ -97,7 +97,7 @@ define service {
97
97
 
98
98
  define service {
99
99
  hostgroup_name CloudstackRouter
100
- service_description Cloudstack Virtual RouterConntrackConnections
100
+ service_description Cloudstack Virtual Router ConntrackConnections
101
101
  display_name Cloudstack Virtual Router Conntrack Connections
102
102
  use Generic-Service,service-pnp
103
103
  check_command cs-nagios_check-conntrack_connections!80!90
@@ -106,8 +106,8 @@ define service {
106
106
 
107
107
  define service {
108
108
  hostgroup_name CloudstackRouter
109
- service_description Cloudstack Virtual RouterActiveFTP
110
- display_name Cloudstack Virtual RouterActiveFTP
109
+ service_description Cloudstack Virtual Router ActiveFTP
110
+ display_name Cloudstack Virtual Router ActiveFTP
111
111
  use Generic-Service,service-pnp
112
112
  check_command cs-nagios_check-active_ftp
113
113
  register 1
@@ -0,0 +1,15 @@
1
+
2
+ define command {
3
+ command_name cs-nagios_check-snapshots
4
+ command_line <%= bin_path -%>cs-nagios check snapshots -w $ARG1$ -c $ARG2$ --config <%= config_file %>
5
+ register 1
6
+ }
7
+
8
+ define service {
9
+ hostgroup_name Cloudstack
10
+ service_description Cloudstack Snapshots
11
+ display_name Cloudstack Snapshots
12
+ use Generic-Service,service-pnp
13
+ check_command cs-nagios_check-snapshots!12!24
14
+ register 1
15
+ }
@@ -6,7 +6,7 @@ define host {
6
6
  display_name <%= vm['name'] %> (<%= vm['privateip'] %>) - <%= vm['zonename'] %>
7
7
  address <%= vm['privateip'] %>
8
8
  use Linux-Host,host-pnp
9
- hostgroups CloudstackSystemVm
9
+ hostgroups CloudstackSystemVm<%= ',CloudstackSSVM' if vm['systemvmtype'] == 'secondarystoragevm' %>
10
10
  check_command check-host-alive
11
11
  register 1
12
12
  }
@@ -29,10 +29,18 @@ define command {
29
29
  register 1
30
30
  }
31
31
 
32
+ cs-nagios_check_systemvm-secstorrw
33
+
34
+ define command {
35
+ command_name cs-nagios_check_systemvm-secstorrw
36
+ command_line <%= bin_path -%>cs-nagios check system_vm secstor_rw -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -P $ARG3$ --ssh-key <%= ssh_key %> --ssh-port <%= ssh_port %> --config <%= config_file %>
37
+ register 1
38
+ }
39
+
32
40
  define service {
33
41
  hostgroup_name CloudstackSystemVm
34
- service_description Cloudstack Virtual System VM Memory
35
- display_name Cloudstack Virtual System VM Memory
42
+ service_description Cloudstack System VM Memory
43
+ display_name Cloudstack System VM Memory
36
44
  use Generic-Service,service-pnp
37
45
  check_command cs-nagios_check_systemvm-memory!80!90
38
46
  register 1
@@ -40,8 +48,8 @@ define service {
40
48
 
41
49
  define service {
42
50
  hostgroup_name CloudstackSystemVm
43
- service_description Cloudstack Virtual System VM CPU
44
- display_name Cloudstack Virtual System VM CPU
51
+ service_description Cloudstack System VM CPU
52
+ display_name Cloudstack System VM CPU
45
53
  use Generic-Service,service-pnp
46
54
  check_command cs-nagios_check_systemvm-cpu!80!90
47
55
  register 1
@@ -49,8 +57,8 @@ define service {
49
57
 
50
58
  define service {
51
59
  hostgroup_name CloudstackSystemVm
52
- service_description Cloudstack Virtual System VM Network
53
- display_name Cloudstack Virtual System VM Network
60
+ service_description Cloudstack System VM Network
61
+ display_name Cloudstack System VM Network
54
62
  use Generic-Service,service-pnp
55
63
  check_command cs-nagios_check_systemvm-network!80!90
56
64
  register 1
@@ -58,8 +66,8 @@ define service {
58
66
 
59
67
  define service {
60
68
  hostgroup_name CloudstackSystemVm
61
- service_description Cloudstack Virtual System VM FS r/w
62
- display_name Cloudstack Virtual System VM FS r/w
69
+ service_description Cloudstack System VM FS r/w
70
+ display_name Cloudstack System VM FS r/w
63
71
  use Generic-Service,service-pnp
64
72
  check_command cs-nagios_check_systemvm-fsrw!80!90
65
73
  register 1
@@ -67,8 +75,8 @@ define service {
67
75
 
68
76
  define service {
69
77
  hostgroup_name CloudstackSystemVm
70
- service_description Cloudstack Virtual System VM DiskUsageRoot
71
- display_name Cloudstack Virtual System VM DiskUsage Root
78
+ service_description Cloudstack System VM DiskUsageRoot
79
+ display_name Cloudstack System VM DiskUsage Root
72
80
  use Generic-Service,service-pnp
73
81
  check_command cs-nagios_check_systemvm-diskusage!80!90!/
74
82
  register 1
@@ -76,9 +84,18 @@ define service {
76
84
 
77
85
  define service {
78
86
  hostgroup_name CloudstackSystemVm
79
- service_description Cloudstack Virtual System VMDiskUsageVar
80
- display_name Cloudstack Virtual System VM DiskUsage Var
87
+ service_description Cloudstack System VM DiskUsageVar
88
+ display_name Cloudstack System VM DiskUsage Var
81
89
  use Generic-Service,service-pnp
82
90
  check_command cs-nagios_check_systemvm-diskusage!80!90!/var
83
91
  register 1
84
92
  }
93
+
94
+ define service {
95
+ hostgroup_name CloudstackSSVM
96
+ service_description Cloudstack SSVM SecondaryStorageRW
97
+ display_name Cloudstack SSVM SecondaryStorageRW
98
+ use Generic-Service,service-pnp
99
+ check_command cs-nagios_check_systemvm-secstorrw!80!90!
100
+ register 1
101
+ }
@@ -1,3 +1,3 @@
1
1
  module CloudstackNagios
2
- VERSION = "0.15.2"
2
+ VERSION = "0.16.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstack-nagios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.16.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-09 00:00:00.000000000 Z
12
+ date: 2014-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -163,6 +163,7 @@ files:
163
163
  - lib/cloudstack-nagios/templates/cloudstack_hostgroups.cfg.erb
164
164
  - lib/cloudstack-nagios/templates/cloudstack_router_hosts.cfg.erb
165
165
  - lib/cloudstack-nagios/templates/cloudstack_router_services.cfg.erb
166
+ - lib/cloudstack-nagios/templates/cloudstack_snapshots.cfg.erb
166
167
  - lib/cloudstack-nagios/templates/cloudstack_storage_pools.cfg.erb
167
168
  - lib/cloudstack-nagios/templates/cloudstack_system_vm_hosts.cfg.erb
168
169
  - lib/cloudstack-nagios/templates/cloudstack_system_vm_services.cfg.erb