bluesteam Posted June 13, 2023 Share Posted June 13, 2023 I received a call from a client this morning asking me why his stats dashboard in WHMCS is still showing that his account is full but his cPanel account shows his account is empty. After checking with the client, I determined that his account WAS originally full and he went and cleared out a bunch of files to free up space. So I asked him how long ago and he said about 10minutes ago. So I explained to him that this statistic on his dashboard doesn't update immediately but could take some time. HOWEVER, After checking on my side on his account through the ADMIN dashboard, I see that it has updated correctly for me. So I thought, "hmmm...maybe I should update the disk usage report to force it to update" so I navigate to the Disk Usage Summary Report and right at the bottom, I click the Update Now link to force it to update. I then go back to his profile only to find that the stat is still showing the old value. This is VERY confusing to the clients as they could think that they still have rogue files somewhere and will pollute our help desk with these questions. Am I the only one who sees this as a problem? In my opinion, what should happen is whenever the client accesses the product page, it should quickly perform a cPanel API call to get the latest disk usage information to correctly reflect the details to the client to prevent this confusion. 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted June 13, 2023 Share Posted June 13, 2023 Hello @bluesteam, How are you? Just to check this first, can you show me, this table here in the Service Profile? And also try to show me this, do you have it? See you soon! 0 Quote Link to comment Share on other sites More sharing options...
bluesteam Posted June 13, 2023 Author Share Posted June 13, 2023 12 minutes ago, andrezzz said: Hello @bluesteam, How are you? Just to check this first, can you show me, this table here in the Service Profile? And also try to show me this, do you have it? See you soon! Thank you so much for being willing to help me understand this. Here is the Statistics: So as you can see, it still shows the old values for the client even though at the top for me on the same profile page it shows it as updated. I have also checked the client's service page and the Last Updated does not show there at all. This might be theme related though. As a last note, I know that if I click the "Refresh now" button on the bottom right, it will update it but we shouldn't have to update it if it has already updated for us as admins. 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted June 13, 2023 Share Posted June 13, 2023 Just to be clear on this, to check if it's possible to create a Hook or not for it if you Refresh now, does it update on the Client Side? 0 Quote Link to comment Share on other sites More sharing options...
bluesteam Posted June 13, 2023 Author Share Posted June 13, 2023 50 minutes ago, andrezzz said: Just to be clear on this, to check if it's possible to create a Hook or not for it if you Refresh now, does it update on the Client Side? Hello, Yes, hitting the refresh now definitely corrects the issue but I just feel that we shouldn't have to write any hooks or mods just to get this to work like it should. Don't you agree? 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted June 13, 2023 Share Posted June 13, 2023 (edited) Well... I agree, but what should we do? We can't change the code or wait some months/years, for it to be changed, so I usually make Hooks to work around it. There are differences between the statistics since one is for "the record" and the other one is for Billing for excessive usage etc. The upper one is the Service Metric (Usage Update), saved on the table `tblhosting`, as `diskusage`, `disklimit`, `bwusage` and`bwlimit` columns. Belongs to WHMCS\Service\Service. This is a daily import of the usage of ALL the services inside that Server. Runs on Daily Cron Job. The other is a Usage Billing (Usage Metrics), saved on the table `tbltenant_stats` (`tenant_id` from `tblserver_tenants`, searching by the domain). Belongs to, I think, since it calls the function `MetricProvider`, WHMCS\Product\Server. According to the documentation, this runs twice a day, via the `TenantUsageMetrics` cron task, maybe isn't running correctly? Try running this command and check for any errors: php -q /path/to/whmcs/crons/cron.php --TenantUsageMetrics -vvv More information: https://docs.whmcs.com/Cron_Job_Issues If you wanna, dm me and we discuss it further. Edited June 13, 2023 by andrezzz 0 Quote Link to comment Share on other sites More sharing options...
bluesteam Posted June 13, 2023 Author Share Posted June 13, 2023 I ran the command from the terminal in cPanel and received an exception stating the following: 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted June 13, 2023 Share Posted June 13, 2023 Funny, their documentation have it like that: https://docs.whmcs.com/Usage_Billing#:~:text=General Settings.-,Usage Data Collection,-Usage data is Try without the "--", maybe I mistaken it. 0 Quote Link to comment Share on other sites More sharing options...
bluesteam Posted June 13, 2023 Author Share Posted June 13, 2023 Still not. 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted June 13, 2023 Share Posted June 13, 2023 (edited) My mistake, checked now and it's working as: php cron.php do --TenantUsageMetrics -vvv Edited June 13, 2023 by andrezzz 0 Quote Link to comment Share on other sites More sharing options...
bluesteam Posted June 13, 2023 Author Share Posted June 13, 2023 That did the trick but no errors: 0 Quote Link to comment Share on other sites More sharing options...
Solution andrezzz Posted June 13, 2023 Solution Share Posted June 13, 2023 Sadly, the only option here is using a Hook/Cron. 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted June 13, 2023 Share Posted June 13, 2023 Can you open `whmcs/crons/cron.php` and tell us the WHMCS version inside ? Is it the same as your WHMCS installation ? 0 Quote Link to comment Share on other sites More sharing options...
bluesteam Posted June 13, 2023 Author Share Posted June 13, 2023 34 minutes ago, pRieStaKos said: Can you open `whmcs/crons/cron.php` and tell us the WHMCS version inside ? Is it the same as your WHMCS installation ? Yup, the same. 8.7.2 0 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted June 13, 2023 Share Posted June 13, 2023 (edited) Its awful and misleading as the updated time just shows the time you visited the product details page in the client area. You can hook on to the cron (which theoretically should run every 5 minutes or so) to automatically update these more frequently. use WHMCS\Service\Service; use Illuminate\Database\Eloquent\Relations\BelongsTo; add_hook( 'AfterCronJob', 1, function () { try { Service::active() ->with( [ 'serverModel' => function ( BelongsTo $query ) { $query->where( 'type', 'cpanel' ); } ] ) ->each( function ( Service $service ) { $service->serverModel->syncTenantUsage( $service->domain ); } ); } catch ( \Exception $e ) {} } ); Edited June 13, 2023 by leemahoney3 1 Quote Link to comment Share on other sites More sharing options...
WHMCS Support Manager WHMCS John Posted June 15, 2023 WHMCS Support Manager Share Posted June 15, 2023 Hi all, I'd like to take the opportunity to provide some clarification on how WHMCS collects and shows usage for shared hosting services. 1. The Disk and Bandwidth usage stats (and last updated date) shown at the top of the Products/Services tab and the client area Service Details page, are taken from the same source. This is collected once per day by the UpdateServerUsage task of the by the Daily Cron Job. Here's what those interfaces look like: 2. The Metric Statistics, further down the admin area and client area pages, are handled separately. They relate to the Usage Billing feature and will be updated twice per day, if you've enabled billing usage billing for that particular Metric. These value are updated twice per day when the TenantUsageMetrics task is run by cron task scheduler, and also immediately prior to invoice generation. Here's what those interfaces look like when Usage Billing is enabled: 0 Quote Link to comment Share on other sites More sharing options...
bluesteam Posted June 15, 2023 Author Share Posted June 15, 2023 (edited) @WHMCS John Hi John, I respectfully disagree. Actually what the client sees is what is shown below. I confirmed that in my post linked below as well as my original post: Not the stat at the top of the Product/Services page as you mentioned. And this is why it's an issue as the client is seeing old data that will only be updated the next day and now they pollute the help desk with queries as to why cPanel and their account is different and ask us why is WHMCS telling them to STILL upgrade after they have already cleared out their disk usage. Edited June 15, 2023 by bluesteam 0 Quote Link to comment Share on other sites More sharing options...
Mark Posted October 20, 2023 Share Posted October 20, 2023 @bluesteam did you ever manage to resolve this? 0 Quote Link to comment Share on other sites More sharing options...
bluesteam Posted October 20, 2023 Author Share Posted October 20, 2023 28 minutes ago, Mark said: @bluesteam did you ever manage to resolve this? Nope, still a problem. Don't hold your breath for a solution. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted October 21, 2023 Share Posted October 21, 2023 *waits for "open a feature request" 1 Quote Link to comment Share on other sites More sharing options...
Mark Posted October 23, 2023 Share Posted October 23, 2023 I think the solution for now is running --UpdateServerUsage and --TenantUsageMetrics with the same frequency? 0 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted October 26, 2023 Share Posted October 26, 2023 On 10/20/2023 at 3:42 PM, bluesteam said: Nope, still a problem. Don't hold your breath for a solution. The hook I provided should do the trick for now? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.