• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Solutions

Monitor Bandwidth Usage on Linux: Daily and Monthly Statistic

neo by neo
September 11, 2025
in Solutions
0
Monitor Bandwidth Usage on Linux: Daily and Monthly Reports

Monitor Bandwidth Usage on Linux: Daily and Monthly Reports

0
SHARES
61
VIEWS
Share on FacebookShare on Twitter
Table of Contents
  • Bandwidth Usage Monitoring on Linux with Periodical Statistic
  • What is vnStat?
  • Installing vnStat
    • Monitor Data Usage (Bandwidth) on the network for the Last 7 Days (Daily)
    • Monitor Data Usage for the Last 3 Months (Monthly Report)
  • Understanding vnStat Output
  • Crate Monitoring Script for Bandwidth Usage Reporting
    • Other Useful Examples to Generate Different Reports

Bandwidth Usage Monitoring on Linux with Periodical Statistic

Monitoring network data usage (monthly, daily or hourly statistic) is crucial for managing bandwidth on Linux servers. Whether you’re managing a home server or a business-critical machine, tracking network traffic helps optimize performance and avoid potential overuse charges. One of the most effective tools for this task is vnStat, a network traffic monitor that logs and summarizes usage statistics (for example, daily or monthly report can be created with Bash scripts).

In this guide, we’ll show you how to use vnStat to view network data usage for the last 7 days and the last 3 months. This is useful for both short-term and long-term network monitoring.

What is vnStat?

vnStat is a lightweight console-based network traffic (bandwidth) monitor that works with Linux systems. It uses data from the /proc directory and does not require packet capturing, making it resource-efficient. The tool logs the data usage for specified network interfaces and can display reports in various formats, such as daily, weekly, monthly, or even yearly summaries.

You can check manual page for the vnStat application at the link.

You can check project page of vnStat application at the link.

Installing vnStat

To begin using vnStat, you first need to install it. Most Linux distributions include vnStat in their package repositories. You can install it using the following commands:

For Debian/Ubuntu-based systems:

sudo apt update
sudo apt install vnstat

After installation, ensure that vnStat is running as a background service to log data continuously. You can start and enable the service using:

sudo systemctl start vnstat
sudo systemctl enable vnstat

Monitor Data Usage (Bandwidth) on the network for the Last 7 Days (Daily)

Once installed, you can start checking the network usage for the last 7 days – daily report. Run the following command:

ADVERTISEMENT
vnstat --days 7 --iface eth0
vnstast monitoring
vnstast monitoring daily report

This command outputs the daily data usage for the interface eth0 over the last 7 days. You can replace eth0 with the actual name of your network interface if different.

ADVERTISEMENT

Monitor Data Usage for the Last 3 Months (Monthly Report)

To get the network traffic report for the last 3 months (monthly report), use the following command:

vnstat --months 3 --iface eth0
vnstast monitoring
vnstat monitoring monthly report

This will display a monthly summary of the network usage for the interface eth0. Like with the daily report, make sure to replace eth0 with your actual network interface.

Understanding vnStat Output

The output of these commands will show you the following information:

  • Rx: Total data received.
  • Tx: Total data transmitted.
  • Total: Combined upload and download data.
  • Average: The average data usage for the period.

Crate Monitoring Script for Bandwidth Usage Reporting

Important is to install vnstat!

nano vnstat_monitor.sh
#!/bin/bash

# Check if vnStat is installed
if ! command -v vnstat &> /dev/null
then
    echo "vnstat is not installed. Please install vnstat and try again."
    exit 1
fi

# Define the network interface
INTERFACE="eth0"

# Define log directory and log file
LOG_DIR="/opt/scripts/log"
LOG_FILE="$LOG_DIR/sysreport_$(date +%F).log"

# Create the log directory if it doesn't exist
mkdir -p $LOG_DIR

# Redirecting both standard output and error output to the log file
{
    echo "=========================="
    echo " Network Usage Report "
    echo "=========================="
    echo "Date: $(date)"
    echo ""

    # Display data usage for the last 7 days
    echo "Last 7 Days Data Usage for $INTERFACE:"
    vnstat --days 7 --iface $INTERFACE

    echo ""

    # Display data usage for the last 3 months
    echo "Last 3 Months Data Usage for $INTERFACE:"
    vnstat --months 3 --iface $INTERFACE

    echo ""
    echo "Report saved at: $LOG_FILE"
} | tee -a $LOG_FILE

Make the Script Executable

chmod +x vnstat_monitor.sh

Run the Script

./vnstat_monitor.sh

Output is something like this:

vnstat Script output
vnstat Script output

For more information about network bandwidth monitoring on Linux see the link.

Other Useful Examples to Generate Different Reports

  • Check live Bandwidth usage on interface
vnstat -tr
vnstat live bandwidth statistics
vnstat live bandwidth statistics
  • Show top 10 days
vnstat -t
vnstat show top 10 days
vnstat show top 10 days

About The Author

neo

See author's posts

Tags: bash-scriptinglinux
ADVERTISEMENT
Previous Post

Linux Networking: Display Open Ports and Listening Services

Next Post

Fortinet FortiGate: Routing Monitor and Route Attributes

neo

neo

Related Posts

Automatic Windows Service Monitoring and Restart Script
Solutions

Automatic Windows Service Monitoring and Restart Script

Host a Website on Raspberry Pi – Real Benchmark Tests
Solutions

Host a Website on Raspberry Pi – Real Benchmark Tests

My Ultimate Docker Command Cheat Sheet (2025 Edition)
Docker

My Ultimate Docker Commands Cheat Sheet (2025 Edition)

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script
Docker

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script

Raspberry Pi Monitoring with Monit: Docker, Temperature, Network & More
Solutions

Raspberry Pi Monitoring with Monit: Docker, Temperature & More

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)
Docker

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Next Post
Fortinet FortiGate: Routing Monitor and Route Attributes

Fortinet FortiGate: Routing Monitor and Route Attributes

Recommended

Find the Largest Files and Folders on Linux

Find the Largest Files and Folders on Linux

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

View & Copy Image Metadata Online – Camera & GPS Info

View & Copy Image Metadata Online – Camera & GPS Info

Online WebP to JPG Converter

Online WebP to JPG Converter

Image Metadata Remover – Clean EXIF and GPS Info Securely

Image Metadata Remover – Clean EXIF and GPS Info Online

Categories

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos
  • Web Tools
ADVERTISEMENT

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Recent News

View & Copy Image Metadata Online – Camera & GPS Info

View & Copy Image Metadata Online – Camera & GPS Info

Online WebP to JPG Converter

Online WebP to JPG Converter

  • Site Map
  • Privacy Policy
  • Facebook Page
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools

© 2025 defencedev.com - All rights reserved.