Friendly Pinger

Written by

in

Building a Network Monitoring Tool in Python Network downtime costs businesses time, money, and reputation. 🖥️ Monitoring server availability does not require complex, expensive enterprise software. You can build a lightweight, automated uptime monitor using Python in just a few minutes.

Assuming you want to monitor a standard list of web servers using basic ICMP ping requests, here is a complete guide to building a custom tool named Friendly Pinger. Prerequisites

To build this tool, you need Python installed on your system. You also need the ping3 library, which handles network requests without requiring admin privileges on most systems. Install the library using your terminal: pip install ping3 Use code with caution.

Create a file named friendly_pinger.py and add the following code:

import time from ping3 import ping # Configuration TARGETS = [“google.com”, “github.com”, “localhost”] INTERVAL = 5 # Seconds between checks def check_servers(): print(“— Friendly Pinger Started —”) while True: for target in TARGETS: # Measure response time in seconds response = ping(target, timeout=2) if response is None: print(f”❌ {target} is DOWN (Timeout)“) elif response is False: print(f”❌ {target} is DOWN (Resolution Error)“) else: # Convert to milliseconds ms = round(response1000, 2) print(f”✅ {target} is ONLINE | Latency: {ms}ms”) print(“-” * 30) time.sleep(INTERVAL) if name == “main”: try: check_servers() except KeyboardInterrupt: print(” Friendly Pinger stopped successfully.“) Use code with caution. How It Works

Target List: The TARGETS array holds the domain names or IP addresses you want to track.

Ping Function: The ping() function sends a packet to the target and measures the round-trip time.

Error Handling: The script explicitly checks for timeouts (None) and DNS failures (False).

Loop Interval: The time.sleep() function prevents network congestion by spacing out the checks. Next Steps

This script provides a foundational command-line interface. You can expand its capabilities by adding features like email alerts via smtplib, logging results to a CSV file for uptime reports, or building a simple graphical user interface using tkinter.

To help tailor this article or code further, please let me know:

Is “Friendly Pinger” intended to be a Python script, a desktop app, or a web service?

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *