Created
September 7, 2018 00:03
-
-
Save divanikus/3a7be25e706fd8339c4e45c7c5e4cfe3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "minitest/autorun" | |
require "minitest/doc_reporter" | |
SMART_CMD = "sudo smartctl" | |
ZPOOL_CMD = "sudo zpool" | |
describe "Disks" do | |
disks = %x{#{SMART_CMD} --scan-open}.scan /^\S+/ | |
it "Server has two disks" do | |
disks.length.must_equal(2) | |
end | |
disks.each do |disk| | |
describe disk do | |
it "S.M.A.R.T. health check is PASSED" do | |
%x{#{SMART_CMD} -H #{disk} | grep "overall-health"}.must_match(/PASSED/) | |
end | |
end | |
end | |
end | |
describe "Zpool" do | |
it "All pools are healthy" do | |
%x{#{ZPOOL_CMD} status -x}.must_match(/all pools are healthy/) | |
end | |
end | |
describe "MDRaid" do | |
Dir.glob("/sys/block/md*").map { |x| x.sub(/^\/sys\/block\//, '') }.each do |dev| | |
describe dev do | |
it "Is healthy" do | |
File.open("/sys/block/#{dev}/md/degraded").read.chomp.to_i.must_equal(0) | |
end | |
it "Has two disks" do | |
File.open("/sys/block/#{dev}/md/raid_disks").read.chomp.to_i.must_equal(2) | |
end | |
end | |
end | |
end | |
describe "Filesystems" do | |
%x{df -x tmpfs -x devtmpfs | grep -v Filesystem}.split(/\n/).map{|x| x.scan(/\S+/)}.each do |fs| | |
describe fs[5] do | |
it "Used space is less than 90%" do | |
fs[4].to_i.must_be(:<, 90) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment