Forum: Ruby Send mail if disk is fully occupied

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and 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 =

# Retrieves the log files
Dir = ["U: / Test", "U: / Test2", "U: / Test3"]
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

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

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

This topic is locked and can not be replied to.