Top Related Projects
Architected for speed. Automated for easy. Monitoring and troubleshooting, transformed!
Web-based Traffic and Security Network Traffic Monitoring
The Prometheus monitoring system and time series database.
Community-based GPL-licensed network monitoring system
Real-time monitoring of IT components and services, such as networks, servers, VMs, applications and the cloud.
Quick Overview
vnStat is a console-based network traffic monitor for Linux and BSD. It keeps a log of network traffic for selected interfaces, allowing users to view daily, weekly, and monthly statistics. vnStat operates as a daemon and can be used to generate reports and graphs.
Pros
- Lightweight and efficient, with minimal system resource usage
- Provides detailed network traffic statistics over various time periods
- Supports multiple interfaces and can generate graphs
- Easy to install and configure
Cons
- Limited to command-line interface, which may not be user-friendly for some
- Requires root access for installation and initial setup
- May require additional tools for graphical output (e.g., vnstati)
- Limited customization options for data presentation
Getting Started
-
Install vnStat:
sudo apt-get install vnstat
-
Start the vnStat daemon:
sudo systemctl start vnstat
-
Enable vnStat to start on boot:
sudo systemctl enable vnstat
-
View network traffic statistics:
vnstat
-
For more detailed options and interface-specific data:
vnstat --help vnstat -i eth0
Competitor Comparisons
Architected for speed. Automated for easy. Monitoring and troubleshooting, transformed!
Pros of netdata
- Comprehensive real-time monitoring of system and application metrics
- User-friendly web interface with interactive charts and dashboards
- Extensive plugin system for monitoring various services and applications
Cons of netdata
- Higher resource usage due to its comprehensive monitoring capabilities
- More complex setup and configuration compared to simpler alternatives
- Steeper learning curve for advanced features and customizations
Code comparison
netdata (in C):
static inline collected_number prometheus_parse_mt(const char *v) {
char *e;
collected_number value = str2ll(v, &e);
if(e && *e == 'e') {
int exponent = (int)str2i(&e[1]);
value *= powl(10, exponent);
}
return value;
}
vnstat (in C):
int getifinfo(const char *iface)
{
FILE *fp;
char temp[64], txfile[64], rxfile[64];
snprintf(rxfile, 64, "%s/%s/statistics/rx_bytes", SYSFS, iface);
snprintf(txfile, 64, "%s/%s/statistics/tx_bytes", SYSFS, iface);
if ((fp = fopen(rxfile, "r")) == NULL) {
return 0;
}
Both projects are written in C, but netdata's codebase is more extensive and complex, reflecting its broader feature set. vnstat focuses specifically on network traffic monitoring, resulting in a simpler codebase.
Web-based Traffic and Security Network Traffic Monitoring
Pros of ntopng
- More comprehensive network monitoring with real-time traffic analysis
- Advanced visualization and reporting capabilities
- Supports a wider range of protocols and network technologies
Cons of ntopng
- Higher system resource requirements
- More complex setup and configuration process
- Steeper learning curve for new users
Code Comparison
ntopng (C++):
void Flow::updateTcpFlags(u_int8_t flags) {
if(flags != 0) {
tcp_flags_last = flags;
if(flags & TH_SYN) tcp_flags_ts.set(0);
if(flags & TH_FIN) tcp_flags_ts.set(1);
if(flags & TH_RST) tcp_flags_ts.set(2);
}
}
vnstat (C):
void updatetrafficdb(const char *iface, const uint64_t *rx, const uint64_t *tx) {
uint64_t rxchange = 0, txchange = 0;
if (*rx >= data.interface.rxcounter) {
rxchange = *rx - data.interface.rxcounter;
}
if (*tx >= data.interface.txcounter) {
txchange = *tx - data.interface.txcounter;
}
addtraffic(rxchange, txchange);
}
The code snippets demonstrate the different focus areas of the projects. ntopng handles more complex network analysis tasks, while vnstat focuses on simpler traffic accounting.
The Prometheus monitoring system and time series database.
Pros of Prometheus
- More comprehensive monitoring solution with a powerful query language (PromQL)
- Supports a wide range of exporters and integrations
- Highly scalable and suitable for large-scale deployments
Cons of Prometheus
- Steeper learning curve and more complex setup compared to vnstat
- Higher resource consumption, especially for large-scale monitoring
- Requires additional components (e.g., Grafana) for optimal visualization
Code Comparison
vnstat (C):
void update_traffic(uint64_t rx, uint64_t tx) {
current.rx += rx;
current.tx += tx;
// Update database and calculate rates
}
Prometheus (Go):
func (c *Counter) Inc() {
c.Add(1)
}
func (c *Counter) Add(v float64) {
c.Value.Add(v)
}
Summary
Prometheus is a more powerful and scalable monitoring solution suitable for complex environments, while vnstat is a lightweight network traffic monitor focused on simplicity. Prometheus offers advanced querying and alerting capabilities but requires more resources and setup time. vnstat is easier to use and lighter on system resources but has limited functionality compared to Prometheus.
Community-based GPL-licensed network monitoring system
Pros of LibreNMS
- Comprehensive network monitoring solution with extensive device support
- Web-based interface with customizable dashboards and alerting
- Active community and regular updates
Cons of LibreNMS
- More complex setup and configuration compared to vnstat
- Higher resource requirements for running the full monitoring suite
Code Comparison
LibreNMS (PHP):
$device = device_by_id_cache($device_id);
$graphs = get_graphs_by_device($device);
$ports = get_ports_by_device($device_id);
vnstat (C):
void showdb(int qmode, char *iface, int newdb)
{
readdb(iface, 0);
if (newdb) {
initdb();
}
}
Summary
LibreNMS is a feature-rich network monitoring system with a web interface, while vnstat is a lightweight console-based network traffic monitor. LibreNMS offers more comprehensive monitoring capabilities but requires more resources and setup time. vnstat is simpler to use and has lower system requirements but provides more basic network traffic statistics. The choice between them depends on the specific monitoring needs and available resources.
Real-time monitoring of IT components and services, such as networks, servers, VMs, applications and the cloud.
Pros of Zabbix
- Comprehensive monitoring solution with support for various metrics and devices
- Scalable architecture suitable for large enterprise environments
- Extensive customization options and plugin ecosystem
Cons of Zabbix
- Steeper learning curve and more complex setup compared to vnstat
- Higher resource requirements for deployment and operation
- May be overkill for simple network traffic monitoring needs
Code Comparison
vnstat (simple command-line usage):
vnstat -i eth0 -l
Zabbix (example of adding a host via API):
from pyzabbix import ZabbixAPI
zapi = ZabbixAPI("http://zabbix.example.com")
zapi.login("Admin", "zabbix")
zapi.host.create(
host="Example Host",
interfaces={"type": 1, "main": 1, "useip": 1, "ip": "192.168.1.1", "dns": "", "port": "10050"},
groups={"groupid": "4"},
templates={"templateid": "10001"}
)
Summary
Zabbix is a feature-rich, enterprise-grade monitoring solution with extensive capabilities, while vnstat is a lightweight, focused tool for network traffic monitoring. Zabbix offers more comprehensive monitoring but requires more resources and setup time. vnstat is simpler to use and more suitable for basic network traffic monitoring needs.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
vnStat
vnStat is a console-based network traffic monitor that uses the network interface statistics provided by the kernel as information source. This means that vnStat won't actually be sniffing any traffic and also ensures light use of system resources regardless of network traffic rate.
By default, traffic statistics are stored on a five minute level for the last 48 hours, on a hourly level for the last 4 days, on a daily level for the last 2 full months and on a yearly level forever. The data retention durations are fully user configurable. Total seen traffic and a top days listing is also provided. Optional image output is available in systems with the GD library installed.
See the official webpage for additional details and output examples.
Getting started
vnStat works best when installed. It's possible to either use the latest stable release, get the current development version from git or use a Docker container containing the pre-compiled latest stable release.
Stable version
wget https://humdi.net/vnstat/vnstat-latest.tar.gz
- optional steps for verifying the file signature
wget https://humdi.net/vnstat/vnstat-latest.tar.gz.asc
gpg --keyserver pgp.mit.edu --recv-key 0xDAFE84E63D140114
gpg --verify vnstat-latest.tar.gz.asc vnstat-latest.tar.gz
- the signature is correct if the output shows "Good signature from Teemu Toivola"
tar zxvf vnstat-latest.tar.gz
cd vnstat-*
Development version
git clone https://github.com/vergoh/vnstat
cd vnstat
In both above cases, continue with instructions from the INSTALL or INSTALL_BSD file depending on used operating system. Instructions for upgrading from a previous version are included in the UPGRADE file. Release notes can be found from the CHANGES file.
Docker container
docker run -d \
--restart=unless-stopped \
--network=host \
-e HTTP_PORT=8685 \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone:ro \
--name vnstat \
vergoh/vnstat
For more details regarding container usage, available environment variables and
a docker-compose.yml example, see the vergoh/vnstat-docker
git repository or Docker Hub. The same
container images are also being published as ghcr.io/vergoh/vnstat
.
Contacting the author
- email - Teemu Toivola <tst at iki dot fi>
- irc - Vergo (IRCNet)
- git - https://github.com/vergoh/vnstat
Bug reports, improvement ideas, feature requests and pull requests should be sent using the matching features on GitHub as those are harder to miss or forget.
Top Related Projects
Architected for speed. Automated for easy. Monitoring and troubleshooting, transformed!
Web-based Traffic and Security Network Traffic Monitoring
The Prometheus monitoring system and time series database.
Community-based GPL-licensed network monitoring system
Real-time monitoring of IT components and services, such as networks, servers, VMs, applications and the cloud.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot