• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • Our UX team believes in the in the power of direct feedback and would like to invite you to participate in interviews, tests, and surveys.
    To stay in the loop and never miss an opportunity to share your thoughts, please subscribe to our UX research program. If you were previously part of the Plesk UX research program, please re-subscribe to continue receiving our invitations.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

CLI command or SQL query to find the size of a mailbox

Miguel_Tellería

Basic Pleskian
Plesk 12.0.18 on Centos 6.6.

Dear all,

In order to do automate some statistics i would like to have a quick way to see the size the mailboxes.

I know that I could execute a du -shc under /var/qmail/mailnames/<domain>/<mailbox> but for large mailboxes it will take a lot of time.

On the other hand Plesk reports mailbox sizes and occupation very fast (although not always up to date as I have noticed). This is the data that I would like to fetch which is good enough for my purposes.

I have tried the output of /usr/local/psa/bin/mail --info but it doesn't have that value. Is there another way to obtain it?

Regards,

Miguel Telleria
 
[root@ppu12-0 ~]# /usr/local/psa/admin/bin/mailbox_usage --help
Usage: mailbox_usage [--in-blocks]
STDIN should contain a set of '<domain_name> <mailbox_id> <mailbox_name>' strings
STDOUT will contain a set of '<counted_usage> <domain_name> <mailbox_id> <mailbox_name>' strings

[root@ppu12-0 ~]# /usr/local/psa/admin/bin/mailbox_usage --in-block
ppu12-0.demo.pp.plesk.ru 1 admin
5212 ppu12-0.demo.pp.plesk.ru 1 admin
 
Hello IgorG,

I have tried your approach, using mailbox_id to 1 in all lists, since I don't know what mailbox_id is.

It works so far for me, although I always get an enigmatic error: "Unable to parse string: <blank>"

I am trying another approach based on the database and the mn_param table.

SELECT mail.mail_name, domains.name, mn_param.val, mail.mbox_quota FROM mail, mn_param, domains WHERE mail.id=mn_param.mn_id AND mail.dom_id=domains.id AND mn_param.param='box_usage' and mail.mail_name="NAMEBEFORE@" and domains.name="DOMAIN"

I assume that this would also be equivalent.
 
You can find IDs of mailboxes with

mysql> select concat(mail.mail_name,"@",domains.name) as address, mail.id from mail,domains,accounts where mail.dom_id=domains.id and mail.account_id=accounts.id order by address;
 
I want to use the mailbox_usage command.
SQL can now look up mailbox IDs.
How do I actually use the mailbox_usage command?

For example, if I wanted to look up [email protected] and the ID of this email address was 10, would the command look like this?

# /usr/local/psa/admin/bin/mailbox_usage --in-block example.com 10 mailadd
 
How do I actually use the mailbox_usage command?
You have to run the command:

# /usr/local/psa/admin/bin/mailbox_usage --in-block

then type

example.com 10 mailadd

and get something like

2026868 example.com 10 mailadd

in output. More details in help:

# /usr/local/psa/admin/bin/mailbox_usage --help
Usage: mailbox_usage [--in-blocks]
STDIN should contain a set of '<domain_name> <mailbox_id> <mailbox_name>' strings
STDOUT will contain a set of '<counted_usage> <domain_name> <mailbox_id> <mailbox_name>' strings
 
Thanks IgorG!

I was able to get the value by the method you told me. Please tell me one more thing.
What value is returned by this command?
I want to get the mailbox utilization with the CLI, but I get the maximum value for each mailbox with the following command, and even though the mailbox is 100%, the values don't match.

A. /usr/local/psa/bin/mail -i [email protected] | grep 'Mbox quota'
If there is "Unlimited"
B. /usr/local/psa/bin/subscription_settings -i example.com | grep mbox_quota
(If the suffix is KB, multiply by 1024, suffix is MB, multiply 1024000...)

Is the way of thinking wrong?
English may be strange because I use machine translation. Sorry.
 
Back
Top