lib/cloudstack-nagios/commands/router.rb in cloudstack-nagios-0.12.3 vs lib/cloudstack-nagios/commands/router.rb in cloudstack-nagios-0.13.0

- old
+ new

@@ -30,11 +30,11 @@ mpstat_output = "" on host do |h| mpstat_output = capture(:mpstat) end values = mpstat_output.scan(/\d+\.\d+/) - usage = 100 - values[-1].to_f + usage = 100 - values[-1].to_f data = check_data(100, usage, options[:warning], options[:critical]) puts "CPU #{RETURN_CODES[data[0]]} - usage = #{data[1]}% | usage=#{data[1]}%" exit data[0] rescue => e exit_with_failure(e) @@ -43,20 +43,23 @@ desc "rootfs_rw", "check if the rootfs is read/writeable on host" def rootfs_rw begin host = systemvm_host - proc_out = "" + test_file = '/rootdiskcheck.txt' + rootfs_rw = false on host do |h| - proc_out = capture(:cat, '/proc/mounts') + rootfs_rw = execute(:touch, test_file) + execute(:rm, '-f', test_file) end - rootfs_rw = proc_out.match(/rootfs\srw\s/) - status = rootfs_rw ? 0 : 2 - puts "ROOTFS_RW #{rootfs_rw ? 'OK - rootfs writeable' : 'CRITICAL - rootfs NOT writeable'}" - exit status + rescue SSHKit::Command::Failed + rootfs_rw = false rescue => e exit_with_failure(e) end + status = rootfs_rw ? 0 : 2 + puts "ROOTFS_RW #{rootfs_rw ? 'OK - rootfs writeable' : 'CRITICAL - rootfs NOT writeable'}" + exit status 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