Skip to main content

a CLI app to ping IP-Address then send the status via MQTT

Project description

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pinger_mqtt-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pinger_mqtt-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file pinger_mqtt-0.1.0.tar.gz.

File metadata

  • Download URL: pinger_mqtt-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.6 Darwin/24.1.0

File hashes

Hashes for pinger_mqtt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0c5b3ed990c055f61a7ad39c57720dc56fafffbbe85f47e802be347e2552afcd
MD5 19571de39bab4796108b36b99ef4d651
BLAKE2b-256 a48fc1cb5cd28a1ae3ab31819a693e860cd7088eba3e48d1637cf3d57042f9dd

See more details on using hashes here.

File details

Details for the file pinger_mqtt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pinger_mqtt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.6 Darwin/24.1.0

File hashes

Hashes for pinger_mqtt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bcc54eb2bd5682696dc4c5e6492ad2a5d299137efe86636b8953a26e483b46b
MD5 72187706d9d53e147cb7355e2675b9cf
BLAKE2b-256 4bed593bd7d6e79464bf3f0a343754db4ee595fb48197bc75ed135bbc4e22f65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page