OMG WALL HAX
So, I was trying to figure out who filled up /home today. Believe it or not, running `du -h –max-depth=1` on a 1TB drive under heavy use takes a while. Luckily, on a cPanel server, there is a .ftpquota file in each user’s home directory. This is not updated in real time, but it’s generally close enough. So I cheated and wrote this little hack.
#!/usr/bin/perl
@files = `ls /var/cpanel/users`;
foreach $user (@files) {
chomp $user;
$quotafile = "/home/$user/.ftpquota";
if (-e $quotafile) {
$quota = `cat $quotafile`;
chomp $quota;
($spam, $ham) = split/ /,$quota;
$gb = sprintf("%.2f",$ham / 1024 / 1024 / 1024);
if ($gb < 1) { next; }
print "$user: $gb\n";
}
}
Let me know if you’ve got a better way to do this. I’m interested to learn new dirty hacks.
Oh, and by the way, one user was consuming 863GB.