A minimal Flask web app that reads a list of hosts from hosts.txt and pings them, showing a simple web UI with green (up) / red (down) labels.
Features
- Backend: Flask endpoint
/api/statusthat returns JSON with host statuses. - Frontend:
static/index.htmlshows status and auto-refreshes every 30s. - Dockerfile for containerized runs.
- Create a virtualenv and install dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt- Edit
hosts.txtwith the hosts you want to monitor (one per line). You may optionally provide a name before the host/IP, e.g.:
localhost 127.0.0.1
8.8.8.8
If a name is provided, the UI shows the name in bold and the host next to it; otherwise the host is shown in bold.
- Run the app:
python app.pyBuild and run with Docker:
docker build -t pataping:latest .
docker run -p 8000:8000 pataping:latestThe app can be deployed to CERN PaaS using the provided Dockerfile. Make sure to set up the hosts.txt file appropriately before building the image. Follow CERN PaaS documentation for deployment steps.
Note
Notes on permissions and ping
- This app uses the system
pingbinary. On some systemspingrequires elevated permissions or a setuid binary. The Debian/Ubuntuiputils-pingbinary is typically available and will work inside the container. - If you run into permission issues inside containers, ensure the
inetutils-pingoriputils-pingpackage is present in the image.