ABillS. Mass shaping of speed in case of accidents

In this article, I will give an example of how you can massively reduce the speed of users in the ABillS billing system.

In the service of each user, in the “Speed (kb)” field, you can specify an individual speed, the priority of which is higher than that of the tariff plan, the speed is indicated by one number in both directions, for example 50000, in the “Filter” field, you can specify individual Radius parameters for the client, for example, the download speed, and the outgoing speed will remain according to the tariff (since it is not specified), or you can also specify the parameter for the outgoing speed separated by a comma.

I will give an example of changing the individual speed of a SQL query:

UPDATE internet_main SET speed=1500 WHERE tp_id NOT IN (1600, 1601) LIMIT 10;
UPDATE internet_main SET speed=1500 WHERE tp_id NOT IN (1600, 1601);
SELECT * FROM internet_main WHERE speed !=0;

An example of clearing the individual speed field:

UPDATE internet_main SET speed="" WHERE tp_id NOT IN (1600, 1601);

An example of specifying radius parameters in the “Filter” field:

RAD: PPPD-Downstream-Speed-Limit=20000

After specifying and clearing the field of individual speed or radius parameters, you need to re-authorize all sessions or execute a script that will transfer speed parameters using CoA requests.

You can also change the speed of clients on a schedule, for example, if several intervals with different speeds are specified in the tariff plan settings, then at the border of the intervals in cron, you need to add a script that will transfer the speed parameters to the access server, for example:

1 17 * * * root /usr/abills/libexec/billd checkspeed NAS_ID=11 > /dev/null 2>&1
30 23 * * * root /usr/abills/libexec/billd checkspeed NAS_ID=11 > /dev/null 2>&1

But first, let’s do it manually for a test, for example for aceel-ppp:

/usr/abills/libexec/billd checkspeed accel_ppp=1 NAS_ID=11
/usr/abills/libexec/billd checkspeed accel_ppp=1 NAS_ID=11 DEBUG=7

Session view example:

/usr/abills/libexec/billd checkspeed accel_ppp=1 SHOW_SPEED=1 NAS_ID=11
/usr/abills/libexec/billd check_accel_ppp=1 NAS_ID=11 SHOW=1

Script for changing the speed on Juniper according to the tariff (the script deactivates the current profile and activates a new one):

/usr/abills/libexec/billd mx80_change_profile LOGIN=test PROFILE="svc-global-ipoe(524288,1048576)" DEBUG=1

With the START=1 option, change the speed on Juniper for all clients to the specified svc-global-ipoe(524288,1048576), speed value in bytes, return the speed according to the tariff a second time:

/usr/abills/libexec/billd mx80_change_profile PROFILE="svc-global-ipoe(524288,1048576)" START=1
/usr/abills/libexec/billd mx80_change_profile PROFILE="svc-global-ipoe(524288,1048576)"

See my article:
Juniper MX. How to view user session speed

You can also end all sessions with a script:

cd /usr/abills/misc/
./autozh.pl DEBUG=1 HANGUP=1

Another example of soft termination of sessions by accel-ppp:

telnet 127.0.0.1 2000
terminate all soft

If, of course, soft-terminate=1 is specified in the accel-ppp configuration, then when requesting to renew the lease of an IP address, accel-ppp will respond to the DHCPNAK client, which will provoke a DHCPDISCOVER request from the client to obtain a new IP address and the reauthorization will be performed smoothly (with the exception of, for example, some old routers with bugs that will not respond to DHCPNAK and will wait for the end of the lease of the IP address and only then fulfill the request for a new IP address).

I will give an example of how you can save the list of accel-ppp sessions to a text file, where you can see the speed parameters in order to observe how the reauthorization is performed:

accel-cmd -H192.168.2.1 -P password show sessions > ixnfo.com.txt

With a large number of sessions, re-authorization is a time-consuming process, so it is better not to end the session, but to transfer new speed parameters to the access server.

See my other articles about ABillS.

Leave a comment

Leave a Reply