Gibby13 Posted March 13, 2012 Share Posted March 13, 2012 So I have a script that grabs how much bandwidth a client is allowed and gathers the usage once a night. It puts it into a comma separated file in MB. I need to put this in the whmcs DB. I know I need to put this in the tblhosting table, for bwusage and bwlimit. I digging around in the WHMCS api since I would think that would be easier, however I do not see the correct API call to update those 2 field in the Update Client Product API usage. Any help? Also once those fields are populated will it then show that data in the client area and admin area? 0 Quote Link to comment Share on other sites More sharing options...
Gibby13 Posted March 13, 2012 Author Share Posted March 13, 2012 So I found the UsageUpdate function, just no clear where to start on customizing it. This is what I want: Take this function function mymodule_UsageUpdate($params) { $serverid = $params['serverid']; $serverhostname = $params['serverhostname']; $serverip = $params['serverip']; $serverusername = $params['serverusername']; $serverpassword = $params['serverpassword']; $serveraccesshash = $params['serveraccesshash']; $serversecure = $params['serversecure']; # Run connection to retrieve usage for all domains/accounts on $serverid # Now loop through results and update DB foreach ($results AS $domain=>$values) { update_query("tblhosting",array( "diskused"=>$values['diskusage'], "dislimit"=>$values['disklimit'], "bwused"=>$values['bwusage'], "bwlimit"=>$values['bwlimit'], "lastupdate"=>"now()", ),array("server"=>$serverid,"domain"=>$values['domain'])); } } And update with this data from a file [chris@ots1 bwlogs]$ cat 03132012.bw.MB.log ClientID,ProductID,Appliance,Total,Allowed,Left 4,31,OTS2,10321.92MB,2048000MB,2037678.08MB It needs to be based on client ID then Product ID, then update the bwusage from Total and bwlimit from Allowed for each line in the log file I do not care about the domain, just for client ID then product id, update bwusage and bwlimit DB=whmcs Table=tblhosting ClientID Column=userid Product ID = id bwusage = bwusage bwlimit = bwlimit Sorry it it was to detailed, I just copied from an email I sent to a co-worker that said he would take a look 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.