The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

list_pops_with_disk doesn't update

Discussion in 'cPanel Developers' started by Scruff, Dec 8, 2015.

  1. Scruff

    Scruff Registered

    Joined:
    Dec 8, 2015
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Sydney
    cPanel Access Level:
    Website Owner
    Hi all. I'm new to this site and to cPanel API's in general.

    I've come across a strange problem....

    I'm using the UAPI list_pops_with_disk function to retrieve the disk usage for email accounts. Everything works fine, except the data doesn't update unless I reset the quota for each account first. Here's what's happenning:

    Let's say I send a 2 MB email to test@mydomain.com.
    If I now log into the cPanel web interface, it correctly shows that there is 2/25 MB used for that account.

    If I now send the list_pops_with_disk API request, all the fields relating to space used are zero (diskusedpercent, diskused, _diskused, diskusedpercent20), and humandiskused = "None".

    If I now reset the quota (using the current value of 25 MB) by calling the edit_pop_quota API, and then call list_pops_with_disk again, the correct usage shows up in the result.

    Next, I fire up my email client, and retrieve the message, thereby emptying the inbox on the server. At this point, I can refresh the web interface and it shows zero usage, but a call to the API shows the same usage as before the messages were deleted (2 MB), until after I send another call to edit_pop_quota.

    The results from list_pops_with_disk are simply not updating at all. It's as if the API and the web interface are reading two different sets of data. I would have thought that both methods would be reading actual usage "on the fly", but that doesn't appear to be the case with the API.

    I'm using PHP, and appending '...&cache_fix=' . time() to the end of each request, so I doubt that it's any kind of caching problem.

    Anyone got any ideas about what's going on?

    I think the cPanel version is 11.52 if that helps.

    Thanks in advance.
     
  2. Scruff

    Scruff Registered

    Joined:
    Dec 8, 2015
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Sydney
    cPanel Access Level:
    Website Owner
    An update...

    I created a PHP script to check which files are being accessed in order to determine the disk usage.

    When refreshing the web interface (https://cpanel.domain.tld/cpsessXXXXXXXXXX/frontend/x3/mail/pops.html), a whole bunch of files have changed modification and access times:

    /.cpanel/email_accounts.cache
    /.cpanel/email_accounts_count
    /.cpanel/caches/statcache_persistant
    /.cpanel/datastore/diskusage_{user@domain.tld}
    (one for each email account, but not all are accessed???)
    /mail/maildirsize
    /mail/{domain.tld}/{user}/maildirsize
    (again one for each account, but not all are accessed)

    Looking at the filenames, this list mostly makes sense. What's strange though, is that the diskusage_ and maildirsize files that are skipped, are the ones which relate to accounts where the actual disk usage is not zero.

    The list_pops_with_disk api however, doesn't log a single access. No files at all have changed access times after the call. This (at least to me) doesn't make any sense at all.

    After a lot of searching, I have found a sort of workaround for obtaining "real time" email account disk usage, without having to send a separate API call for each pop account.

    The workaround is to delete the /.cpanel/email_accounts.yaml file. When you call the API, the file is automatically recreated, and the correct disk usage is returned. What's curious about this, is that neither the web interface nor the API appear to access this file (at least not for the purpose of checking disk usage anyway). It doesn't make any sense, but deleting this file before each call to list_pops_with_disk works, and is the only way that I can get the API to behave as it should.

    This is far from an acceptable long term solution though. Is this strange behaviour a bug?
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,675
    Likes Received:
    647
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Could you verify if disabling "Cache disk quota information" under the "System" tab in "WHM >> Tweak Settings" affects the behavior you are experiencing?

    Thank you.
     
  4. Scruff

    Scruff Registered

    Joined:
    Dec 8, 2015
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Sydney
    cPanel Access Level:
    Website Owner
    Hi Michael. This is paid hosting, so I don't have access to any Server Configuration settings. I've logged into to the web interface, and can't find any such cache settings at all.

    I did a search on the Cache disk quota information setting, and from what I found, this may have been the issue.

    I have just commented out the line in my script that deletes the email_accounts.yaml file, and ran some tests. Everything seems to now be updating as it should. The host did do some maintenance over the the new year period, so I suspect that some settings have been changed.

    For now though, everything seems to be working correctly.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,675
    Likes Received:
    647
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I am happy to see it's now working well. Thank you for updating us with the outcome.
     
Loading...
Similar Threads - list_pops_with_disk doesn't update
  1. sparek-3
    Replies:
    2
    Views:
    229
  2. mtorromeo
    Replies:
    5
    Views:
    462

Share This Page