Skip to main content

Pinger - Ping device via CLI

PyPI License Python

Pinger is a command-line application for monitoring network devices by pinging target IP addresses and reporting their status via MQTT. It allows you to configure MQTT settings, schedule automatic pings, and manage target devices—all from the terminal with a polished interface provided by Click and Rich.


✨ Features

  • Device Monitoring: Ping a list of devices and report if they are online or offline.
  • MQTT Reporting: Publish JSON-formatted reports to an MQTT broker.
  • Scheduling: Set and update scheduled times for automatic pings (default: 10:00, 14:00, 19:00).
  • Dynamic Configuration: Update and view MQTT settings, schedule times, and device targets through dedicated CLI commands.
  • Rich CLI Interface: User-friendly, formatted outputs (tables, progress bars, etc.) using Rich and rich-click.

🚀 Installation

Pinger CLI is available on PyPI. To install it, simply run:

pip install pinger-cli

Once installed, the pinger command will be available in your terminal.


🛠️ Usage

Starting the Pinger CLI

To start the application (which loads your configuration, sets up scheduled tasks, and listens for MQTT triggers), run:

pinger --config config.json

If no configuration file exists, you can create one or update settings using the configuration commands described below.

Commands

MQTT Configuration

  • Update MQTT Settings:
pinger setmqtt --broker new_broker_address --port 1883 --report-topic new_report_topic --trigger-topic new_trigger_topic
  • Display Combined Configuration (MQTT & Schedule Times):
pinger showconfig --config config.json

This command displays both the current MQTT configuration and the scheduled times in a table format.

Scheduling

  • Update Scheduling Times:
pinger setschedule --time 09:30 --time 12:00 --time 18:45

If you omit the --time options, the default schedule (10:00, 14:00, 19:00) will be set.

Device (IP Target) Management

  • Add a New IP Target:
pinger addtarget --substation "Substation A" --bay "Bay 1" --ied "IED1" --ip "192.168.1.10" --source-ip "192.168.1.1"
  • Display Current IP Targets:
pinger showtargets --config config.json

Triggering a Report

The application listens for MQTT messages on the trigger topic specified in your MQTT configuration. When a message (e.g., trigger) is received, the app immediately generates a report and publishes it via MQTT.

📖 Configuration File Format

Your configuration file (default: config.json) is a JSON file that may look like this:

{
  "mqtt": {
    "broker": "broker.mqtt-dashboard.com",
    "port": 1883,
    "report_topic": "muflihuns/ied/connection_report_MRNDA",
    "trigger_topic": "muflihuns/ied/trigger_report_MRNDA"
  },
  "schedule_times": ["10:00", "14:00", "19:00"],
  "ied_list": [
    {
      "substation": "GIS Marunda",
      "bay": "Bay Transformer 1",
      "ied": "OC150",
      "ip": "10.140.16.131",
      "source_ip": "10.140.16.120"
    },
    {
      "substation": "GIS Marunda",
      "bay": "Bay Transformer 1",
      "ied": "LCD",
      "ip": "10.140.16.132",
      "source_ip": "10.140.16.120"
    }
  ]
}

mqtt: Contains MQTT broker settings.

  • schedule_times: An array of times (in HH:MM format) for when the app should automatically generate reports.
  • ied_list: A list of devices with their target IP addresses, source IP addresses, and identifiers.

🪛 Troubleshooting

  • Configuration File: Ensure that your configuration file exists and is properly formatted.
  • MQTT Connection: Verify that the MQTT broker settings are correct and that the broker is reachable.
  • Ping Command: If you encounter issues with pinging devices, ensure your operating system supports the parameters used in the command (you may need to adjust the command for your OS).

🤝 Contributing

Contributions are welcome! Please open an issue or submit a pull request with your changes.

🛡️ License

This project is licensed under the MIT License.

⭐ Support

If you find Pinger useful, don’t forget to give a star ⭐ on this repository!

Metadata

Release files for pinger-mqtt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pinger-mqtt 0.1.0
File Size Uploaded
pinger_mqtt-0.1.0.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pinger-mqtt 0.1.0
File Interpreter ABI Platform
pinger_mqtt-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / pinger_mqtt-0.1.0.tar.gz

Download URL pinger_mqtt-0.1.0.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0c5b3ed990c055f61a7ad39c57720dc56fafffbbe85f47e802be347e2552afcd
BLAKE2b-256 checksum
How to use checksums
a48fc1cb5cd28a1ae3ab31819a693e860cd7088eba3e48d1637cf3d57042f9dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.6 Darwin/24.1.0

Release files / pinger_mqtt-0.1.0-py3-none-any.whl

Download URL pinger_mqtt-0.1.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7bcc54eb2bd5682696dc4c5e6492ad2a5d299137efe86636b8953a26e483b46b
BLAKE2b-256 checksum
How to use checksums
4bed593bd7d6e79464bf3f0a343754db4ee595fb48197bc75ed135bbc4e22f65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.6 Darwin/24.1.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page