{"id":369841,"date":"2021-11-19T19:00:00","date_gmt":"2021-11-19T16:00:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-monitor-monthly-bandwidth-usage-in-linux-cloudsavvy-it\/"},"modified":"2021-11-19T19:00:00","modified_gmt":"2021-11-19T16:00:00","slug":"how-to-monitor-monthly-bandwidth-usage-in-linux-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-monitor-monthly-bandwidth-usage-in-linux-cloudsavvy-it\/","title":{"rendered":"#How to Monitor Monthly Bandwidth Usage in Linux \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a35ff62b71a5\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a35ff62b71a5\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-monitor-monthly-bandwidth-usage-in-linux-cloudsavvy-it\/#Install_vnstat\" >Install vnstat<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Monitor Monthly Bandwidth Usage in Linux \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-5144\" srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/06\/ee230f2d.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/06\/ee230f2d.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/06\/ee230f2d.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"vnstat output\" width=\"700\" height=\"300\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>As a server owner, it\u2019s important to keep track of your network usage over time. Many hosting providers will charge for bandwidth and transmitted data, so you\u2019ll want to keep tabs on your month-to-month usage.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Install_vnstat\"><\/span>Install vnstat<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>There are plenty of bandwidth monitoring tools out there\u2014most real-time monitoring tools like <code>htop<\/code>\u00a0and <code>glances<\/code>\u00a0will show Rx (received) and Tx (transmitted) out. However, it\u2019s much more useful to look at daily and monthly averages, and to do that, you\u2019ll need a tool that can keep logs over time.<\/p>\n<p>Of course, if you\u2019re hosting your servers on a big cloud provider like AWS or GCP, they will probably have built-in log collection tools like AWS CloudWatch and GCP Cloud Monitoring. For a generic Linux solution though, you\u2019ll want to install <code>vnstat<\/code>.<\/p>\n<p><code>vnstat<\/code>\u00a0monitors all network interfaces, and keeps logs on how much traffic your servers are handling, which can be used to present monthly, daily, and hourly averages of traffic. It also has the option of outputting to a PNG for a better looking graph.<\/p>\n<p><code>vnstat<\/code>\u00a0is available from most main package managers. For Debian-based systems like Ubuntu, that would be:<\/p>\n<pre>sudo apt install vnstat<\/pre>\n<p>You\u2019ll also want to install <code>vnstati<\/code>\u00a0for image output:<\/p>\n<pre>sudo apt install vnstati<\/pre>\n<p>If it isn\u2019t available on your package manager, you can <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/humdi.net\/vnstat\/\">download it from source,<\/a> and use <code>make<\/code>\u00a0to build it for your system.<\/p>\n<p><code>vnstat<\/code>\u00a0will im<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">media<\/a>tely start collecting data, but it will take a while for enough data to be collected to actually present anything. Come back to it in a few hours once it\u2019s collected some data, and run <code>vnstat<\/code>\u00a0to view its output:<\/p>\n<pre>vnstat<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5138\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/06\/56b27f53.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"605\" height=\"136\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This shows received GiB (RX), and transmitted GiB (TX), as well as a total and an estimate based on prior usage if the logs are incomplete. Keep in mind that <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Gibibyte\">this is in <em>Gibi<\/em>bytes<\/a>, not <em>Giga<\/em>bytes, though the difference isn\u2019t as much as the much smaller Giga<em>bits.<\/em><\/p>\n<p>If you want more detailed output, you can output hourly:<\/p>\n<pre>vnstat -h<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"imgchk9 alignnone wp-image-5140 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/06\/69ddf276.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Hourly received and transmitted output results\" width=\"627\" height=\"355\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To output an image summary, you can use the following command (<code>-s<\/code>\u00a0for summary), replacing eth0 with whatever network device you want to view:<\/p>\n<pre>vnstati -s -i eth0 -o ~\/network-log.png<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"imgchk9 alignnone wp-image-5142 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/06\/96a1eddb.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"An image summary\" width=\"498\" height=\"200\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You can also view hourly output in the same fashion.<\/p>\n<pre>vnstati -h -i eth0 -o ~\/network-log.png<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"imgchk9 alignnone wp-image-5143 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/06\/d2879656.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Hourly output \" width=\"700\" height=\"553\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If you\u2019d like to do more in-depth analysis, or send these logs off somewhere else, you can output all of <code>vnstat<\/code>\u2018s logs with the <code>--json<\/code>\u00a0flag.\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/5137\/how-to-monitor-monthly-bandwidth-usage-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Monitor Monthly Bandwidth Usage in Linux \u2013 CloudSavvy IT&#8221; As a server owner, it\u2019s important to keep track of your network usage over time. Many hosting providers will charge for bandwidth and transmitted data, so you\u2019ll want to keep tabs on your month-to-month usage. Install vnstat There are plenty of bandwidth monitoring tools&#8230;<\/p>\n","protected":false},"author":1,"featured_media":369842,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/06\/ee230f2d.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-369841","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/369841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=369841"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/369841\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/369842"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=369841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=369841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=369841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}