1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Mailbox Sizes - Quick Shell Script

Discussion in 'Plesk for Linux - 8.x and Older' started by ghazlewood, Oct 16, 2006.

  1. ghazlewood

    ghazlewood Basic Pleskian

    24
    40%
    Joined:
    Nov 15, 2004
    Messages:
    40
    Likes Received:
    0
    Location:
    London, UK
    Recently I've needed to know the size of the largest mailboxes on a Plesk 8 box. After some quick Googling and testing I've worked out the following to email me the top 25 (or however many) mailboxes by size.

    Code:
    #!/bin/sh
    
    cd /var/qmail/mailnames;
    du -hs --block-size=1024K */* | sort -nr | head -25 | mail -s 'Top 25 Mailboxes by Size' [email]postmaster@yourdomain.com[/email]
    
    I'm running this weekly by cron so I have a record. Next step is to make it check the psa database for each domain and only show mailboxes near or over quota. But for now it'll do.

    Hope someone else finds this useful.

    Cheers

    George
     
  2. mooiesite

    mooiesite Basic Pleskian

    24
    23%
    Joined:
    Jun 17, 2006
    Messages:
    66
    Likes Received:
    0
    you can use my script if you want...
    it's in dutch, but you'll figure out

    it runs every night and checks all mailboxes.
    it checks for >90% mailboxes and for >100% mailboxes
    it will copy a new mail directly to a users mailbox.

    http://www.mooiesite.nl/mailcheck.txt
     
  3. ghazlewood

    ghazlewood Basic Pleskian

    24
    40%
    Joined:
    Nov 15, 2004
    Messages:
    40
    Likes Received:
    0
    Location:
    London, UK
    Hey that was exactly what I was looking for! Thanks very much indeed. I had a feeling someone else might have been here already, thanks for sharing your script.

    Cheers

    George
     
  4. lvalics

    lvalics Silver Pleskian Plesk Guru

    36
    43%
    Joined:
    Jun 20, 2003
    Messages:
    965
    Likes Received:
    32
    Location:
    Romania
    Can you translate text to english from script and post it?
     
  5. Mr.Yes

    Mr.Yes Guest

    0
     
    anyone tried this script? it's working?

    i tried as well and i had a MySQL error al line 29 :
    if (mysql_num_rows($result) > 0)

    so i changed in :

    if (@mysql_num_rows($result) > 0)

    now when i run the script i have no error but a blank page, is it normal? how can i test if it's working correctly?

    Thanx and have a great xmas time!
     
  6. albatroz

    albatroz Guest

    0
     
    Can somebody repost this script?

     
  7. ghazlewood

    ghazlewood Basic Pleskian

    24
    40%
    Joined:
    Nov 15, 2004
    Messages:
    40
    Likes Received:
    0
    Location:
    London, UK
  8. Mr.Yes

    Mr.Yes Guest

    0
     
    Hi,

    i have a parse error:
    Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /home/httpd/vhosts/mydomain.com/httpdocs/check_fullmailbox.php on line 168

    and if i comment out line 168 i have 2 Warning too:

    Warning: ini_set(): open_basedir restriction in effect. File(0) is not within the allowed path(s): (/home/httpd/vhosts/mydomain.com/httpdocs:/tmp) in /home/httpd/vhosts/mydomain.com/httpdocs/check_fullmailbox.php on line 100

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/mydomain.com/httpdocs/check_fullmailbox.php on line 108


    Can you help me to fix this very useful script?

    Thanx
     
  9. ghazlewood

    ghazlewood Basic Pleskian

    24
    40%
    Joined:
    Nov 15, 2004
    Messages:
    40
    Likes Received:
    0
    Location:
    London, UK
    Ah I should have said I'm running this from cron:

    Code:
    php -d open_basedir=/var/qmail/mailnames -d safe_mode=0 -f /usr/local/psa/admin/htdocs/mailcheck.php
    I run this nightly, it's probably not a good idea to run it from an actual site. Well it won't do any harm but much better to run it from cron anyway.
     
  10. Mr.Yes

    Mr.Yes Guest

    0
     
    Hi,

    i tried via cron bur i still have the parse error on line 168, no one else is in my condition?

    thanx
     
  11. ghazlewood

    ghazlewood Basic Pleskian

    24
    40%
    Joined:
    Nov 15, 2004
    Messages:
    40
    Likes Received:
    0
    Location:
    London, UK
    Sorry for making you find the bugs Mr.Yes!

    Can you try downloading it again? I thought I was tidying up before posting it but it looks like I added a bug.

    Cheers

    George
     
  12. Mr.Yes

    Mr.Yes Guest

    0
     
    Hello,

    i still have an error with new version:

    <b>Warning</b>: mysql_num_rows(): supplied argument is not a valid MySQL result resource in <b>/usr/local/psa/admin/htdocs/mailcheck.php</b> on line <b>108</b>

    Thanx for your help
     
  13. ghazlewood

    ghazlewood Basic Pleskian

    24
    40%
    Joined:
    Nov 15, 2004
    Messages:
    40
    Likes Received:
    0
    Location:
    London, UK
    Sounds like the query is failing, check that your database connection is working correctly. Did you change the host, username and password for mysql?

    Failing that can you try running the SQL through phpMyAdmin and see if it's the query which has a problem?

    Cheers

    George
     
  14. Mr.Yes

    Mr.Yes Guest

    0
     
    Hello here is my conf:

    PHP:
    /* CHANGE ME !
    Just change the settings below: 
    */

    define("MAILNAMES""/var/qmail/mailnames/");
    // You must set this!
    define("DOMAIN""yourdomain.co.uk");
    define("ACCOUNT""postmaster");
    define("FROM"ACCOUNT."@".DOMAIN);
    // Uncomment the line below and users will get an email, otherwise only the postmaster (defined above) will get messages
    //define("DELIVER_TO_USER",true);
    define("LOWER_LIMIT"90.0); // 90% full - approaching capacity
    define("UPPER_LIMIT"99.9); // 99.9% full - mailbox full
    // You must set these!
    define("DBHOST"'localhost');
    define("DBUSER"'admin');
    define("DBPASS"'mypleskpassword');
    /* End of config */
    As u see i put: localhost, admin and mypleskpassword .. is it correct?
     
  15. ghazlewood

    ghazlewood Basic Pleskian

    24
    40%
    Joined:
    Nov 15, 2004
    Messages:
    40
    Likes Received:
    0
    Location:
    London, UK
    Sounds right to me. For my setup here I created a specific user who only has read access to those tables but the plesk admin user should be fine too. Can you try running the SQL in phpMyAdmin?
     
Loading...