Index: [Article Count Order] [Thread]

Date:  Sat, 12 Jan 2008 10:58:30 +0000
From:  Gustavo Silva <pseudo (at mark) zbronx.com>
Subject:  [coba-e:11711] user over quota report for cron
To:  coba-e (at mark) bluequartz.org
Message-Id:  <47889D56.1040607 (at mark) zbronx.com>
X-Mail-Count: 11711

hello Blues!

thought i would share this for those that might find it handy.
i added this script to my cron.daily so i could get a report of over 
quota users...
some users keep forgetting to empty/clean their mbox wich sometimes 
results in "problems", so i like to be notified in advance.

maybe its not the best approach... but oh well... dont have better for 
now.. :P
what i really wanted is a way to track down inactive accounts (over the 
period of X time)... ill study that later :D

<?php
       //get all users
       exec("ls -Al /home/sites/*/users/* | gawk {'print $9'} | sed 's~/mbox~~' | sed 's~/home/sites/~~' | sed 's~/users~~'", $allusers);

       //begin testing
       echo "\n---------------------------------------------------------\n";
       echo " BlueQuartz users quota check ( by pseudo (at mark) zxwg.com ) v.1 \n";
       echo "---------------------------------------------------------\n";
       echo " Testing ".(count($allusers)-1)." VSITE users ( excluding other UNIX users )\n";
       echo "---------------------------------------------------------\n";
       foreach ($allusers as $a){
               unset($quota);
               $a=explode("/", $a);
               if (@$c!=$a[0]){
                       $c=$a[0];
                       $title=false;
               }

               //check quota
               exec("quota -q ".$a[1], $quota);
               if (count($quota)>0){
                       if (!$title){
                               echo "\n ~~ vSite: [ $c ]\n";
                               $title=true;
                       }
                       echo "  ' User [ ".$a[1]." ] is over quota!\n";
                       $error=true;
               }
       }
       echo "\n---------------------------------------------------------\n";
       echo " ~~ Finished. Bye!          ( generated on: ".date("Y-m-d")." )\n";
       echo "---------------------------------------------------------\n";
?>

Best regards,
Gustavo