• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
DefenceDev
No Result
View All Result
Home Linux Monitoring

Monitor Bandwidth Usage on Linux: Daily and Monthly Statistic

by neo
September 3, 2026
in Monitoring
0
Monitor Bandwidth Usage on Linux: Daily and Monthly Reports

Monitor Bandwidth Usage on Linux: Daily and Monthly Reports

0
SHARES
127
VIEWS
Share on FacebookShare on LinkedIn
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:

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.

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

Tags: linuxmonitoringnetworking
Previous Post

Linux Networking: Display Open Ports and Listening Services

Next Post

Fortinet FortiGate: Routing Monitor and Route Attributes

neo

Related Posts

Get Instant SSH Login Alerts on Ubuntu with Bash and Telegram
Monitoring

Get Instant SSH Login Alerts on Ubuntu with Bash and Telegram

Solution: Ubuntu Internet Connection Monitoring Script (Create a Log File, Possible to Send per Email)
Monitoring

Ubuntu Internet Connection Monitoring Script: Log Creation and Email Alerts

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

Raspberry Pi Monitoring with Monit: Docker, Temperature & More

Linux Performance Monitoring with Monit Application
Monitoring

Linux Performance Monitoring with Monit Application

Network Monitoring (Bandwidth, Sessions) Tools for Linux
Monitoring

Best Linux Network Monitoring Tools for Bandwidth and Sessions

Linux Real-Time Performance (CPU, Memory Usage) Metrics with htop, atop, nload, and iostat
Monitoring

Linux Real-Time Performance (CPU, Memory Usage) Metrics with htop, atop, nload, and iostat

Next Post
Fortinet FortiGate: Routing Monitor and Route Attributes

Fortinet FortiGate: Routing Monitor and Route Attributes

Recommended

View & Copy Image Metadata Online – Camera & GPS Info

View & Copy Image Metadata Online – Camera & GPS Info

MikroTik: OpenVPN Client Failover Script

MikroTik: OpenVPN Client Failover Script

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

Fix Proxmox VM Snapshot “Out of Space” Errors

Fix Proxmox VM Snapshot “Out of Space” Errors

Categories

  • Linux
    • Bash Scripting
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Web Tools

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

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

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

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools

© 2025 defencedev.com - All rights reserved.