{"id":13853,"date":"2019-04-06T11:45:01","date_gmt":"2019-04-06T11:45:01","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13853"},"modified":"2019-04-06T11:45:01","modified_gmt":"2019-04-06T11:45:01","slug":"how-to-install-vnstat-and-vnstati-to-monitor-network-traffic-in-rhel-centos-7","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/how-to-install-vnstat-and-vnstati-to-monitor-network-traffic-in-rhel-centos-7\/","title":{"rendered":"How to Install vnStat and vnStati to Monitor Network Traffic in RHEL\/CentOS 7"},"content":{"rendered":"<p><strong>VnStat<\/strong>\u00a0is a console based network traffic monitoring tool design for Linux and BSD. It will keep a log of the network traffic for a selected network interface\/s. To generate the logs, vnStat uses the information provided by the kernel. In other words it will not sniff the network traffic and will ensue the lite usage of the system resource. To use this software under Linux you will need at least version 2.2 of the kernel series.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a title=\"VnStat PHP Network Monitoring\" href=\"https:\/\/www.tecmint.com\/vnstat-php-frontend-for-monitoring-network-bandwidth\/\" target=\"_blank\" rel=\"noopener\">VnStat PHP: A Web Based Interface for Monitoring Network Traffic Usage<\/a><\/p>\n<p>The latest version of\u00a0<strong>vnStat 1.13<\/strong>\u00a0has been released on\u00a0<strong>January 18th, 2015<\/strong>\u00a0and includes several following features and fixes.<\/p>\n<h4>Features<\/h4>\n<ol>\n<li>Statistics remain available even after system reboots<\/li>\n<li>Monitor multiple network interfaces at the same time<\/li>\n<li>Multiple output options<\/li>\n<li>Sort the data by hour, day, month, week or get the top 10 days<\/li>\n<li>Generate png graphic of the output<\/li>\n<li>Configure \u201cMonths\u201d to follow up with different billing cycles you may have<\/li>\n<li>Very light \u2013 consumes really small portion of your system resources<\/li>\n<li>Low CPU usage no matter how much traffic you generate<\/li>\n<li>You don\u2019t have to be root to use it<\/li>\n<li>Select units dynamically (KB, MB etc)<\/li>\n<li>vnStati provides some new options like:\n<ol>\n<li><strong>-nl<\/strong>\u00a0\/\u00a0<strong>\u2013nolegend<\/strong>\u00a0(hides the rx\/tx legend)<\/li>\n<li><strong>\u2013altdate<\/strong>\u00a0\u2013 use alternative date\/time text location<\/li>\n<li><strong>\u2013headertext<\/strong>\u00a0\u2013 to customize the text in the image header.<\/li>\n<\/ol>\n<\/li>\n<li>You can add legend to generated output image<\/li>\n<li>Customizable options for content positioning and image background color to vnStat.cgi.<\/li>\n<li>The interface bandwidth will be automatically detected.<\/li>\n<li>Use JSON for output<\/li>\n<\/ol>\n<p>In this article, we will show you how to install\u00a0<strong>vnStat<\/strong>\u00a0and\u00a0<strong>vnStati<\/strong>\u00a0tool under\u00a0<strong>RHEL\/CentOS 7<\/strong>\u00a0systems to monitor real time network traffic.<\/p>\n<h3>Installing vnStat and vnStati Network Monitoring Tools<\/h3>\n<p><strong>1.<\/strong>\u00a0To install vnStat in\u00a0<strong>RHEL\/CentOS 7<\/strong>\u00a0you will need to download the latest version (<strong>1.13<\/strong>) using following link:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/install-vnstat-and-vnstati-to-monitor-linux-network-traffic\/_blank\">http:\/\/humdi.net\/vnstat\/<\/a><\/li>\n<\/ol>\n<p>Alternatively, you can also use following\u00a0<strong>wget<\/strong>\u00a0command to download the latest source tarball as shown below.<\/p>\n<pre># wget http:\/\/humdi.net\/vnstat\/vnstat-1.13.tar.gz\r\n<\/pre>\n<div id=\"attachment_12376\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Download-Vnstat.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-12376\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Download-Vnstat.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Download-Vnstat.png 720w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Download-Vnstat-620x344.png 620w\" alt=\"Download Vnstat\" width=\"620\" height=\"344\" aria-describedby=\"caption-attachment-12376\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12376\" class=\"wp-caption-text\">Download Vnstat<\/p>\n<\/div>\n<p><strong>2.<\/strong>\u00a0Once you have downloaded the file, extract the archive using your terminal and then navigate to the location where you have extracted the archive and compile it using following commands.<\/p>\n<pre># tar -xvf vnstat-1.13.tar.gz\r\n# cd vnstat-1.13\/\r\n# make\r\n<\/pre>\n<div id=\"attachment_12377\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Compile-Vnstat.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-12377\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Compile-Vnstat.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Compile-Vnstat.png 878w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Compile-Vnstat-620x223.png 620w\" alt=\"Compile Vnstat\" width=\"620\" height=\"223\" aria-describedby=\"caption-attachment-12377\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12377\" class=\"wp-caption-text\">Compile Vnstat<\/p>\n<\/div>\n<p>Once the above compilation completed successfully, run:<\/p>\n<pre># make install\r\n<\/pre>\n<div id=\"attachment_12378\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Install-Vnstat.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-12378\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Install-Vnstat.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Install-Vnstat.png 622w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Install-Vnstat-620x180.png 620w\" alt=\"Install Vnstat\" width=\"620\" height=\"180\" aria-describedby=\"caption-attachment-12378\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12378\" class=\"wp-caption-text\">Install Vnstat<\/p>\n<\/div>\n<p><strong>3.<\/strong>\u00a0Once the install has finished you will need to create a new database for the network interface that you will be monitoring. Before you do so, make sure that the following directory exist:<\/p>\n<pre>\/var\/lib\/vnstat\r\n<\/pre>\n<p>If that directory does not exist the database creation mail fail and you will end up getting following error<\/p>\n<pre>Error: Unable to open database directory \"\/var\/lib\/vnstat\": No such file or directory\r\nThe vnStat daemon should have created this directory when started.\r\nCheck that it is is configured and running. See also \"man vnstatd\".\r\n<\/pre>\n<div id=\"attachment_12379\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Vnstat-Error.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-12379\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Vnstat-Error.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Vnstat-Error.png 720w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Vnstat-Error-620x344.png 620w\" alt=\"Vnstat Error: \/var\/lib\/vnstat \" width=\"620\" height=\"344\" aria-describedby=\"caption-attachment-12379\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12379\" class=\"wp-caption-text\">Vnstat Error: \/var\/lib\/vnstat<\/p>\n<\/div>\n<p>If it is missing you can create it by running following command.<\/p>\n<pre># mkdir \/var\/lib\/vnstat\r\n<\/pre>\n<p><strong>4.<\/strong>\u00a0To create a new database for your network interface run:<\/p>\n<pre># vnstat --create -i eth0\r\n\r\nCreating database for interface \"eth0\"...\r\nInfo: -&gt; A new database has been created.\r\n<\/pre>\n<div id=\"attachment_12390\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Vnstat-Database-Created1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-12390\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Vnstat-Database-Created1-620x344.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Vnstat-Database-Created1-620x344.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Vnstat-Database-Created1.png 720w\" alt=\"Vnstat Database Created \" width=\"620\" height=\"344\" aria-describedby=\"caption-attachment-12390\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12390\" class=\"wp-caption-text\">Vnstat Database Created<\/p>\n<\/div>\n<p>In my case the network interface is \u201c<strong>eth0<\/strong>\u201d, but this may vary. You can run\u00a0<strong>ifconfig -a<\/strong>\u00a0to check the available interfaces for your machine.<\/p>\n<p><strong>5.<\/strong>\u00a0If you wish to customize your vnStat configuration you can open its configuration file located at:<\/p>\n<pre>\/etc\/vnstat.conf\r\n<\/pre>\n<p>The options in there are self explanatory so I won\u2019t be stopping on each one of them. You can still review them if you wish to customize your installation.<\/p>\n<p><strong>6.<\/strong>\u00a0You would need to allow some time for the stats to be updated in the database. Once you have enough information written in the database you can see the network stats by simply running:<\/p>\n<pre># vnstat\r\n<\/pre>\n<div id=\"attachment_12381\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Monitor-Network-Traffic.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-12381\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Monitor-Network-Traffic.png\" alt=\"Monitor Network Traffic of Interface\" width=\"545\" height=\"327\" aria-describedby=\"caption-attachment-12381\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12381\" class=\"wp-caption-text\">Monitor Network Traffic of Interface<\/p>\n<\/div>\n<p><strong>7.<\/strong>\u00a0Yon can also check the hourly stats by using the\u00a0<code>-h<\/code>\u00a0option:<\/p>\n<pre># vnstat -h\r\n<\/pre>\n<div id=\"attachment_12382\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Monitor-Hourly-network-Traffic.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-12382\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Monitor-Hourly-network-Traffic.png\" alt=\"Monitor Hourly Network Traffic\" width=\"593\" height=\"388\" aria-describedby=\"caption-attachment-12382\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12382\" class=\"wp-caption-text\">Monitor Hourly Network Traffic<\/p>\n<\/div>\n<p><strong>8.<\/strong>\u00a0For daily stats, you will need to use the\u00a0<code>-d<\/code>\u00a0option:<\/p>\n<pre># vnstat -d \r\n<\/pre>\n<div id=\"attachment_12383\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Daily-Network-Traffic-monitoring.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-12383\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Daily-Network-Traffic-monitoring.png\" alt=\"Monitor Daily Network Traffic\" width=\"568\" height=\"159\" aria-describedby=\"caption-attachment-12383\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12383\" class=\"wp-caption-text\">Monitor Daily Network Traffic<\/p>\n<\/div>\n<p><strong>9.<\/strong>\u00a0For more available options you can use the\u00a0<code>--help<\/code>:<\/p>\n<pre># vnstat --help\r\n<\/pre>\n<div id=\"attachment_12384\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Vnstat-Monitoring-Options.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-12384\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Vnstat-Monitoring-Options.png\" alt=\"Vnstat Monitoring Options\" width=\"532\" height=\"289\" aria-describedby=\"caption-attachment-12384\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12384\" class=\"wp-caption-text\">Vnstat Monitoring Options<\/p>\n<\/div>\n<p><strong>10.<\/strong>\u00a0To make the stats easier to read you can use the\u00a0<strong>vnStati<\/strong>\u00a0tool to generate\u00a0<strong>.png<\/strong>\u00a0images for vnStat.<\/p>\n<p><strong>VnStati<\/strong>\u00a0is automatically installed along vnStat so no further installation actions would be required. To generate a summary image for the network usage of your network interface, you can run:<\/p>\n<pre># vnstati -s -i eth0 -o ~\/network-log.png\r\n<\/pre>\n<div id=\"attachment_12386\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Generate-Monitoring-Report.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-12386\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Generate-Monitoring-Report.png\" alt=\"Generate Network Monitoring Report\" width=\"500\" height=\"200\" aria-describedby=\"caption-attachment-12386\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12386\" class=\"wp-caption-text\">Generate Network Monitoring Report<\/p>\n<\/div>\n<pre># vnstati -h -i eth0 -o ~\/network-log.png\r\n<\/pre>\n<div id=\"attachment_12387\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Hourly-Network-Report.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-12387\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/04\/Hourly-Network-Report.png\" alt=\"Hourly Network Report\" width=\"500\" height=\"200\" aria-describedby=\"caption-attachment-12387\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-12387\" class=\"wp-caption-text\">Hourly Network Report<\/p>\n<\/div>\n<p>In my cases\u00a0<strong>vnStat<\/strong>\u00a0was just recently installed, but those will get populated over time. For more available options and different stats you can use the\u00a0<strong>\u2013help<\/strong>\u00a0option:<\/p>\n<p>The information that both\u00a0<strong>vnStat<\/strong>\u00a0and\u00a0<strong>vnStati<\/strong>\u00a0provide can greatly help your network monitoring, analysis and troubleshooting in time. You may find more information about the available options of vnStat in the man page of the tool.<\/p>\n<p>If you have an additional suggestion or question about vnStat and vnStati please do not hesitate to submit your comment in the comment section below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/install-vnstat-and-vnstati-to-monitor-linux-network-traffic\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>VnStat\u00a0is a console based network traffic monitoring tool design for Linux and BSD. It will keep a log of the network traffic for a selected network interface\/s. To generate the logs, vnStat uses the information provided by the kernel. In other words it will not sniff the network traffic and will ensue the lite usage &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/how-to-install-vnstat-and-vnstati-to-monitor-network-traffic-in-rhel-centos-7\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Install vnStat and vnStati to Monitor Network Traffic in RHEL\/CentOS 7&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13853","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13853"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13853\/revisions"}],"predecessor-version":[{"id":13854,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13853\/revisions\/13854"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}