Matt Brookings wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Harm van Tilborg wrote:
Well almost everything did go smoothly, with the exception of things
already pointed out by Wouter (i.e. libvpopmail.so was not known by the
dynamic linker).

I've added the -R flag to the linker and this *should* work without having
to update ldconfig.  Let me know if this is not the case.

Well, I haven't checked other vpopmail binaries, since qmail was still off at that moment. But at least vusaged was rejecting to run because of it couldn't find libvpopmail.so. So I guess you haven't altered vusaged's Makefile...


vpopmaild has two functions get_user_size() and get_domain_size() (okay,
I admit, I've written these functions some time ago), they make use of
readuserquota() that calls wrapreaduserquota(), however, in stderr it
states these are deprecated, probably because of vusaged. Still, it
doesn't tell how to fix it. Using client_query(_quick?) directly, or is
there a layer in between.

These are warnings meant to be used by me to determine any functionality that
is still using these functions either in vpopmail or qmailadmin.

You will notice quota.c and quota.h are now part of vpopmail.  They contain the
new quota functions that programs should move over to.

When 5.5 goes stable, maildirquota.c probably will not be a part of vpopmail
anymore and therefore, none of the calls will either.


I've included a patch that solves (i.e. uses the new quota_* functions) at least get_user_size and get_domain_size inside vpopmail's daemon.

Ow, and here's a daemontools/supervise script to run vusaged:

Thanks!

After a few weeks and the fact that I'm fully convinced of vusaged's
behaviour :], I will try a production server that's probably a good test
case: around 3500 domains with an average of four users/domain and like
90G of mail.

Great!  Please let me know how it goes.  We have it in production at a few
locations.

Well, I found some weird behavior, as in:

[host] ~# /home/vpopmail/bin/vusagec @example.com
example.com: 4380224008 byte(s) in 22419 file(s)

See the difference with the actual usage on disk:

[host] ~# du -sb /home/vpopmail/domains/example.com
1630720386    /home/vpopmail/domains/example.com

That is with `Count directory entry size = True;'. I can't believe however, these 2.6G could come from directory inodes :].

I think this behavior is caused by the fact that I have a symbolic link inside each user directory that is using (Binc)IMAP. (Like /home/vpopmail/domains/example.com/user/Maildir/INBOX points to /home/vpopmail/domains/example.com/user/Maildir). And since all functions inside vusaged use stat(2) calls, no symlinks are discovered. I'm guessing this is resulting in some kind of a loop.

I see that behavior is as expected for people having parts of their mail via symlinks or such, however I think there should be a configuration option that states not to follow any symlinks while calculating usage, so for directory traversal only lstat(2) calls are used.

Let me know what you think Matt.

And can you perhaps explain a little how the daemon globally works, it caches all directories together with some timestamps (last check + last modify time), however, what triggers the system to recheck everything, etc. etc.

And what exactly is the age configuration option for the daemon?

--
Kind regards,
Harm van Tilborg

http://zeroxcool.net

- --
/*
    Matt Brookings <m...@inter7.com>       GnuPG Key D9414F70
    Software developer                     Systems technician
    Inter7 Internet Technologies, Inc.     (815)776-9465
*/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkoj3dkACgkQ6QgvSNlBT3BS0QCdH//M/lUXzYoB51kD2l+Yjt2C
taMAniRCKjzMFZmEVguOYXrHsDPpQnY3
=m/fY
-----END PGP SIGNATURE-----


!DSPAM:4a244a0032681316612635!
--- vpopmaild.vanilla.c 2009-06-01 20:32:04.000000000 +0200
+++ vpopmaild.c 2009-06-01 23:17:13.000000000 +0200
@@ -29,6 +29,7 @@
 #include "vauth.h"
 #include "vlimits.h"
 #include "vauthmodule.h"
+#include "quota.h"


 #include "vpopmaild.msg"
@@ -2595,8 +2596,8 @@
 int get_user_size()
 {
   char *email_address;
-  int ret, cnt;
-  long bytes;
+  int ret;
+  storage_t bytes, count;

   if (!(AuthVpw.pw_gid & QA_ADMIN) && !(AuthVpw.pw_gid & SA_ADMIN)) {
     snprintf(WriteBuf, sizeof(WriteBuf), RET_ERR "3801 not authorized" 
RET_CRLF);
@@ -2628,19 +2629,18 @@
     return(-1);
   }

-  bytes = 0;
-  cnt = 0;
-  if ((ret = readuserquota(tmpvpw->pw_dir, &bytes, &cnt)) != 0) {
-    snprintf(WriteBuf, sizeof(WriteBuf),
+  bytes = count = 0;
+  if ((ret = quota_get_usage(email_address, &bytes, &count)) != 1) {
+    snprintf(WriteBuf, sizeof(WriteBuf),
       RET_ERR "3806 unable to fetch size of user account" RET_CRLF);
     return(-1);
   }

   snprintf(WriteBuf, sizeof(WriteBuf), RET_OK_MORE);
   wait_write();
-  snprintf(WriteBuf, sizeof(WriteBuf), "size %ld" RET_CRLF, bytes);
+  snprintf(WriteBuf, sizeof(WriteBuf), "size %llu" RET_CRLF, bytes);
   wait_write();
-  snprintf(WriteBuf, sizeof(WriteBuf), "count %d" RET_CRLF, cnt);
+  snprintf(WriteBuf, sizeof(WriteBuf), "count %llu" RET_CRLF, count);
   wait_write();
   snprintf(WriteBuf, sizeof(WriteBuf), "." RET_CRLF);

@@ -2649,11 +2649,9 @@

 int get_domain_size()
 {
-  char *domain, tmpdir[256];
-  int ret, cnt, first;
-  long bytes;
-  unsigned int totalcnt;
-  unsigned long long totalbytes;
+  char *domain, email_address[256];
+  int ret, first;
+  storage_t bytes, count;

   if (!(AuthVpw.pw_gid & QA_ADMIN) && !(AuthVpw.pw_gid & SA_ADMIN)) {
     snprintf(WriteBuf, sizeof(WriteBuf),
@@ -2677,37 +2675,40 @@
   snprintf(WriteBuf, sizeof(WriteBuf), RET_OK_MORE);
   wait_write();

-  totalbytes = 0;
-  totalcnt = 0;
   first = 1;
   while ((tmpvpw = vauth_getall(domain, first, 0)) != NULL) {
     first = 0;
-    bytes = 0;
-    cnt = 0;
-    snprintf(tmpdir, sizeof(tmpdir), "%s/Maildir", tmpvpw->pw_dir);
-    if ((ret = readuserquota(tmpdir, &bytes, &cnt)) != 0) {
-      snprintf(WriteBuf, sizeof(WriteBuf),
-        RET_ERR "3904 unable to fetch size of user accounts '%s'" RET_CRLF, 
tmpvpw->pw_name);
+    bytes = count = 0;
+    snprintf(email_address, sizeof(email_address), "%...@%s", tmpvpw->pw_name, 
domain);
+    if ((ret = quota_get_usage(email_address, &bytes, &count)) != 1) {
+      snprintf(WriteBuf, sizeof(WriteBuf),
+        RET_ERR "3904 unable to fetch size of account '%s'" RET_CRLF, 
email_address);
       return(-1);
     } else {
-      snprintf(WriteBuf, sizeof(WriteBuf), "user %...@%s" RET_CRLF, 
tmpvpw->pw_name, domain);
+      snprintf(WriteBuf, sizeof(WriteBuf), "user %s" RET_CRLF, email_address);
       wait_write();
-      snprintf(WriteBuf, sizeof(WriteBuf), "size %ld" RET_CRLF, bytes);
+      snprintf(WriteBuf, sizeof(WriteBuf), "size %llu" RET_CRLF, bytes);
       wait_write();
-      snprintf(WriteBuf, sizeof(WriteBuf), "count %d" RET_CRLF, cnt);
+      snprintf(WriteBuf, sizeof(WriteBuf), "count %llu" RET_CRLF, count);
       wait_write();
-      totalbytes += (unsigned long)bytes;
-      totalcnt += (unsigned int)cnt;
     }
   }

-  snprintf(WriteBuf, sizeof(WriteBuf), "domain %s" RET_CRLF, domain);
-  wait_write();
-  snprintf(WriteBuf, sizeof(WriteBuf), "size %llu" RET_CRLF, totalbytes);
-  wait_write();
-  snprintf(WriteBuf, sizeof(WriteBuf), "count %u" RET_CRLF, totalcnt);
-  wait_write();
-  snprintf(WriteBuf, sizeof(WriteBuf), "." RET_CRLF);
+  bytes = count = 0;
+  snprintf(email_address, sizeof(email_address), "@%s", domain);
+  if ((ret = quota_get_usage(email_address, &bytes, &count)) != 1) {
+    snprintf(WriteBuf, sizeof(WriteBuf),
+      RET_ERR "3905 unable to fetch size of domain '%s'" RET_CRLF, domain);
+    return(-1);
+  } else {
+    snprintf(WriteBuf, sizeof(WriteBuf), "domain %s" RET_CRLF, domain);
+    wait_write();
+    snprintf(WriteBuf, sizeof(WriteBuf), "size %llu" RET_CRLF, bytes);
+    wait_write();
+    snprintf(WriteBuf, sizeof(WriteBuf), "count %llu" RET_CRLF, count);
+    wait_write();
+    snprintf(WriteBuf, sizeof(WriteBuf), "." RET_CRLF);
+  }

   return(0);
 }

!DSPAM:4a244a0032681316612635!

Reply via email to