Ruby Assignment

Your systems administrator wants to replace the server hard drives with fast, shiny SSDs. Unfortunately, SSDs are not as reliable long term for a very large number of writes.

Because of this, the sysadmin wants to know what files are changed the most so they may be moved to a conventional hard drive. You will write a ruby script that will poll the files for changes and record the frequency at with they are being altered.

Requirements

  1. The program must be in ruby.
  2. This implementation may accept any given path, but this is not required.
  3. You must use some sort of an external data store for the acquired data. This means that the program can be started and stopped without change to the running state.
  4. The program must be able to print out the rate of change of a file and the number of changes it has had since monitoring started.
  5. In order to remove threading, the script will start up in either monitor mode (polling for changes) or statistics mode (user checking statistics)

Suggestions

  1. SQLite is going to be a lot cleaner and easier than a flat text file.
  2. Store the following for each file:
  1. Filename
  2. DateTime monitoring began
  3. Number of changes
  4. DateTime of last change
  1. Each cycle, check if all files have been changed since the last saved modify time.
  1. If this check errors from the database, create a new entry for the file.
  1. Subclass the database functions so that you only have a dbObject that has specific calls:
  1. bool CheckLastModify(filename, modifytime)
  2. void ModifyFile(filename)
  1. If using a flat file, use the subclass as an interface.