# Solution to monitor data transfer usage on dedicated servers?



## kcaj (Jul 4, 2014)

Hello,

I've two dedicated servers which have no data transfer usage stats in their control panels. Currently I run 'ifconfig' to view data transfer stats. I have a concern however that if the dedicated server was to go offline, these stats would reset. It would be ideal to log the output of ifconfig to a file on the server at a regular interval using cron. At the moment I have this..


0 0 * * * date >> /home/bandwidth.txt; ifconfig | grep bytes >> /home/bandwidth.txt

The date command runs and is logged to /home/bandwidth.txt but not the ifconfig part. I have tried running the second part of the command on a cron of it's own but still nothing is logged.

Does anyone have any ideas for me?


----------



## MartinD (Jul 4, 2014)

Why not run something like cacti on a remote vm?

Surely your provider should be keeping tabs on this in some portal you can access?


----------



## fizzyjoe908 (Jul 4, 2014)

Cacti should help you with this. It is easy to setup to collect and graph your bandwidth data including total bandwidth used or 95th percentile.

We offer Cacti graphs to all clients and keep our own 95th percentile graphs to be sure our datacenter is charging us for bandwidth appropriately.


----------



## lbft (Jul 4, 2014)

To jump on the bandwagon of suggesting other options, vnstat will keep daily and monthly bandwidth usage totals and is dead simple to use.


----------



## kcaj (Jul 4, 2014)

They're Kimsufi servers, the panel has no total data transfer usage. I already use Observium which provides me graphs but the totals displayed on the graphs are often slightly out with what ifconfig reports.

vnstat looks to do the job I need, thank you.


----------



## zzrok (Jul 4, 2014)

Yep, all of my boxes get vnstat right away.  Don't forget to check that the daemon or the cron job is set to run or it won't collect stats.


----------



## manacit (Jul 4, 2014)

Definitely go with vnstat. Dead simple to install, and really easy to use. I have it running on both of my OVH servers:

[email protected]:~$ vnstat -m
 
 eth0  /  monthly
 
       month        rx      |     tx      |    total    |   avg. rate
    ------------------------+-------------+-------------+---------------
      Nov '13    291.79 GiB |  140.78 GiB |  432.57 GiB |    1.40 Mbit/s
      Dec '13     68.90 GiB |  975.25 GiB |    1.02 TiB |    3.27 Mbit/s
      Jan '14     62.41 GiB |  775.33 GiB |  837.74 GiB |    2.62 Mbit/s
      Feb '14     89.08 GiB |  571.07 GiB |  660.15 GiB |    2.29 Mbit/s
      Mar '14    334.74 GiB |    4.73 TiB |    5.05 TiB |   16.21 Mbit/s
      Apr '14    152.83 GiB |  959.14 GiB |    1.09 TiB |    3.60 Mbit/s
      May '14    177.78 GiB |    1.11 TiB |    1.28 TiB |    4.12 Mbit/s
      Jun '14    515.47 GiB |    1.64 TiB |    2.15 TiB |    7.11 Mbit/s
      Jul '14    172.18 GiB |  275.00 GiB |  447.18 GiB |   12.03 Mbit/s
    ------------------------+-------------+-------------+---------------
    estimated      1.44 TiB |    2.31 TiB |    3.75 TiB |There's also some nice WebUIs in front of it


----------



## Kalam (Jul 4, 2014)

I have a crontab running hourly to make an xml of my vnstat stats, which is displayed on a php page. Basically a shitty custom web ui.

vnstat all the way.


----------



## Dylan (Jul 4, 2014)

Yup, vnstat sounds like exactly what you want.


----------



## splitice (Jul 5, 2014)

vnstat is great, however if a textual log is what you want (very useful for auditing purposes) the following should work.


date >> /home/bandwidth.txt; /sbin/ifconfig | grep bytes >> /home/bandwidth.txt
A different PATH environment variable is used in cron scripts, sbin is not usually in it.


----------



## bpsRobert (Jul 6, 2014)

I would recommend Observium on a remote VPS.


----------

