5 stable releases
3.0.0 | Aug 3, 2024 |
---|---|
2.0.0 | Aug 1, 2024 |
1.9.999 | Jul 31, 2024 |
#933 in Network programming
35KB
599 lines
ifstat-rs
ifstat-rs
is a straightforward and efficient Rust tool to report network interface stats, similar to ifstat.
Features
- Real-time Monitoring: Parses and displays RX and TX bytes for each network interface every second.
- Interface Flexibility: Monitor specific interfaces, all interfaces, or just loopback interfaces.
- Configurable Updates: Set delays between updates and limit the number of updates.
- Interface Listing with Friendly Names: Displays friendly names for interfaces where supported (currently Windows).
Supported Platforms
- Linux: Fully supported with real-time network statistics from
/proc/net/dev
. - Windows: Supported as of v2.0.0.
- macOS: Supported as of v3.0.0.
Installation
To install ifstat-rs
, ensure you have Rust and Cargo installed.
Choose option A or B:
A: Release from crates.io
cargo install ifstat-rs
B: Install from Development Git Repository
cargo build --release
sudo cp target/release/ifstat-rs /usr/local/bin/
ifstat-rs --version
Usage
Options
ifstat-rs
-a
: Monitor all interfaces.-l
: Include loopback interfaces.-z
: Hide inactive interfaces where the counter stays zero.-i <interfaces>
: Specify interfaces to monitor, separated by commas (e.g.,-i eth0,lo
).--list-interfaces
: List all interfaces, with their friendly names where supported (currently Windows).--first-measurement <seconds>
: Set delay before the first measurement (default is the same as --delay).<delay>
: Delay between updates in seconds (default is 1 second).<count>
: Number of updates before stopping (default is unlimited).
By default, ifstat-rs shows all interfaces excluding "lo".
Examples
Default usage:
$ ifstat-rs
eth0
KB/s in KB/s out
8724.76 225.89
10356.68 259.95
13281.06 294.90
Monitor specific interfaces:
# Linux/Mac-style
ifstat-rs -i eth0,wlan1
# Windows-style
ifstat-rs -i "\DEVICE\TCPIP_{66963456-C690-4E4E-940B-E7C915B9A07D},\DEVICE\TCPIP_{97D92124-3AC3-45B5-8634-F6547F9676CE}"
Lookup list of interfaces, (on Windows: with Adapter Names where present):
$ ifstat-rs --list-interfaces
3 adapters:
\DEVICE\TCPIP_{66963456-C690-4E4E-940B-E7C915B9A07D} Ethernet
\DEVICE\TCPIP_{3CE6ABDA-3928-11EF-BFD9-806E6F6E6963} Loopback Pseudo-Interface 1
\DEVICE\TCPIP_{97D92124-3AC3-45B5-8634-F6547F9676CE} vEthernet (nat)
16 interfaces:
[...]
\DEVICE\TCPIP_{97D92124-3AC3-45B5-8634-F6547F9676CE} (vEthernet (nat))
\DEVICE\TCPIP_{66963456-C690-4E4E-940B-E7C915B9A07D} (Ethernet)
\DEVICE\TCPIP_{34DB3D4C-C1FC-4CDF-8BB2-9A7B1D40D640}
\DEVICE\TCPIP_{3CE6ABDA-3928-11EF-BFD9-806E6F6E6963} (Loopback Pseudo-Interface 1)
[...]
Monitor all interfaces, measure every second, for 10 seconds:
ifstat-rs -a 1 10
Include loopback interfaces:
ifstat-rs -l
Specify delay and count - first measure after 1 second, then every 60 seconds:
ifstat-rs -a --first-measurement 1 60
Development
Run the tool with:
cargo run -- -a
License
This project is licensed under the MIT License - see the LICENSE file for details.
"This project has been generated with the assistance of ChatGPT. Please be aware that ChatGPT can make mistakes. It is important to review and verify all information provided by the tool." is what it says. Just so you know. Because I guess maybe all the bugs aren't my fault after all.
Dependencies
~7–48MB
~746K SLoC