|Syntactic Confectionery Delight|
Script to show space usage by users in home partitionby OfficeLinebacker (Chaplain)
|on Jan 12, 2007 at 06:50 UTC||Need Help??|
OfficeLinebacker has asked for the
wisdom of the Perl Monks concerning the following question:
Greetings, esteemed monks!
I kind of had the last straw yesterday with one of my users filling up our home/ partition and then conveniently going home for the evening immediately thereafter. We don't do hard quotas, but I am thinking of ways to nip these situations in the bud, as it were. One method I thought of is a CGI script that displays everyone's overall space usage in home/ so that when stuff breaks, everyone in our section knows whodunit. Other ideas include sending friendly email reminders, etc. Anyway I got kind of caught up in parsing the output of dhog (not sure if that's a standard builtin) and converting the output to "human readable" form (aka dividing by the appropriate power of 1024 and appending K,M,or G as appropriate (the partition is 20G so T isn't necessary (YET!!).Without further ado (very raw yet):
As you can see I originally intended to create a hash with logonid=>space use pairs but haven't got around to that yet (any ideas welcome).
So of course I'll have to consider the overall plan and truncate all the insignificant digits, but it's a start. What experience have you guys had when begging/exhorting/recommending use of partitions other than home for users' heavy-duty data work?
I already have a cron job that runs a `df` every five minutes and sends me a warning message if any of my partitions hits 95% usage, so I was thinking of adding another one or modifying that one so that the particular user gets an email if and when their personal space usage in the home partition exceeds $QUOTA. I was also thinking of ccing our boss if the situation isn't resolved in a certain number of hours or days or if it's worsening rapidly.
BTW ChemBoy had some great ideas in the chatterbox which I hope he will post here as I am about to doze off here so pardon the quality of the code and writing.
UPDATE since ChemBoy seems to have beat me to sleep here's some of what he typed in the cb:first
(oh dammit... too clever again. Take out the chomp and use perl -l...
UPDATE: Final form should have been (via /msg from ChemBoy)
I like computer programming because it's like Legos for the mind.