Send mail if disk is fully occupied


#1

Hello everybody
I’m working on a script.
This can delete “only” log data from given drives and compress it.
With the time I noticed that it is very stupid, if my program in the
drives delete the logfiles, if these are fully occupied to 90% loaded.
Is it possible to send a mail to any address when my script sees that
drive xy is fully occupied to 90%?

Here is my script:

Require 'fileutils'
Require 'date'
Require "zlib"

Current_day = Time.now.to_datetime.jd

# Retrieves the log files
Dir = ["U: / Test", "U: / Test2", "U: / Test3"]
Dir
Puts d
Dir.chdir (d)
Dir.glob ("* .log") each do | file | #im directory
File_day = File.mtime (file) .to_datetime.jd

If current_day - file_day> = 3
FileUtils.rm file

end
Puts (d)
If current_day - file_day> = 1
Puts (file)
Bin_data = File.read (file)
File.open ("# {file} .gz", "w") do | f |
  Gz = Zlib :: GzipWriter.new (f)
  gz.write (bin_data)
  gz.close
end

If file.exist? ("# {File} .gz")
File.delete (file)
end
end
}

regards
rubyamateur