#!/usr/bin/perl -w # Shows the quota space used by the specified cpanel user, in % # Rename to quotaused, chown root and chmod 0700 # Usage: quotaused username ############################################################################### # Author: Juan R. Pozo - http://html.conclase.net/cp/scripts/ # Released on December 8, 2003 ############################################################################### # This software is released into the public domain. Use at your own risk. # The author holds no rights or responsibilities related to this software. ############################################################################### use strict; use POSIX qw(nice); my $user; if (defined($ARGV[0]) && $ARGV[0] =~ /^[-\w]{1,8}$/ && -r "/var/cpanel/users/$ARGV[0]") { $user = ($ARGV[0]); } else { die("0\nUsage: quotaused username\n"); } my ($quota, $quotamax) = (0, 0); my @quota = `quota -u $user`; # /dev/sda2 452 30720 30720 94 0 0 foreach my $line (@quota) { if ($line =~ m!/dev/\S+\s+(\d+)\*?\s+(\d+)!) { $quota += $1; $quotamax = $2; } } printf("%.2f", ($quota/$quotamax)*100); exit;