Jump to content

Kamran

Regular Collector
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

3 Neutral

About Kamran

  • Rank
    Junior Member

Recent Profile Visitors

320 profile views
  1. Hi, I want to perform some tasks that require the service id on a hook(specifically invoice creation) the paramters there are limited all I get is the invoice id. Is there a way to fetch service id using that invoice id any indication/help/solution would be highly appreciated. The hook must trigger either before or after invoice generation. Thanks. ūüĎć
  2. @WHMCS David The problem is partially SOLVED huge thanks to @Lobster (who was in touch on direct message)for his help so my problem was I needed to use the below mentioned code in the metadata(This is not included in the sample provisioning code) 'ListAccountsUniqueIdentifierField'=> 'domain', Now TYPE_SNAPSHOT works fine along with TYPE_PERIOD_MONTH but I'm facing problems with TYPE_PERIOD_DAY my code is still the same only change is that now my metrics function becomes public function metrics() { return [ new Metric( 'dsk', 'Disk', MetricInterface::TYPE_PERIOD_DAY, new GigaBytes() ), new Metric( 'vm', 'VMs', MetricInterface::TYPE_SNAPSHOT, new WholeNumber("vms") ) ]; } everything works fine except the metric disk which is TYPE_PERIOD_DAY let me know please if you have any suggestions. By the way @WHMCS David glad to know WHMCS really cares about it's clients and their needs your and @Lobster's help is much appreciated! Thanks for hearing me out..
  3. Hi @WHMCS David Thank you for responding as this is quite critical for my employer, much appreciated! I understand your concern but I've returned MyMetricsProvider(implements ProviderInterface). Secondly now I'm following you on the tenant id part and I'm using service properties to set username as well as domain and then keying the domain name so my new api call function is this private function apiCall($action) { if($action == "stats"){ return[ [ "username" => "kamran2.com", "disk" => 99 ] ]; } return[ [ "disk" => 100 ] ]; } And as per your advised method I'm not passing any Usage object on metrics function, everthing else is the same as what I've provided on my original post but still I'm not getting the desired output even on the admin area the result I see on the admin area is provided below Also whenever I click on refresh now tenantUsage() function didn't run(I verify using module logs I've placed logModuleCall() in both Usage() and TenantUsage()) also I tried to check if the database stores the values correctly so below is the result for: tblserver_tenants | 19 | 4 | kamran2.com | 2020-01-20 20:43:02 | 2020-01-20 21:01:27 | tbltenants_stats | 57 | 19 | disk | snapshot | 99.000000 | 1579554086.759813 | 0 | 2020-01-20 21:01:26 | 2020-01-20 21:01:26 | +----+-----------+----------------+----------+------------+-------------------+------------+---------------------+---------------------+ So clearly values are tracked correctly right? Also I didn't modify or inset anything on the database and let WHMCS do the job I just checked.
  4. Hi Chris,

              Can you please look into why usage metrics is not working for 3rd party provisioning module developers or please ask your team to help as soon as possible.I've sent a ticket to WHMCS support but according to them they do not cater tickets related to 3rd party module development so can you please get us into speed as usage metrics is very important for my employer and we're soon heading towards a product launch so time is ticking for us, any kind of help regarding solving this issue will be highly appreciated!

    P.S. Syntax is not the issue here(just so you know)

  5. Hi, What is the meaning of a tenant in context to WHMCS and what is meant by tenant id? I've tried a lot of options like using serviceid, clientid and productid as tenantid but nothing works here is the link where this term is mentioned. Thanks!
  6. Greetings, I'm developing a module for my service which tracks usage information and my current module works fine, usage metrics which released for WHMCS v7.9 attracted me and hence found a use case for my service but the issue that I am facing is usage data won't update (not even once!) I've followed all these links including Usage billing feature doc, Usage metrics provisioning module doc and class doc whereas have posted my relevant code and details on whmcs community under whmcs 7.9 beta discussion but did not recieve any help so far on this issue below is the link for that post: If anyone in the community(either from WHMCS staff or anyone ) knows what's wrong and can help it'll be much appreciated as this feature is quite important for my organization. Thank you!
  7. Greetings, I'm developing a module to setup a user on my server and sync their usage data to whmcs. I've successfully contextualized usage metrics now the big issue here is how whmcs track usage metrics my progress so far is below: I've created a new class which implements "ProviderInterface" below is the code for "metrics" function public function metrics() { return [ new Metric( 'disk', 'Disk Utilized', MetricInterface::TYPE_SNAPSHOT, new MegaBytes, new Usage(0) ) ]; } usage function is public function usage() { $serverData = $this->apiCall('stats'); $usage = []; foreach ($serverData as $data) { $usage[$data['username']] = $this->wrapUserData($data); } return $usage; } tenantusage function is public function tenantUsage($tenant) { $userData = $this->apiCall('user_stats'); return $this->wrapUserData($userData); } helper wrapuserdata function is: private function wrapUserData($data) { $wrapped = []; foreach ($this->metrics() as $metric) { $key = $metric->systemName(); if ($data[$key]) { $value = $data[$key]; $metric = $metric->withUsage( new Usage($value) ); } $wrapped[] = $metric; } return $wrapped; } And lastly helper apicall function which delibrately sends a value somewhat emulating an api call for now. private function apiCall($action) { if($action == "stats"){ return [ [ "username" => "kamran@domain.com", //this represents my username which is provided to whmcs "disk" => 100 ] ]; } else{ return [ [ "disk" => 100 ] ]; } } Okay so far in the above mentioned code, date and time updates but usage details are not updating. BTW I'm checking metrics using module parameters using $params["metricStats"][0]["currentvalue"] So please help me with the below mentioned questions. What is the correct way to return "usage()" function including what should be the identifier of the tenant(i.e. the key of value usage object where key should be serviceid?accountid?userid? of the tenant)? Whenever cron job "TenantUsageMetrics" runs only "usage()" function is invoked and never "tenantusage()" why? Also if my syntax is wrong a possible example would be tremendous. Thank you for hearing me out!
  8. Welcome to WHMCS.Community Kamran! We're glad you're here please take some time to familiarise yourself with the Community Rules & Guidelines and take a moment to introduce yourself to other WHMCS.Community members in the Introduce Yourself Board.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated