Home

Awesome

Zag-NetStats

Zag-NetStats is a lightweight and efficient network monitoring tool written in Go. It collects and displays real-time statistics about network interfaces, including data transfer speeds and total usage. With a clean interface and customizable output formats, it’s suitable for developers, system administrators, and anyone who needs detailed network statistics.

<br> <div align="center">

Version Downloads Stars

Go Go Report Card Code Size Top Language

</div> <br>

Features


Installation

Option 1: Download from Releases

  1. Go to the Releases page of the repository.
  2. Download the binary for your operating system.
  3. Extract the downloaded file.
  4. Run the binary:
    ./zag-netStats -i <interface_name>
    

Option 2: Build from Source

  1. Ensure you have Go installed (version 1.23.2 or higher).
  2. Clone this repository:
    git clone https://github.com/ShadowZagrosDev/Zag-NetStats.git
    cd Zag-NetStats
    
  3. Build the binary:
    go build -o zag-netStats ./cmd/main.go
    
  4. Run the tool:
    ./zag-netStats -i <interface_name>
    

Usage

Command-Line Options

OptionDescriptionDefault Value
-i (required)Specify the network interface to monitor.N/A
-tRefresh interval in seconds (1 to 3600).1
-pPrecision for rounding numerical values (0 to 6).2
-fOutput format: json or table.table

Example

Monitor a network interface (eth0) with a refresh interval of 2 seconds and JSON output:

./zag-netStats -i eth0 -t 2 -f json

Sample Output

Tabular Format

+-----------+------------+------------+------------+------------+-------------+
| Interface | Sent Speed | Recv Speed | Total Sent | Total Recv | Total Usage |
+-----------+------------+------------+------------+------------+-------------+
| eth0      | 12.34 MB/s | 56.78 MB/s | 1.23 GB    | 4.56 GB    | 5.79 GB     |
+-----------+------------+------------+------------+------------+-------------+

JSON Format

{
  "interface": "eth0",
  "sentSpeed": { "value": 12.34, "unit": "MB/s" },
  "recvSpeed": { "value": 56.78, "unit": "MB/s" },
  "totalSent": { "value": 1.23, "unit": "GB" },
  "totalRecv": { "value": 4.56, "unit": "GB" },
  "totalUsage": { "value": 5.79, "unit": "GB" }
}

How It Works

  1. Interface Selection: The tool retrieves network I/O statistics for the specified interface using gopsutil.
  2. Data Processing:
    • Calculates instantaneous upload and download speeds.
    • Computes total data sent and received since the start of monitoring.
  3. Output Rendering: Formats the data as a table or JSON for display.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch.
  3. Commit your changes.
  4. Submit a pull request.

Please ensure your changes are well-documented and tested.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments


Issues

For issues and feature requests, please use the GitHub Issues section.


Author

ShadowZagrosDev

Feel free to connect via GitHub for any questions or feedback.