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
- The program must be in ruby.
- This implementation may accept any given path, but this is not required.
- 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.
- 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.
- In order to remove threading, the script will start up in either monitor mode (polling for changes) or statistics mode (user checking statistics)
Suggestions
- SQLite is going to be a lot cleaner and easier than a flat text file.
- Store the following for each file:
- Filename
- DateTime monitoring began
- Number of changes
- DateTime of last change
- Each cycle, check if all files have been changed since the last saved modify time.
- If this check errors from the database, create a new entry for the file.
- Subclass the database functions so that you only have a dbObject that has specific calls:
- bool CheckLastModify(filename, modifytime)
- void ModifyFile(filename)
- If using a flat file, use the subclass as an interface.