Vnstat
vnStat is a network traffic monitor for Linux that keeps a log of daily network traffic for the selected interface(s). vnStat is not a packet sniffer. The traffic information is analyzed from the /proc filesystem. That way vnStat can be used even without root permissions. However, at least a 2.2 series kernel is required.
Vnstat needs to be downloaded and installed seperately.
We can use yum to install this.
Different options with vnstat are.
-q, –query query database
-h, –hours show hours
-d, –days show days
-m, –months show months
-w, –weeks show weeks
-t, –top10 show top10
-s, –short use short output
-u, –update update database
-i, –iface change interface (default: eth0)
-?, –help short help
-v, –version show version
-tr, –traffic calculate traffic
-l, –live show transfer rate in real time
———————————–
To start using vnstat
1. Install vnstat
2. create a database for the device using the command given below.
For example if we want to create a database for the device eth0, we can use the command given below.
#vnstat -u -i eth0
Now a new database foe the device eth0 will be created at /var/lib/vnstat/eth0.
We can query this database using the varios options .
To see all the options we can use #vnstat –help
————-
Examples
————-
$ vnstat
Database updated: Sun Dec 2 22:20:01 2007
inet (eth0)
received: 735.00 GB (48.9%)
transmitted: 769.38 GB (51.1%)
total: 1.47 TB
rx | tx | total
———————–+————+———–
yesterday 23.35 MB | 20.25 MB | 43.60 MB
today 27.47 MB | 21.37 MB | 48.84 MB
———————–+————+———–
estimated 29 MB | 22 MB | 51 MB
(with 2 interfaces)
$ vnstat
rx / tx / total / estimated
Internet (eth1):
yesterday 209.36 MB / 322.88 MB / 532.24 MB
today 1.99 GB / 2.46 GB / 4.46 GB / 4.67 GB
Local (eth0):
yesterday 248.27 MB / 4.63 GB / 4.87 GB
today 2.31 GB / 4.21 GB / 6.52 GB / 6.83 GB
$ vnstat -h
inet (eth0) 22:15
^ r
| rt r
| rt rt
| rt rt
| r rt rt
| rt r rt rt
| rt rt rt rt rt
| rt rt rt r r rt r rt r rt rt rt
| rt rt rt r rt rt rt rt rt rt rt rt rt
| rt rt rt rt r r r r r rt rt rt rt rt rt rt rt rt rt
-+—————————————————————————>
| 23 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22
h rx (kB) tx (kB) h rx (kB) tx (kB) h rx (kB) tx (kB)
23 1,352 1,219 07 277 151 15 1,352 1,165
00 2,281 2,140 08 402 158 16 1,487 878
01 1,485 1,261 09 290 155 17 1,752 1,559
02 648 522 10 589 185 18 1,455 1,001
03 392 261 11 650 202 19 2,332 1,835
04 323 240 12 907 350 20 3,881 3,619
05 311 179 13 1,234 1,044 21 3,695 3,237
06 281 173 14 1,221 812 22 675 591
$ vnstat -d
inet (eth0) / daily
day rx | tx | total
————————+————-+—————————————-
03.11. 26.57 MB | 27.39 MB | 53.97 MB %%%%%%:::::::
04.11. 22.23 MB | 16.71 MB | 38.94 MB %%%%%::::
05.11. 31.38 MB | 23.35 MB | 54.74 MB %%%%%%%::::::
06.11. 35.17 MB | 26.85 MB | 62.02 MB %%%%%%%%%::::::
$ vnstat -m
inet (eth0) / monthly
month rx | tx | total
————————-+————–+————————————–
Jan ‘07 1.33 GB | 1.25 GB | 2.58 GB %%%%%%%%%::::::::
Feb ‘07 1.31 GB | 1.51 GB | 2.82 GB %%%%%%%%%::::::::::
Mar ‘07 1.54 GB | 1.66 GB | 3.20 GB %%%%%%%%%%%:::::::::::
Apr ‘07 1.27 GB | 1.13 GB | 2.40 GB %%%%%%%%::::::::
$ vnstat -t
inet (eth0) / top 10
# day rx | tx | total
——————————-+————-+———————————
1 26.03.06 6.41 GB | 10.83 GB | 17.24 GB %%%%%%%:::::::::::
2 05.02.04 8.31 GB | 7.08 GB | 15.39 GB %%%%%%%%%:::::::
3 04.02.05 7.96 GB | 6.21 GB | 14.17 GB %%%%%%%%::::::
4 04.09.05 8.09 GB | 5.22 GB | 13.30 GB %%%%%%%%:::::
$ vnstat -w
Local (eth0) / weekly
rx | tx | total
—————————-+—————+————–
last 7 days 4.83 GB | 18.82 GB | 23.65 GB
last week 2.52 GB | 14.58 GB | 17.10 GB
current week 2.31 GB | 4.24 GB | 6.55 GB
—————————-+—————+————–
estimated 17.66 GB | 32.36 GB | 50.02 GB
$ vnstat -tr
10386 packets sampled in 5 seconds
Traffic average for eth1
rx 112.21 kB/s 620 packets/s
tx 1444.77 kB/s 1456 packets/s
$ vnstat -l
Monitoring eth0… (press CTRL-C to stop)
rx: 430.68 kB/s 291 p/s tx: 10.21 kB/s 147 p/s
eth0 / traffic statistics
rx | tx
————————————–+—————————————-
bytes 32.79 MB | 957 kB
————————————–+—————————————-
max 656.39 kB/s | 90.50 kB/s
average 419.78 kB/s | 11.97 kB/s
min 288.37 kB/s | 7.03 kB/s
————————————–+—————————————-
packets 23298 | 12348
————————————–+—————————————-
max 732 p/s | 609 p/s
average 291 p/s | 154 p/s
min 195 p/s | 100 p/s
————————————–+—————————————-
time 1.33 minutes
Praji's Blog