Forum: Ruby Send mail if disk is fully occupied

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B8c0fa903537801d9268fc77b98e0039?d=identicon&s=25 Ruby Amateur (rubyamateur)
on 2017-05-03 21:37
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:
[Code = ruby]
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
}
[/code]

regards
rubyamateur
This topic is locked and can not be replied to.