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.

Enforcing bandwidth limit

Discussion in 'cPanel Developers' started by odmink0, Feb 29, 2012.

  1. odmink0

    odmink0 Member

    Joined:
    Feb 29, 2012
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Russia
    cPanel Access Level:
    Reseller Owner
    Hello.

    In the description of the "limitbw" WHM API function we can see that one of the returned parameters is "bwlimitenable", which indicates "whether or not the bandwidth limit is enforced".

    When I try to set different limits for the user via API calls, I always get 0 for this parameter.

    What will be done to user when he will run out of bandwidth limit? Is it possible to set this parameter to 1 somehow?
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi odmink0,

    If you call 'limitbw' with a 'bwlimit' value greater than 0, the 'bwlimitenabled', in the return response, will be 1. To disable bandwidth limit (have 'bwlimitenabled' response of 1), then you must pass a 'bwlimit' value of 0 or 'unlimited'.

    If a bwlimit is set for a user (i.e., 'bwlimitenabled' of 1), and that user exceeds that limit, the account will be suspended.

    Regards,
    -DavidN

    PS. I think the JSON response example on that page is incorrect. I've filed an internal Documentation case (57864) to have this investigated and updated appropriately...I'm fairly certain it should be:
    Code:
    {
       "result":[
          {
             "status":1,
             "statusmsg":"Bandwidth Limit for joe set to 5",
             "bwlimit":{
                "bwlimitenable":1,
                "human_bwlimit":"5 MB",
                "domains":[
                   "example.com"
                ],
                "unlimited":0,
                "bwlimit":5242880,
                "human_bwused":"none"
             }
          }
       ]
    }
    
     
  3. odmink0

    odmink0 Member

    Joined:
    Feb 29, 2012
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Russia
    cPanel Access Level:
    Reseller Owner
    Hi, thanks for the answer, but in my case "bwlimitenable" was not set to 1 even when I have set "bwlimit" to the values like 100 or 500 Mb.

    Though maybe that's because I'm using an old (v11.30.6.4) cPanel with a trial license for testing.
    I'll better try it on a newer version with a working license and will tell if anything goes wrong.
     
  4. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    It's possible that the trial license is affecting it, and there might be a bug in 11.30.6.4, however, I haven't heard of either. If you continue to see this, post up sample code and/or detailed api request and output.

    Regards,
    -DavidN
     
Loading...

Share This Page