SOLVED Bulk Reset Package Bandwidth Limit for all users on multiple servers

fatidol

Registered
Jul 12, 2018
3
1
3
Slovenia
cPanel Access Level
Root Administrator
Hi guys,

in our infrastructure we have a lot of cPanel servers (100+) and we have bandwidth limits on packages controlled by Puppet. Recently we changed BW limit but this limits are changed only on newly created accounts the old ones stay the same.

Looking into /scripts directory does not reveal any scripts that could reset to package Bandwidth limit for user or maybe all users on a server. I've also checked API documentation if there is anything but i could not find nothing to grasp on. I know this can be changed for an account if you go to Home »Account Functions »Reset Account Bandwidth Limit and click on every possible account, but this is not the best solution if you have such a big scope of servers.

One thing i tried is to change BWLIMIT to the value of new packages limit in /var/cpanel/users and run the following script /usr/local/cpanel/scripts/updateuserdomains but if i go to Home »Account Functions »Modify an Account i can still see message in red saying: "Package value: 1,000,000,000"

Is there any other way to change this via SSH for mass action of Reset Account Bandwidth Limit?

Thanks, A.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
in our infrastructure we have a lot of cPanel servers (100+) and we have bandwidth limits on packages controlled by Puppet. Recently we changed BW limit but this limits are changed only on newly created accounts the old ones stay the same.
Hello @fatidol,

If you changed the bandwidth limit itself on a package, the new limit should automatically apply to any accounts assigned that package. If that did not happen, could you let us know the full steps you took to edit the existing package?

Or, are you attempting to simply reset the existing bandwidth usage for multiple accounts, regardless of the value associated with the package assigned to the account?

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
sorry for the confusion, i would like to reset the existing bandwidth limit for multiple accounts if that is possible.
Hello @fatidol,

There's no option to do this for multiple accounts, but simply editing the package associated with the accounts using WHM >> Edit a Package will achieve the same result. It automatically updates the assigned bandwidth limit for any account assigned that package to the new bandwidth limit.

Thank you.
 

fatidol

Registered
Jul 12, 2018
3
1
3
Slovenia
cPanel Access Level
Root Administrator
There's no option to do this for multiple accounts, but simply editing the package associated with the accounts using WHM >> Edit a Package will achieve the same result. It automatically updates the assigned bandwidth limit for any account assigned that package to the new bandwidth limit.
Hey,

thank you for your suggestion, this issue was resolved with the following command that searches for all packages that have BWLIMIT set to 100000000 and changes only for them.

Code:
while read -u 9 package ; do whmapi1 editpkg name=$package bwlimit=100000000; done 9< <( cd /var/cpanel/packages/ ; fgrep -R -l 'BWLIMIT=100000000' )
Hope this helps anyone who is looking for similar action.

Best, A.

Note: This also generated email for each changed package to default sysadmin address, so proceed with caution.
 
  • Like
Reactions: cPanelMichael

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello @fatidol,

I'm glad to see you were able to solve the issue. Thank you for sharing the solution.