LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Check Your Vultr Bandwidth Before This Happens! We Make It Easy

It's Complicated

Bandwidth in Vultr is…complicated.

Here’s how it works:

  • Every month you get a dollop of free bandwidth, spread across your VMs.  Presently it’s 2TB.
  • Then you get per-instance bandwidth.  This is allocated to each instance, but you don’t get it all at once.  You get 1/672nd of the hourly spec for that VM every hour.
  • Coming Soontm you will be able to also purchase additional bandwidth.

The reason for these complications is that Vultr is selling bandwidth on a per-hour basis.  They don’t want someone firing up an instance, burning 1TB of bandwidth, then shutting it down and immediately starting a new VM with a new 1TB of bandwidth, etc.  On the other hand, someone might need to use more of their allocation early in the month and could run ahead of the 1/672nd, so they have an overall free allocation as well.

And When You Go Over, the Meter Starts

If you exceed your bandwidth (total of free bandwidth and instance bandwidth), Vultr will start charging you at $.01 per GB.  That’s not a bad price compared to some people (<cough> AWS <cough>) but still real money at $10/TB.

You should monitor how much bandwidth you’re using.  But how?  You can login to the Vultr panel, and there is a Bandwidth Usage report.

Vultr Bandwidth

Of course, that means remembering to login and check it.

Much better would be something you can script.  Here’s a quick piece of code that lets you query the Vultr API to get your bandwidth stats.  You’ll need an API key (go to the panel and look under…you guessed it…API).

You’ll also need jq, which is a JSON pretty-printer/extractor your favorite package manager can install for you with something like

apt install jq

Vultr’s API returns data in JSON format, and we use jq to pull data out of the results.


VULTR_API_KEY=ABC123DEF456GHI789 # replace

DATA=$(curl -s "https://api.vultr.com/v2/account/bandwidth" \
  -X GET \
  -H "Authorization: Bearer ${VULTR_API_KEY}")

IBC=$( echo $DATA |  jq .bandwidth.currentMonthToDate.instanceBandwidthCredits )
FBC=$( echo $DATA |  jq .bandwidth.currentMonthToDate.freeBandwidthCredits )
GB_OUT=$( echo $DATA |  jq .bandwidth.currentMonthToDate.gb_out )


printf "Total BW credits: %d\n" $TOT_CREDIT
printf "Total BW used   : %d\n" $GB_OUT
printf "Total BW avail  : %d\n" $AVAIL

If you want an email alert, try adding this at the bottom:

if [ $AVAIL -lt 100 ] ; then
   echo "Vultr bandwidth low!  $AVAIL out of $TOT_CREDIT left" | mailx -s "Vultr bandwidth alert" your@email.com

Stick it in cron and you’ll get alerted when your remaining bandwidth is less than 100GB.


No Comments

    Leave a Reply

    Some notes on commenting on LowEndBox:

    • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
    • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
    • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

    Your email address will not be published. Required fields are marked *