{"id":2155,"date":"2012-05-11T21:28:56","date_gmt":"2012-05-11T13:28:56","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=2155"},"modified":"2023-04-28T09:49:19","modified_gmt":"2023-04-28T09:49:19","slug":"how-to-monitor-bandwidth-usage-with-vnstat-on-linux-centos-6-2-server","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-monitor-bandwidth-usage-with-vnstat-on-linux-centos-6-2-server\/","title":{"rendered":"How to Monitor Bandwidth Usage with vnStat on Linux CentOS 6.2 Server"},"content":{"rendered":"<p><a href=\"https:\/\/humdi.net\/vnstat\/\" title=\"vnStat\">vnStat<\/a> is a open source monitoring tool that can be use to monitor the bandwidth usage of the network traffic for Linux and BSD. vnStat actually will not be sniffing any traffic and use less of the system resources. However, at least a linux kernel 2.2 series is required. Some of the vnStat features are as below :<\/p>\n<ul>\n<li>quick and simple to install and get running<\/li>\n<li>gathered statistics persists through system reboots<\/li>\n<li>can monitor multiple interfaces at the same time<\/li>\n<li>several output options\n<ul>\n<li>summary, hourly, daily, monthly, weekly, top 10 days<\/li>\n<li>optional png image output (using libgd)<\/li>\n<\/ul>\n<\/li>\n<li>months can be configured to follow billing period<\/li>\n<li>light, minimal resource usage<\/li>\n<li>same low cpu usage regardless of traffic<\/li>\n<li>can be used without root permissions<\/li>\n<li>online color configuration editor<\/li>\n<\/ul>\n<p>In this post, i will guide through the steps on how to install and configure vnStat on CentOS 6.2. These steps was tested using the Local Yum Repository from CD-ROM\/DVD-ROM image and EPEL repository. Therefore it is recommended to install Local Yum Repository from CD-ROM\/DVD-ROM and EPEl repository as documented in the following post.<br \/>\n1. Install and configure Local Yum Repository from CD-ROM\/DVD-ROM image and EPEL Repository as per below posts :<\/p>\n<p><a href=\"https:\/\/webhostinggeeks.com\/howto\/how-to-install-and-configure-epel-repository-on-centos-6-2\/\">How to Install and Configure EPEL Repository on CentOS 6.2<\/a><br \/>\n<a href=\"https:\/\/webhostinggeeks.com\/howto\/how-to-setup-local-yum-repository-from-cd-romdvd-rom-image-on-centos-6-2\/\">How to Setup Local Yum Repository from CD-ROM\/DVD-ROM image on CentOS 6.2<\/a><\/p>\n<p>2. Install vnStat using yum command :<\/p>\n<pre>[root@centos62 ~]# yum install vnstat -y\nLoaded plugins: fastestmirror\nLoading mirror speeds from cached hostfile\n * base: mirrors.hostemo.com\n * epel: ftp.riken.jp\n * extras: mirrors.hostemo.com\n * updates: ossm.utm.my\nSetting up Install Process\nResolving Dependencies\n--&gt; Running transaction check\n---&gt; Package vnstat.i686 0:1.11-1.el6 will be installed\n--&gt; Processing Dependency: libgd.so.2 for package: vnstat-1.11-1.el6.i686\n--&gt; Running transaction check\n---&gt; Package gd.i686 0:2.0.35-10.el6 will be installed\n--&gt; Processing Dependency: libXpm.so.4 for package: gd-2.0.35-10.el6.i686\n--&gt; Running transaction check\n---&gt; Package libXpm.i686 0:3.5.8-2.el6 will be installed\n--&gt; Finished Dependency Resolution\n\nDependencies Resolved\n\n====================================================================================================\n Package           Arch            Version                    Repository                       Size\n====================================================================================================\nInstalling:\n vnstat            i686            1.11-1.el6                 epel                            104 k\nInstalling for dependencies:\n gd                i686            2.0.35-10.el6              CentOS6.2-Repository            141 k\n libXpm            i686            3.5.8-2.el6                CentOS6.2-Repository             58 k\n\nTransaction Summary\n====================================================================================================\nInstall       3 Package(s)\n\nTotal download size: 304 k\nInstalled size: 944 k\nDownloading Packages:\n(1\/3): vnstat-1.11-1.el6.i686.rpm                                            | 104 kB     00:00\n----------------------------------------------------------------------------------------------------\nTotal                                                               227 kB\/s | 304 kB     00:01\nRunning rpm_check_debug\nRunning Transaction Test\nTransaction Test Succeeded\nRunning Transaction\n  Installing : libXpm-3.5.8-2.el6.i686                                                          1\/3\n  Installing : gd-2.0.35-10.el6.i686                                                            2\/3\n  Installing : vnstat-1.11-1.el6.i686                                                           3\/3\n\nInstalled:\n  vnstat.i686 0:1.11-1.el6\n\nDependency Installed:\n  gd.i686 0:2.0.35-10.el6                         libXpm.i686 0:3.5.8-2.el6\n\nComplete!<\/pre>\n<p>3. Start the vnStat service :<\/p>\n<pre>\n[root@centos62 ~]# service vnstat start\nStarting vnstatd:                                          [  OK  ]\n<\/pre>\n<p>4. To ensure that vnStat is started at boot time, you can execute a chkconfig command as below :<\/p>\n<pre>\n[root@centos62 ~]# chkconfig vnstat on\n<\/pre>\n<p>5. Execute command &#8220;vnstat &#8211;iflist&#8221; to display the available network interface :<\/p>\n<pre>\n[root@centos62 ~]# vnstat --iflist\nAvailable interfaces: lo eth0\n<\/pre>\n<p>6. Before vnStat can begin logging the bandwidth usage, it is necessary to setup the database for your network interface. Kindly replace the &#8220;eth0&#8221; with the correct interface if you running multiple interface :<\/p>\n<pre>\n[root@centos62 ~]# vnstat -u -i eth0\n<\/pre>\n<p>7. View the first vnStat data :<\/p>\n<pre>\n[root@centos62 ~]# vnstat\nDatabase updated: Thu Mar 8 20:41:00 2012\n\neth0 since 03\/08\/12\n\nrx: 75 KiB tx: 73 KiB total: 148 KiB\n\nmonthly\nrx | tx | total | avg. rate\n------------------------+-------------+-------------+---------------\nMar '12 75 KiB | 73 KiB | 148 KiB | 0.00 kbit\/s\n------------------------+-------------+-------------+---------------\nestimated -- | -- | -- |\n\ndaily\nrx | tx | total | avg. rate\n------------------------+-------------+-------------+---------------\ntoday 75 KiB | 73 KiB | 148 KiB | 0.02 kbit\/s\n------------------------+-------------+-------------+---------------\nestimated -- | -- | -- |\n<\/pre>\n<p>8. View vnStat bandwidth statistic by day :<\/p>\n<pre>[root@centos62 ~]# vnstat -d\n\n eth0  \/  daily\n\n         day         rx      |     tx      |    total    |   avg. rate\n     ------------------------+-------------+-------------+---------------\n      03\/08\/12        75 KiB |      73 KiB |     148 KiB |    0.02 kbit\/s\n     ------------------------+-------------+-------------+---------------\n     estimated        --     |      --     |      --     |\n\n<\/pre>\n<p>9. View vnStat bandwidth statistic by hour :<\/p>\n<pre>[root@centos62 ~]# vnstat -h\n eth0                                                                     20:41\n  ^                                                                       r\n  |                                                                       rt\n  |                                                                       rt\n  |                                                                       rt\n  |                                                                       rt\n  |                                                                       rt\n  |                                                                       rt\n  |                                                                       rt\n  |                                                                       rt\n  |                                                                       rt\n -+---------------------------------------------------------------------------&gt;\n  |  21 22 23 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20\n\n h  rx (KiB)   tx (KiB)      h  rx (KiB)   tx (KiB)      h  rx (KiB)   tx (KiB)\n21          0          0    05          0          0    13          0          0\n22          0          0    06          0          0    14          0          0\n23          0          0    07          0          0    15          0          0\n00          0          0    08          0          0    16          0          0\n01          0          0    09          0          0    17          0          0\n02          0          0    10          0          0    18          0          0\n03          0          0    11          0          0    19          0          0\n04          0          0    12          0          0    20         75         73<\/pre>\n<p>10. Update the vnStat database :<\/p>\n<pre>\n[root@centos62 ~]# vnstat -u\n<\/pre>\n<p>11. View vnStat help and other available command :<\/p>\n<pre>\n[root@centos62 ~]# vnstat --help\n vnStat 1.11 by Teemu Toivola <tst at iki dot fi>\n\n         -q,  --query          query database\n         -h,  --hours          show hours\n         -d,  --days           show days\n         -m,  --months         show months\n         -w,  --weeks          show weeks\n         -t,  --top10          show top10\n         -s,  --short          use short output\n         -u,  --update         update database\n         -i,  --iface          select interface (default: eth0)\n         -?,  --help           short help\n         -v,  --version        show version\n         -tr, --traffic        calculate traffic\n         -ru, --rateunit       swap configured rate unit\n         -l,  --live           show transfer rate in real time\n\nSee also \"--longhelp\" for complete options list and \"man vnstat\".\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>vnStat is a open source monitoring tool that can be use to monitor the bandwidth usage of the network traffic for Linux and BSD. vnStat actually will not be sniffing&#8230;<\/p>\n","protected":false},"author":6,"featured_media":2156,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2055,1065],"tags":[1244,1253,2089,1975,1536,1902],"class_list":["post-2155","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-system-administration","tag-centos","tag-centos-6-2","tag-configuration","tag-install","tag-linux","tag-vnstat"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=2155"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2155\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/2156"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=2155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=2155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=2155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}