#!/usr/bin/perl # Monitors users e-mail accounts for mail space capacity # # Coded by J-Dog one slow afternoon in about 10 minutes out # of boredom and for a friend who wanted a script to do it. # # There will prolly NEVER be any updates to this script... # but on the offchance that I do decide to dink on it.. the # official webpage is Http://www.resentment.org/projects/dumailcheck/ # # J-Dog format top= Disk Username (UID) MailSpool Space Security ------------------------------------------------------------------- . # format for each line written to file handle STDOUT format STDOUT = @<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<< @<<<<<<<<< $nameandgid, $umail, $disk, $warn . open (PASSWD, "/etc/passwd") || die "Can't Open /etc/passwd: $!\n"; USER: while () { # loop over passwd file lines chop; # lists are enclosed in parentheses ($uname,$pass,$uid,$gid,$junk,$junk) = split(/:/); # Assign a Value to the Users Mailspool Path $umail = "/var/spool/mail/$uname"; # remove newline, parse line, throw out uninteresting entries if ($uname eq "root" || $uname eq "nobody" || substr($uname,0,2) eq "uu" || ($uid <=100 && $uid > 0)) { next USER; } # Setup da output messages for security $warn = ($uid == 0 && $uname ne "root") ? "** UID=0" : ""; # Check out their Mailspool and dump da size if (-e $umail) { $du = `du -s -k /var/spool/mail/$uname`; chop($du); ($disk,$junk) = split(/\t/,$du); $disk .= "Kb"; } else { $disk = "Skipped"; } # Combine the Username & GID for Printing $nameandgid ="$uname ($uid)"; write; # write out formatted line to standard output } exit;