#!/usr/local/bin/perl # use Mail::Sendmail; $mailhost = "mail_server"; $fromaddress = "me@.com"; $toaddress = "me@.com"; %mail = ( From => $fromaddress, Subject => "server Quota Report", Smtp => $mailhost, To => $toaddress, ); # Define Global Variables # Percentage Quota used that triggers a warning to the user. $warnquotapct = 25; # Netapp mixed mode filer my @quota = `rsh server_name quota report -x`; #Remove the top 3 lines from the quota output (header) shift(@quota); shift(@quota); shift(@quota); foreach $line (@quota) { chomp($line); ($ignore, $user, $vol, $tree, $used, $limit, $thresh, $ignore, $ignore, $ignore) = split(/\s+/, $line); next unless ($user); $user = lc($user); next if ($user eq "\*"); next if ($user eq "root"); next if ($user eq "builtin\\administrators"); next if ($used <= "0") || ($used eq ""); # # Below line is for server right now limit = "-" # next if ($limit eq "-") || ($limit eq ""); # Strip out the "NT_DOMAIN\" prefix to the username if it's there. $user =~ s/NT_DOMAIN\\//; $used = $used / 1000; $quota = $quota / 1000; $limit = $limit / 1000; $usedquotapct= $used / $limit *100; $remainingquota = $limit - $used; if ($usedquotapct >= $maxquotapct ) { printf ("$user\'s disk usage \= %.2f MB.\nHas %.2f MB available.\nQuota set to: %.2f MB\n\n", $used, $remainingquota, $limit); } } print("\nSending email..."); sendmail(%mail) || print "Error: $Mail::Sendmail::error\n"; print("Complete\n");