How to use the command vnstati (with examples)
- Linux
- December 25, 2023
Command Description
The vnstati
command is a useful tool that generates PNG image outputs based on network traffic data collected by the vnStat
tool. It provides various options to analyze and visualize network usage statistics over different time periods. With vnstati
, you can quickly obtain summaries, top traffic days, and detailed traffic statistics for a specific network interface.
Use Case 1: Output a summary of the last 2 months, days, and all-time
Code:
vnstati --summary --iface network_interface --output path/to/output.png
Motivation:
This use case allows you to generate a visual summary of the network traffic for the last two months, days, and all-time. It helps you gain a high-level understanding of the overall network usage patterns within the specified time frame.
Explanation:
--summary
: Specifies that a summary report should be generated.--iface
: Specifies the network interface for which the report should be generated.--output
: Specifies the path and filename for the output PNG image.
Example Output:
The generated PNG image will display a summary of the network traffic, including statistics such as total usage, average traffic per day, maximum traffic per day, and peak usage time.
Use Case 2: Output the 10 most traffic-intensive days of all time
Code:
vnstati --top10 --iface network_interface --output path/to/output.png
Motivation:
By generating a report that shows the top 10 most traffic-intensive days of all time, you can easily identify the days when network usage was exceptionally high. This information can help you investigate and optimize network performance during peak usage periods.
Explanation:
--top10
: Specifies that the report should include the top 10 most traffic-intensive days.--iface
: Specifies the network interface for which the report should be generated.--output
: Specifies the path and filename for the output PNG image.
Example Output:
The generated PNG image will display a bar chart illustrating the 10 days with the highest network traffic. Each bar will represent a day, and its height will denote the amount of traffic recorded on that day.
Use Case 3: Output monthly traffic statistics from the last 12 months
Code:
vnstati --months --iface network_interface --output path/to/output.png
Motivation:
This use case allows you to analyze the monthly network traffic trends over the past year. By visualizing the traffic statistics for each month, you can identify any patterns or anomalies in network usage and plan capacity upgrades accordingly.
Explanation:
--months
: Specifies that monthly traffic statistics should be generated.--iface
: Specifies the network interface for which the report should be generated.--output
: Specifies the path and filename for the output PNG image.
Example Output:
The generated PNG image will present a line chart that showcases the monthly network traffic over the last 12 months. Each point on the chart represents the average traffic for a specific month, allowing you to observe any fluctuations or growth trends.
Use Case 4: Output hourly traffic statistics from the last 24 hours
Code:
vnstati --hours --iface network_interface --output path/to/output.png
Motivation:
By generating hourly traffic statistics for the last 24 hours, you can gain insights into the network activity throughout the day. This information is particularly useful for identifying peak hours, potential congestion, or abnormal usage patterns that could impact overall network performance.
Explanation:
--hours
: Specifies that hourly traffic statistics should be generated.--iface
: Specifies the network interface for which the report should be generated.--output
: Specifies the path and filename for the output PNG image.
Example Output:
The generated PNG image will display a column chart showcasing the network traffic on an hourly basis over the past 24 hours. Each column represents an hour, and its height indicates the amount of traffic during that hour, allowing you to visualize patterns and identify periods of high or low network utilization.
Conclusion:
The vnstati
command is a powerful tool for generating visually informative reports based on network traffic data. By leveraging its various options, you can gain valuable insights into network usage patterns, identify peak traffic periods, and make data-driven decisions to optimize network performance.