Simple inventory and auditing for files/directories stored on file system.
-
Clone this repo.
git clone https://github.com/gwu-libraries/audit-tool.git
-
Copy
example.config.py
toconfig.py
.cd audit-tool cp example.config.py config.py
-
Edit the values in
config.py
. This file contains explanations of the values. -
Optional: Create a virtualenv.
Check which version of Python 3 is installed:
python3 --version
Install the associated
python3.x-venv
. You may need to do this as a different user who hassudo
privileges. For example, for Python 3.8:sudo apt install python3.8-env
(As the
gwlai
user:) Create the Python virtual environment:python3 -m venv ENV source ENV/bin/activate
-
Install requirements.
pip install -r requirements.txt
-
Optional: Schedule audits with cron.
0 12 * * Sat /opt/audit-tool/ENV/bin/python /opt/audit-tool/audit_tool.py detect_changes --notify all /storage/Drobo5Volume1
Note: If multiple users will be performing inventorying activities, be cognizant of file permissions. One useful approach is to have all users in a common group, set the python executable to that group, and set the guid & group's executable bit (chmod g+s
) on the python executable.
When adding a new file system to the inventory, the inventory for that file system must be populated.
python audit_tool.py populate <file system base path>
- Add, update, or delete files. If copying files from other storage, that copy should be verified (e.g., by using rsync or checking fixities before and after copy).
- Detect the added, updated, or deleted files.
To generate json and Excel reports:
python audit_tool.py detect_changes <base path containing the changes>
To generate a json report only:
python audit_tool.py detect_changes <base path containing the changes>
-
Detecting the changes will produce an inventory report, describing all of the changes that were detected. Review the report to make sure that it is accurate. To keep track of your progress, you may want to add notes.
-
Update the inventory.
python audit_tool.py update <path to report>
Note: If an report has notes, you will be asked to confirm before proceeding.
-
Detect changes either by a scheduled cron job or by manually invoking:
python audit_tool.py detect_changes <file system base path>
-
Review the report to determine if any discrepancies were detected.
-
If a discrepancy was detected and the discrepancy was caused by a failure to update the inventory after updating files then update the inventory:
python audit_tool.py update <path to report>
-
If a discrepancy was detected and the discrepancy was caused by an error with the files, then fix the error and re-run detect changes to make sure the problem was resolved.
You can add notes with:
python audit_tool.py note <path to report> "Your note."
Notes will be added to the report.
To get an Excel version of a report:
python audit_tool.py excel <path to report>
python -m unittest discover