Jump to content

Update VPS Bandwidth usage


Gibby13

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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