October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Monitor Server Bandwidth With vnStat on Linux

A practical guide to monitoring Linux server bandwidth with vnStat: install and start vnstatd, select interfaces, query historical usage, export JSON/XML, configure the database, and troubleshoot stale or missing data.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use vnStat for lightweight, per-interface bandwidth accounting on a Linux server. The vnstatd daemon periodically reads the kernel’s interface counters and stores five-minute, hourly, daily, monthly, and yearly totals; the vnstat command then reports those saved values or exports them as JSON or XML. Install the package or build it with SQLite support, enable the daemon, confirm the interface name, and allow the first update cycle to complete before judging the results.

vnStat is an accounting tool, not a packet sniffer. It can tell you how much traffic crossed eth0 or another interface and when, but not which connection, process, URL, or packet caused it. That distinction determines whether it is the right monitor for your server.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What vnStat records and how its two commands work

vnStat is a console-based network traffic monitor that reads counters exposed through Linux /proc or /sys filesystems. It normally does not need root privileges to read those counters on supported systems. Because it samples counters instead of inspecting packets, it uses little CPU and storage compared with packet-capture or flow-analysis systems.

The project separates collection from reporting:

Component Role What to expect
vnstatd Collector daemon Wakes periodically, reads interface counters, caches values, and writes database updates.
vnstat Query and export client Reads the database and prints human-readable periods or machine-readable JSON/XML.

The daemon’s sleep-and-update cycle means a query can trail the live kernel counter. That is normal: the database changes when the next collection and save operation occurs, not on every packet.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

RX, TX, and total traffic

Every report separates RX (received traffic) from TX (transmitted traffic), usually with a combined total. Decide which direction matters for your provider’s quota before interpreting a number. A server that downloads backups may be RX-heavy; a web or game server serving clients may be TX-heavy.

Available time buckets

vnStat maintains five-minute, hourly, daily, monthly, and yearly history. These are reporting buckets built from interface counters, not independent precision measurements. A newly created database cannot show a complete month or year until enough collection time has elapsed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install vnStat

Use your distribution package when available

Most Linux distributions package vnStat. Package names, default paths, service-unit names, and whether the daemon is enabled automatically differ by distribution and release, so follow that distribution’s current package documentation. After installation, verify which executable and unit were installed:

vnstat --version
systemctl status vnstat

If your distribution uses a differently named unit, list matching units with systemctl list-unit-files | grep -i vnstat. Do not assume that installing the command also started the collector.

Build from source

The upstream build requires a C compiler and make. SQLite development files are required for the traffic database; libgd is optional and is needed only for image output through the related vnstati utility. A typical source installation uses:

./configure --prefix=/usr --sysconfdir=/etc
make
sudo make install

Install the development packages provided by your operating system before running configure. If configuration reports a missing SQLite header or library, add that distribution’s SQLite development package and rerun the command. Keep a record of the prefix and configuration directory because they determine where the executable, service file, and configuration are installed.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enable and start the systemd service

The upstream installation examples use a systemd service file. If your package or source tree supplies one, install or copy it according to its instructions, reload systemd’s unit metadata when necessary, then enable and start the daemon:

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
sudo systemctl daemon-reload
sudo systemctl enable vnstat
sudo systemctl start vnstat
sudo systemctl status vnstat

enable makes the service start at boot; start starts it now. A successful service status only proves that the collector process is running, not that the desired interface has been added or that enough history exists to display a useful report.

Identify and register the interface you actually want

First inspect Linux’s interface names with the operating system’s normal tools:

ip link

Choose the interface carrying the traffic you intend to measure. On a virtual server this may be ens3, enp1s0, or another provider-specific name rather than the traditional eth0. Avoid selecting loopback unless you intentionally want local-only traffic, and remember that bridges, VLANs, containers, and tunnel devices can produce different accounting views.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After the daemon starts, inspect interfaces known to vnStat:

vnstat --iflist

On versions whose long-option spelling differs, run vnstat --help and use the database-listing option shown by that build. If automatic discovery did not add the interface, add it explicitly:

sudo vnstat --add -i eth0

Replace eth0 with the real name. Confirm the resulting entry with the interface-listing command before building reports around it. In a multi-interface host, specify the interface on every important query instead of relying on a default.

Run the routine reports

The following commands use eth0 as an example. Substitute the interface selected on your server.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
Question Command Use
What is the current summary? vnstat -i eth0 Quick human-readable overview for the selected interface.
How much traffic per day? vnstat -d -i eth0 Daily totals and recent daily rows.
How much traffic per month? vnstat -m -i eth0 Monthly accounting for quota and trend checks.
What happened this year? vnstat -y -i eth0 Yearly totals built from collected history.
What happened each hour? vnstat -h -i eth0 Short-term distribution across hours.
What happened in five-minute buckets? vnstat -5 -i eth0 Fine-grained recent history after those buckets have been collected.
What is moving right now? vnstat -l -i eth0 Live-style view based on current counters; it is not a replacement for packet tracing.

Use one explicit interface in scripts and runbooks. The default interface is a configuration convenience, not a safe assumption on a host with several network devices.

Keep rate units consistent

Traffic volume is commonly displayed in bytes, while rates may be displayed in bytes per second or bits per second. The Debian command documentation supports choosing the rate-unit mode. Set that mode deliberately in the shared configuration and keep it unchanged for dashboards and scripts; otherwise a value labeled “Mb/s” can be mistaken for “MB/s,” an eightfold difference.

Export data for scripts and dashboards

Human-readable tables are ideal for an SSH check, but automation should consume a documented structured format:

vnstat --json -i eth0
vnstat --xml -i eth0

JSON is usually the simplest starting point for a script, while XML can fit an existing XML pipeline. The command documentation also includes database-listing and database-dump-oriented modes for administration. Check the help output on the installed version before hard-coding an option, because distribution packages can lag or alter command-line details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A minimal shell export can write a snapshot for another process:

IFACE=eth0
vnstat --json -i "$IFACE" > /var/tmp/vnstat-"$IFACE".json

Have the consumer treat the file as a snapshot, not an instantaneous kernel reading. The daemon may not yet have saved the latest counters, and a query made during a write can represent the previous completed interval. For a robust dashboard, record the interface name, collection timestamp, RX/TX units, and the vnStat version alongside the payload.

Force a save when coordinating automation

The daemon manual documents SIGHUP behavior: it writes cached data, rescans the database directory, and reloads configuration. With a systemd-managed service, request that signal without guessing the daemon’s process ID:

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
sudo systemctl kill -s HUP vnstat

Use this when a controlled handoff or backup needs the most recent cached values. It does not turn vnStat into a packet-level real-time monitor, and it should not be sent repeatedly as a substitute for normal collection intervals.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure the database and shared behavior

vnstat.conf is shared by vnstat, vnstati, and vnstatd. Depending on how you installed the software, it is commonly under the system configuration directory selected at build time (the source example uses /etc); package layouts may differ. Consult the installed service and help output to locate the active file rather than editing an unused copy.

Relevant settings include:

  • Database directory: where per-interface history files are stored.
  • Default interface: the interface used when a command omits -i.
  • Disk-space checks: safeguards that prevent database writes when available space falls too low.
  • Update behavior: daemon intervals and related collection settings.
  • Display and rate units: the byte-versus-bit convention used by reports.

The documented Linux default database directory is /var/lib/vnstat unless configuration changes it. Treat that directory as operational state: include it in backups when long-term history matters, preserve ownership and permissions, and document any custom DatabaseDir alongside your service configuration.

There is no universal retention period or published accuracy percentage to apply to every installation. Retention depends on the vnStat version, configuration, database growth, and whether old interface databases are removed. Monitor disk usage and define your own retention and backup policy instead of promising that a particular number of years will always remain available.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Handle interface changes and migrations safely

When a newly installed interface is missing

  1. Run ip link and copy the exact Linux interface name.
  2. Check vnStat’s database list.
  3. Add the interface with vnstat --add -i INTERFACE if discovery did not create it.
  4. Run an explicit query such as vnstat -d -i INTERFACE and wait for a collection cycle.

Adding an interface starts a new history for that database entry; it cannot recreate traffic that was never collected under that name.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When a provider or migration renames the device

Interface names can change after a virtual-machine migration, operating-system reinstall, or network configuration change. Check DatabaseDir, preserve the existing per-interface database files, and verify whether the old name still maps to the same traffic source. Do not merge files or rename entries casually: an old database may represent a different device, and combining counters can make totals meaningless. If the old history is retained but the new interface is genuinely different, keep separate records and label them with their dates and roles.

Removing an obsolete entry

Use the interface-management removal option documented by your installed version (commonly vnstat --remove -i INTERFACE) only after backing up the database. Removal is an administrative action; it is not a way to correct a mistaken total while preserving an audit trail.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Troubleshoot the common failure modes

The command prints no useful data immediately after installation

  • Check systemctl status vnstat and the service journal for startup errors.
  • Confirm that the intended interface appears in vnStat’s database list.
  • Wait several minutes for the first update cycle. The upstream guide explicitly warns that results are not immediate because database entries are not updated continuously.
  • Run the query with an explicit interface after the first cycle.

The report shows the wrong interface

List interfaces with ip link, compare them with vnStat’s database list, and repeat the query using -i. On hosts with bridges, VLANs, containers, or tunnels, decide whether you want physical-link traffic, virtual-device traffic, or both; those are different accounting scopes.

Totals appear stale in a script

Remember that vnstat reads the saved database while vnstatd caches and periodically writes counters. Check the daemon’s state, allow the next save interval, or issue the documented HUP signal before a coordinated export. Do not interpret a short delay as packet loss.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

History disappeared after moving the server

Inspect the active configuration for a changed DatabaseDir, restore the preserved database files, and correct ownership and permissions for the service account. A clean reinstall can leave the old history untouched in a different directory, so search configuration and backup records before creating a replacement database.

The daemon cannot write its database

Check free disk space, the configured directory, directory permissions, and service logs. Disk-space checks are configurable; a full filesystem or an unwritable custom directory prevents new samples even though the query command itself still runs.

Know where vnStat stops being the right tool

vnStat is a good fit for lightweight, local, per-interface accounting and trend views. It does not identify individual connections, processes, applications, domains, packet contents, or attack signatures. It also does not provide a built-in centralized fleet view, universal alerting system, or a guaranteed retention period.

Need vnStat fit Use another class of tool when
Monthly quota and historical interface totals Strong fit —
Quick SSH check with minimal overhead Strong fit —
Per-connection or packet investigation Not provided You need packet capture or flow inspection.
Which process consumed bandwidth? Not provided You need host-level process attribution.
Many servers in one dashboard Limited to exported data You need centralized collection, retention, and alerting.
Sub-second incident response Limited You need a real-time telemetry or packet-analysis system.

These boundaries are consequences of vnStat’s data source: aggregate counters exposed by the operating system. Pair it with another monitor when the question is about who or what generated traffic rather than how much crossed an interface.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A repeatable operating checklist

  1. Install vnStat from the distribution package or build it with SQLite support.
  2. Locate the service and configuration file supplied by that installation.
  3. Run ip link and select the interface whose traffic should be counted.
  4. Enable and start vnstatd.
  5. Verify the interface in vnStat’s database list; add it explicitly if needed.
  6. Wait through the first collection cycle, then run an interface-specific daily or monthly query.
  7. Choose and document byte or bit rate units.
  8. For automation, consume JSON or XML and record the interface, units, timestamp, and version.
  9. Back up the configured database directory if historical continuity matters.
  10. Recheck the database path and interface mapping after migrations, renames, or reinstalls.

Following that sequence gives you reproducible per-interface history without mistaking a delayed aggregate counter for a packet trace.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.