Skip to content

Commit

Permalink
add sytsem_vm check for sec_stor mounts
Browse files Browse the repository at this point in the history
  • Loading branch information
niwo committed Oct 14, 2014
1 parent 779b2af commit afbda0e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
cloudstack-nagios (0.15.0)
cloudstack-nagios (0.16.0)
cloudstack_client (~> 0.7, >= 0.7.1)
erubis (~> 2.7.0)
highline (~> 1.6.20)
Expand Down
31 changes: 27 additions & 4 deletions lib/cloudstack-nagios/commands/system_vm.rb
Expand Up @@ -41,12 +41,12 @@ def cpu
end
end

desc "fs_rw", "check if the rootfs is read/writeable on host"
desc "fs_rw", "check if a certain mount point is read/writeable on host"
option :mount_point, desc: "The mount point to check", default: '/', aliases: '-m'
def fs_rw
begin
host = systemvm_host
test_file = File.join(options[:mount_point], 'rootdiskcheck.txt')
test_file = File.join(options[:mount_point], 'cs_nagios_diskcheck.txt')
fs_rw = false
on host do |h|
fs_rw = execute(:touch, test_file)
Expand All @@ -58,12 +58,35 @@ def fs_rw
exit_with_failure(e)
end
status = fs_rw ? 0 : 2
puts "FS_RW #{fs_rw ?
puts fs_rw ?
"OK - file system (#{options[:mount_point]}) writeable" :
"CRITICAL - file system (#{options[:mount_point]}) NOT writeable"}"
"CRITICAL - file system (#{options[:mount_point]}) NOT writeable"
exit status
end

desc "secstor_rw", "check if all secstorage mounts are read/writeable on host"
def secstor_rw
host = systemvm_host
mounts = {}
on host do |h|
capture(:mount, '|grep SecStorage').each_line do |nfs_mount|
mount_point = nfs_mount[/.* on (.*) type .*/, 1]
test_file = File.join(mount_point, 'cs_nagios_diskcheck.txt')
fs_rw = execute(:touch, test_file) rescue false
mounts[mount_point] = fs_rw
execute(:rm, '-f', test_file)
end
end
fs_ro = mounts.select {|key,value| value != true}
status = fs_ro.size == 0 ? 0 : 2
puts status == 0 ?
"OK - all sec_stor mounts are writeable" :
"CRITICAL - some sec_stor mounts are NOT writeable (#{fs_ro.keys.join(', ')})"
exit status
rescue => e
exit_with_failure(e)
end

desc "disk_usage", "check the disk space usage of the root volume"
option :partition, desc: "The partition to check", default: '/', aliases: '-P'
def disk_usage
Expand Down
2 changes: 1 addition & 1 deletion lib/cloudstack-nagios/version.rb
@@ -1,3 +1,3 @@
module CloudstackNagios
VERSION = "0.15.3"
VERSION = "0.16.0"
end

0 comments on commit afbda0e

Please sign in to comment.