To install vnStat, a network traffic monitor, on CentOS or RHEL, you can use the following steps:
- Install the vnstat package:
sudo yum install vnstat
- Start the vnstat daemon and enable it to start automatically at boot time:
sudo systemctl start vnstat
sudo systemctl enable vnstat
- Create a database for the desired network interfaces:
sudo vnstat --create -i <interface>
Replace <interface>
with the name of the interface you want to monitor (e.g., eth0
).
- Check the vnstat status:
sudo vnstat -u
- Display the current network traffic statistics:
sudo vnstat
By default, vnStat keeps a log of daily traffic. You can display the traffic statistics for specific days, months, or years by using the vnstat
command with the appropriate options.