LinuxCommandLibrary

vnstati

Visualize network traffic usage

TLDR

Output a summary of the last 2: months, days, and all-time

$ vnstati --summary --iface [network_interface] --output [path/to/output.png]
copy

Output the 10 most traffic-intensive days of all time
$ vnstati --top 10 --iface [network_interface] --output [path/to/output.png]
copy

Output monthly traffic statistics from the last 12 months
$ vnstati --months --iface [network_interface] --output [path/to/output.png]
copy

Output hourly traffic statistics from the last 24 hours
$ vnstati --hours --iface [network_interface] --output [path/to/output.png]
copy

SYNOPSIS

vnstati [options] [arguments]

PARAMETERS

-s, --summary
    Displays a summary of all network interfaces.

-h, --hourly
    Shows hourly traffic statistics for the current day.

-d, --daily
    Shows daily traffic statistics for the current month.

-m, --monthly
    Shows monthly traffic statistics for the current year.

-t, --top10
    Displays the top 10 days with the highest traffic usage.

-w, --weekly
    Shows weekly traffic statistics for the current year.

-p, --pages
    Generates all available statistics (daily, monthly, top, hourly, summary) as individual images.

-i <interface>, --iface <interface>
    Specifies the network interface to query (e.g., eth0).

-o <file>, --output <file>
    Saves the generated image to the specified file path. For -p, use %x to auto-name files.

-l <level>, --level <level>
    Sets the image color level (0-3), affecting the visual appearance.

-nh, --noheaders
    Suppresses the display of image headers.

-nt, --nototal
    Hides the total traffic row in summary views.

-nm, --nocolor
    Disables color output in the generated image.

-ne, --noedge
    Removes the edges from the graph bars in the image.

--altdate
    Uses an alternative date format (MM/DD instead of DD.MM).

--locale <locale>
    Sets the locale for date and time formatting within the image.

--style <style>
    Defines the output style for the image (0-2), affecting graph aesthetics.

--dbdir <directory>
    Specifies an alternative directory for the vnstat database files.

--footer <text>
    Adds custom text to the footer of the generated image.

--label <text>
    Adds custom text above the graph, acting as a label.

-v, --version
    Displays the vnstati version information.

-?, --help
    Shows a concise help message.

--longhelp
    Shows a more detailed help message, including advanced options.

--dumpconfig
    Dumps the currently used configuration settings for vnstati.

--enable-http
    Enables HTTP header output, primarily for use in CGI environments.

DESCRIPTION

vnstati is a companion utility to the vnstat network traffic monitor. It creates visually appealing PNG images from the data collected by the vnstat daemon. These images can display various network usage statistics, including daily, weekly, monthly, and hourly traffic, as well as top 10 usage days and a summary of all interfaces. It's widely used in web interfaces, custom dashboards, or scripting environments to provide an at-a-glance overview of network consumption. The command offers extensive options to customize the output, such as selecting specific interfaces, defining output file names, adjusting color schemes, and adding custom text to the images.

CAVEATS

vnstati requires the vnstat daemon to be running and collecting data. If the database is empty or corrupted, images may not generate correctly or show no data. Ensure sufficient permissions to write to the specified output directory when using the -o option.

OUTPUT FORMATS

vnstati exclusively generates PNG image files. It does not support other image formats or direct text output. The generated image can be saved to a file or piped to standard output.

USAGE WITH WEB SERVERS

Often used in conjunction with web servers (like Apache or Nginx) and CGI scripts to dynamically display network statistics on a webpage, by piping the image output directly to the browser. This allows for real-time, graphical network usage monitoring via a web interface.

HISTORY

vnstati is part of the vnstat project, which was originally created by Teemu Toivola. It emerged as a solution for visualizing the network traffic data collected by the vnstat daemon, providing a user-friendly graphical representation that could be easily integrated into web pages or monitoring dashboards. Its development has focused on providing flexible output options and maintaining compatibility with various system environments.

SEE ALSO

vnstat(1), vnstatd(8)

Copied to clipboard