Skip to content

rohingosling/pinger

Repository files navigation

Ping Logger

A Python application to ping a specified host, log the results to a CSV file, and print statistics to the console. The project supports configurable packet sizes and optional CSV logging.

Why did I create this? Because I did'nt like the output format of the default Windows ping command. And, I felt like making a pinger, for fun. So, here we are.

Table of Contents

  1. Features
  2. Usage
  3. Installation
  4. Contributing
  5. License
  6. Contact Information
  7. Acknowledgements

Features

  • Ping a specified host with a configurable packet size.
  • Log ping results to a CSV file.
  • Print statistics to the console.

Usage

CLI Usage:

python main.py -H <host> -s <packet_size> [-f]
  • <host> : The host to ping (default: 8.8.8.8)
  • <packet_size> : The size of the ping packet in bytes (default: 32)
  • -f : Enable logging to a CSV file (optional)

Example 1:

  • Ping Google with 32-byte packets.
  • Do not write output to CSV file, i.e. do not include the -f argument.
  • Press [Ctrl+C] to exit program.
python main.py -H 8.8.8.8 -s 32
2025-07-18 23:06:28.664    Ping: "8.8.8.8"    Packet Size: 32 bytes    Delay: 5.5 ms    Min: 5.5 ms    Max: 5.5 ms    Average: 5.5 ms    Packets Sent: 1    Packets Lost: 0 (0.00%)
2025-07-18 23:06:29.671    Ping: "8.8.8.8"    Packet Size: 32 bytes    Delay: 5.5 ms    Min: 5.5 ms    Max: 5.5 ms    Average: 5.5 ms    Packets Sent: 2    Packets Lost: 0 (0.00%)
2025-07-18 23:06:30.677    Ping: "8.8.8.8"    Packet Size: 32 bytes    Delay: 5.5 ms    Min: 5.5 ms    Max: 5.5 ms    Average: 5.5 ms    Packets Sent: 3    Packets Lost: 0 (0.00%)
2025-07-18 23:06:31.684    Ping: "8.8.8.8"    Packet Size: 32 bytes    Delay: 5.4 ms    Min: 5.1 ms    Max: 5.5 ms    Average: 5.4 ms    Packets Sent: 4    Packets Lost: 0 (0.00%)

Example 2:

  • Ping local host with 128-byte packets.
  • Write output to CSV file, i.e. Include the -f argument.
    • The file name will looks simialr to this, ping_log_20250718_230821_192_168_1_1_128.csv.
  • Press [Ctrl+C] to exit program.
python main.py -H 192.168.1.1 -s 128 -f
2025-07-18 23:08:21.122    Ping: "192.168.1.1"    Packet Size: 128 bytes    Delay: 2.8 ms    Min: 2.8 ms    Max: 2.8 ms    Average: 2.8 ms    Packets Sent: 1    Packets Lost: 0 (0.00%)
2025-07-18 23:08:22.125    Ping: "192.168.1.1"    Packet Size: 128 bytes    Delay: 2.7 ms    Min: 2.5 ms    Max: 2.8 ms    Average: 2.7 ms    Packets Sent: 2    Packets Lost: 0 (0.00%)
2025-07-18 23:08:23.129    Ping: "192.168.1.1"    Packet Size: 128 bytes    Delay: 2.6 ms    Min: 2.5 ms    Max: 2.8 ms    Average: 2.6 ms    Packets Sent: 3    Packets Lost: 0 (0.00%)
2025-07-18 23:08:24.133    Ping: "192.168.1.1"    Packet Size: 128 bytes    Delay: 2.7 ms    Min: 2.5 ms    Max: 3.0 ms    Average: 2.7 ms    Packets Sent: 4    Packets Lost: 0 (0.00%)

Code Usage

from app_config import AppConfig
from application import Application

if __name__ == "__main__":
    config = AppConfig().get_arguments()
    app = Application(config)
    app.run()

Installation

Prerequisites

  • Python 3.x

Steps

  1. Clone the repository:

    git clone https://github.com/your-username/your-repo.git
  2. Navigate to the project directory:

    cd your-repo
  3. Create and activate the virtual environment using the provided batch files:

    • To create the virtual environment and activate it, run:

      venv_create.bat
    • If you need to activate the virtual environment later, run:

      venv_activate.bat
    • To deactivate the virtual environment, run:

      venv_deactivate.bat
    • To delete the virtual environment, run:

      venv_delete.bat
  4. Install the required packages:

    venv_install_requirements.bat
  5. To save the current list of installed packages to venv_requirements.txt, run:

    venv_save_requirements.bat

Contributing

Contributions are welcome! Please follow the contribution guidelines.

  1. Fork the project.
  2. Create your feature branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a pull request.

License

Distributed under the MIT License. See LICENSE for more information.

Contact Information

Acknowledgements

About

Utility to ping a host and measure response time, using Python ping3 package.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors