{"id":18060253,"url":"https://github.com/friedjof/pingping","last_synced_at":"2025-04-05T12:14:21.601Z","repository":{"id":260370670,"uuid":"881112087","full_name":"Friedjof/PingPing","owner":"Friedjof","description":"PingPing is a Python tool that measures latency between hosts and sends the results to an MQTT server. It runs as a daemon and periodically publishes latency, packet loss, and reachability metrics.","archived":false,"fork":false,"pushed_at":"2024-10-30T23:55:52.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T12:14:18.657Z","etag":null,"topics":["latency","monitoring","mqtt","network","network-analysis","packet-loss","ping","pingping","python","reachability"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Friedjof.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-30T23:33:20.000Z","updated_at":"2024-10-30T23:55:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"77813d61-e787-409c-b27b-350acea04366","html_url":"https://github.com/Friedjof/PingPing","commit_stats":null,"previous_names":["friedjof/pingping"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Friedjof%2FPingPing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Friedjof%2FPingPing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Friedjof%2FPingPing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Friedjof%2FPingPing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Friedjof","download_url":"https://codeload.github.com/Friedjof/PingPing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332596,"owners_count":20921854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["latency","monitoring","mqtt","network","network-analysis","packet-loss","ping","pingping","python","reachability"],"created_at":"2024-10-31T04:06:43.454Z","updated_at":"2025-04-05T12:14:21.581Z","avatar_url":"https://github.com/Friedjof.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PingPing\n\nPingPing is a simple tool to measure the latency between two hosts. It is written in Python and uses the MQTT protocol to send the results to a server. PingPing runs in the background as a daemon and sends the results to the server at regular intervals.\n\n## Installation\n\nTo install PingPing, you need to have Python 3.6 or higher installed on your system.\n\n### 1. Clone the Repository\n\nClone the repository to a temporary location:\n\n```shell\ngit clone https://github.com/Friedjof/PingPing.git\n```\n\n### 2. Move the Project to `/opt`\n\nMove the project to `/opt`:\n\n```shell\nsudo mv PingPing /opt/PingPing\n```\n\nSet permissions for `/opt/PingPing`:\n\n```shell\nsudo chown -R root:root /opt/PingPing\nsudo chmod -R 755 /opt/PingPing\n```\n\n### 3. Create a Virtual Environment and Install Requirements\n\nNavigate to the project directory and create a virtual environment:\n\n```shell\ncd /opt/PingPing\n```\n\nIf you don't have the `python3-venv` package installed, you can install it with the following command:\n```shell\nsudo apt install python3.11-venv\n```\n\nCreate the virtual environment:\n```shell\nsudo python3 -m venv .venv\n```\n\nActivate the virtual environment:\n\n```shell\nsource .venv/bin/activate\n```\n\nInstall the required packages from `requirements.txt`:\n\n```shell\nsudo .venv/bin/pip install -r requirements.txt\n```\n\n### 4. Create the `.env` File\n\nIn the `/opt/PingPing` directory, create a `.env` file with the following content:\n\n```shell\nMQTT_BROKER_HOST=your-mqtt-broker-host # e.g. mqtt.eclipse.org\nMQTT_BROKER_PORT=your-mqtt-broker-port # e.g. 1883\nMQTT_USERNAME=your-mqtt-username       # optional\nMQTT_PASSWORD=your-mqtt-password       # optional\nPING_INTERVAL=your-ping-interval       # in seconds (e.g. 60)\nPING_COUNT=your-ping-count             # number of pings per interval (e.g. 5), the average is calculated\nPING_TARGETS=your-ping-targets         # comma-separated list of targets (e.g. 'github.com,ecosia.org')\n```\n\n### 5. Configure the systemd Service\n\n1. In the root directory of the project, you will find the `pingping.service` file. Copy it to the systemd directory:\n\n   ```shell\n   sudo cp /opt/PingPing/pingping.service /etc/systemd/system/pingping.service\n   ```\n\n2. Reload the systemd daemon and enable the service to start on boot:\n\n   ```shell\n   sudo systemctl daemon-reload\n   sudo systemctl enable pingping\n   sudo systemctl start pingping\n   ```\n\nNow the service is running in the background and sends the results to the MQTT server at regular intervals.\n\nYou can check the status of the service with the following command:\n\n```shell\nsudo systemctl status pingping\n```\n\n### 6. MQTT Topics\n\nThe results are sent to the following MQTT topics:\n- `pingping/\u003cip-or-hostname\u003e/latency`: The latency in milliseconds (average of the pings)\n- `pingping/\u003cip-or-hostname\u003e/packet_loss`: The packet loss in percentage\n- `pingping/\u003cip-or-hostname\u003e/timestamp`: The timestamp of the measurement in milliseconds since epoch\n- `pingping/\u003cip-or-hostname\u003e/reachable`: Whether the target is reachable or not\n\n## Development\n\nYou can set up a mosquitto broker locally for testing purposes. The broker can be started with the following command:\n\n1. Set up your password file:\n    \n   ```shell\n   docker run -it --rm -v $(pwd)/mosquitto/config:/mosquitto/config eclipse-mosquitto mosquitto_passwd -c /mosquitto/config/passwordfile \u003cusername\u003e\n   ```\n\n2. Start the broker:\n\n   ```shell\n   docker compose up -d\n   ```\n\n\u003e **Note:** To subscribe to the topics, you can use the [MQTT Explorer](https://mqtt-explorer.com/) or the `mosquitto_sub` command.\n\n## License\n\nThis project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriedjof%2Fpingping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriedjof%2Fpingping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriedjof%2Fpingping/lists"}