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

Plesk 10 per user disk usage report?

Discussion in 'Plesk 10.x for Linux Issues, Fixes, How-To' started by JP Kelly, Apr 2, 2011.

  1. JP Kelly

    JP Kelly Regular Pleskian

    28
     
    Joined:
    Jan 20, 2007
    Messages:
    168
    Likes Received:
    0
    Is it possible for a client to view usage on his domain(s) per user and per email account?
    There only seems to be a grand total.
    Before he could view usage on each email account and each web user.
     
  2. dsojo

    dsojo Guest

    0
     
    also cannot find this

    our customer are already upset... any idea how to ?
     
  3. JP Kelly

    JP Kelly Regular Pleskian

    28
     
    Joined:
    Jan 20, 2007
    Messages:
    168
    Likes Received:
    0
    a hack

    I created a script and custom button for my 1 customer who complained.
    This only works for the one customer/domain, I did not have time to make one that works for all users.
    It should be pretty easy to modify for your purposes.

    The script: (saved in /usr/local/sbin/hogs and chmod 755 and change <THEDOMAIN.COM> to whatever the domain is you are getting usage for)
    Code:
    #!/bin/sh
    #
    #lists disk usage by user
    
    echo 'Web Site Files'
    du -chs /var/www/vhosts/<THEDOMAIN.COM>/httpdocs/* | tail -1
    echo
    echo 'Web Users'
    du -chs /var/www/vhosts/<THEDOMAIN.COM>/web_users/* | tail -1
    du -sk /var/www/vhosts/<THEDOMAIN.COM>/web_users/* | sort -nr | awk '{ print $2 }' | while read f ; do du -sh "$f" | awk -F/var/www/vhosts/<THEDOMAIN.COM>/web_users/ '{ print $1, "\t", $2 }' ; done
    echo
    echo 'Mail Users'
    du -chs /var/qmail/mailnames/<THEDOMAIN.COM>/* | tail -1
    du -sk /var/qmail/mailnames/<THEDOMAIN.COM>/* | sort -nr | awk '{ print $2 }' | while read f ; do du -sh "$f" | awk -F/var/qmail/mailnames/<THEDOMAIN.COM>/ '{ print $1, "\t", $2 }' ; done
    You will also need to add this to the bottom of the sudoers file (use visudo)
    Code:
    psaadm  ALL = NOPASSWD: /usr/local/sbin/hogs
    The custom button references a page which is placed in /usr/local/psa/admin/htdocs/usage/index.php
    The link for the custom button would be https://mydomain.net:8443/usage/index.php I selected "Open URL in Parallels Panel" so it is integrated nicely.
    The custom button is added via the user's control panel under the "Account' tab and in "Additional Services" (took me a while to find that one).

    Here is the code for index.php
    Code:
    <style type="text/css">
    pre {
            font-family: tahoma, arial, verdana, sans-serif;
            font-size: 12px;
            line-height: 16px;
    }
    </style>
    
    <div style="margin-left:100px;">
        <div style="width:375px; float:left;">
            <?
            $hogs = shell_exec('sudo /usr/local/sbin/hogs');
            echo 'Usage for <THEDOMAIN.COM>';
            echo "<pre>$hogs</pre>";
            ?>      
        </div>
    </div>
     
    Last edited: Apr 4, 2011
  4. dsojo

    dsojo Guest

    0
     
    hi there, thanks first for your help but i'm still having trouble. the script returns
    domain.com
    Mail Users
    0 tota
    also i try modifying iindex.php the line of sudo to sh but same result. permission are 644 for this archive and user root. i believe that something is stopping the shell_exec. the php.ini has no restriction on it .. any idea ? also the sudoers is ok
     
  5. JP Kelly

    JP Kelly Regular Pleskian

    28
     
    Joined:
    Jan 20, 2007
    Messages:
    168
    Likes Received:
    0
    Did you change /var/www/vhosts/thedomain.com/httpdocs/ to reflect your domain name? (change thedomain.com to whatever your domain is)
     
  6. dsojo

    dsojo Guest

    0
     
    hi there
    yes we change it . weird. we re using a centos 5
     
  7. JP Kelly

    JP Kelly Regular Pleskian

    28
     
    Joined:
    Jan 20, 2007
    Messages:
    168
    Likes Received:
    0
    Does it work wen you paste the command in terminal?
    Code:
    du -sk /var/www/vhosts/<THEDOMAIN.COM>/web_users/* | sort -nr | awk '{ print $2 }' | while read f ; do du -sh "$f" | awk -F/var/www/vhosts/<THEDOMAIN.COM>/web_users/ '{ print $1, "\t", $2 }' ; done
     
  8. dsojo

    dsojo Guest

    0
     
    it gives me the list ok. i think something is happening with the variable coz it displays me
    domain.....com

    Mail Users
    with nothing here
     
  9. JP Kelly

    JP Kelly Regular Pleskian

    28
     
    Joined:
    Jan 20, 2007
    Messages:
    168
    Likes Received:
    0
    I did not use any variables. The script was written to work with a single domain only.
     
  10. dsojo

    dsojo Guest

    0
     
    i refer in the index.php when it seems that the shellexec comand does not file. we re using plesk 10.1.1

    <?
    $hogs = shell_exec('sudo /usr/local/sbin/hogs'); this line is not working and i have no idea why also try sh /usr/local
    echo 'domains.com';
    echo "<pre>$hogs</pre>";
     
  11. dsojo

    dsojo Guest

    0
     
    is not working for me.i-m not saying is wrong

     
  12. JP Kelly

    JP Kelly Regular Pleskian

    28
     
    Joined:
    Jan 20, 2007
    Messages:
    168
    Likes Received:
    0
    safe mode on?

    Do you have safe_mode on?

    shell_exec() will not work with safe mode on.
     
  13. dsojo

    dsojo Guest

    0
     
    yes safe mode is off........ very weird
     
  14. JP Kelly

    JP Kelly Regular Pleskian

    28
     
    Joined:
    Jan 20, 2007
    Messages:
    168
    Likes Received:
    0
    Maybe you need the full path to sudo? e.g. /usr/bin/sudo

    Are you able to run a simpler command with shell_exec()? Such as /bin/ls /
     
  15. dsojo

    dsojo Guest

    0
     
    also try that.. nevermind we will wait for the report feature... thanks a lot for your help anyway !
     
Loading...