Can I make my server automatically suspend if it hits the bandwidth limit?

February 16, 2013 11.1k views
I'm concerned about the costs of going over the limit. Is there a way to automatically suspend my server and send me an email if it hits the monthly bandwidth limit?
4 Answers
Here is a script i wrote (you need vnstat and bc installed) which turns off your droplet once u hit 999 GB traffic in the current month:
  • Does the script run in the background automatically or am I going to have to set that up?
    Oh and this thread is old so im wondering is there a bandwidth limiter now?

  • It looks like @fs' script only runs once so you will need to configure a cronjob to run it e.g. every hour.

    Run crontab -e as root to edit root's cronjob list and add the following line at the bottom:

    0 * * * * bash /path/to/script

    and save the file.

    At the moment, we are not billing for bandwidth as there is no way for a user to tell how much bandwidth their droplet has used via the control panel, so you don't need to worry about it for now :)

Install vnstat, monitor its logs and once it hits 900gb on combined transfer make it send you and email.
We're going to be adding alerts in the future after we introduce stats so you'll be able to configure that.
The solution with vnstat is great (you can install it from epel-repo with yum automatically) and setup cron to send you an email on daily/weekly basis.

Another solution is to setup some monitoring for current network bandwidth and get a notification when you hit some peak (even thought I do not suggest this solution).

You'd better go with vnstat.
Have another answer? Share your knowledge.