vnstat is a command-line tool in Linux that is generally used by system administrators in order to monitor network parameters such as bandwidth consumption or maybe some traffic flowing in or out. It monitors the traffic on the network interfaces of the system.
Installing vnstat on Linux
In case of RedHat based Linux
yum install vnstat
In case of a ubuntu or debian Linux
apt install vnstat
Working with vnstat Command
1. To get basic stats of all network interfaces
This command will print all the basic stats of the network interfaces connected to the system.
2. To monitor a specific interface
vnstat -i wlo1
This will monitor and display the stats of the specified interface that is wlo1.
3. To get the daily stats of an interface
vnstat -d -i wlo1
This will print the daily stats of the specified interface which is wlo1.
4. To get the hourly stats of an interface
vnstat -h -i wlo1
This will print the hourly stats of the specified interface which is wlo1.
5. To display the monthly stats of a interface
vnstat -m -i wlo1
This command will display the monthly stats of the specified interface.
6. To save output to a XML file
vnstat --xml -i wlo1 >output.xml
The command will create an XML file with name output.xml and will have the output of the command in XML format.
7. To save output to a JSON file
vnstat --json -i wlo1 >output.json
This command will create a JSON file with name output.json and will have the output of the command in JSON format.
8. To save output to a text file
vnstat --oneline -i wlo1 >output.txt
This command will create a text file with name output.txt and will have the output in a one-line format.
9. To calculate traffic on the current interface
This command will display the traffic on the current network interface in use.
10. To display vnstat help
This command will display the vnstat help section.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!