Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

box-community/archived-python-weekly-stats

Repository files navigation

“box-dev-logo”

box-weekly-stats

Box Weekly User Report Script

This is a script that does an emailed weekly report on some basic usage statistics of Box across our domain at the University of Michigan.

The main script is box_data_archiver which is a shell script which emails the report and is set to run weekly at a specific time using Cron. The script utilizes the Box APIs to access data for Box across our domain with the box.py module. auth.conf and settings.conf are the configuration files used in running this script. auth.conf is populated by running the box.py module and settings.conf needs parameters to be entered by the user of the script. A spreadsheet in .csv form, with the date in the title, for all of the users across the domain is populated using fetch_user_data.py and then user_report.py crawls that data to crunch the numbers for the report. We also add the shared accounts to a group just for shared accounts, to better administer them, using add_shared_to_group.py. Lastly, we add a .tar.gz file of the .csv to a Box folder using upload_file.py.

Note that when our domain went to unlimited storage accounts for all our users, we added tracking codes for account_type and set the value to either "shared" or "admin". The script is now based upon this configuration. We had at one time hard-coded the allocation of space for different account types into the script, but our current solution is more readable and accurate in reporting.

Please see below for text of one of the reports that was sent out with the script.


Sample Email Report:

Subject: Box User Report 2015-08-21

Summary for active user accounts
     Total accounts: 49048
     Total storage used: 91723.9 GB
     Mean storage used: 1.9 GB
     Median storage used: 0.0 bytes

Summary for active shared accounts
     Total accounts: 845
     Total storage used: 17754.5 GB
     Mean storage used: 21.0 GB
     Median storage used: 240.3 MB

Summary for active admin accounts
     Total accounts: 11
     Total storage used: 1.7 GB
     Mean storage used: 157.3 MB
     Median storage used: 0.0 bytes

Summary for inactive accounts
     Total accounts: 3156
     Total storage used: 2668.5 GB
     Mean storage used: 865.8 MB
     Median storage used: 0.0 bytes

Summary for all accounts:
     Top 1% of users account for: 12.45% of space used
     Top 10% of users account for: 30.49% of space used
     Top 25% of users account for: 47.84% of space used

About

[Archived] Weekly user report script in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published