I will need to use some dedicated servers with limited bandwidth allocated.
What are the efficient ways to monitor the bandwidth usage and stop the servers to avoid bandwidth overages?
there are many options for you to install monitoring services for bandwidth that alert you when you reach a certain limit, even stopping all services if necessary. The options are too many to list.
Librenms
enable the traffic billing in the config and do a cron to the built-in API.
And set the desired action in your cron once the limit has been reached.
Comments
What control panel are you using?
I don't use any control panel. The server will run different microservices, most of the services are docker-based.
I'm thinking of collecting the result from vnstat to a web service and then manually do necessary actions.
there are many options for you to install monitoring services for bandwidth that alert you when you reach a certain limit, even stopping all services if necessary. The options are too many to list.
for example check here:
https://www.tecmint.com/linux-network-bandwidth-monitoring-tools/
I use hetrixtools. It monitors many things, and this is one of them.
vnstat + bash script to shutdown server when the limit has been reached
Shutting down seems a bit much?
It is better for him to stop the server himself than to have it removed by the service provider.
Yeah that's mean
Or maybe use something like Wonder Shaper.
Librenms
enable the traffic billing in the config and do a cron to the built-in API.
And set the desired action in your cron once the limit has been reached.