This is a simple Python Flask application that pings google.com
(by default) and show result in web graphs.
📶 Demo
- App is designed to use Postgres and run on Raspberry PI, I assume it can run on other platforms and use other database technologies with basic modifications.
- Development was done on WinOS
These instructions will get you a copy of the project up and running on your RPI.
Raspbian is our official operating system for all models of the Raspberry Pi. Use Raspberry Pi Imager for an easy way to install Raspbian and other operating systems to an SD card ready to use with your Raspberry Pi
Alternatively, use the link below: https://www.raspberrypi.org/downloads/
In a basic Raspbian install, the boot files are stored on the first partition of the SD card, which is formatted with the FAT file system. This means that it can be read on Windows, macOS, and Linux devices.
When the Raspberry Pi is powered on, it loads various files from the boot partition/folder in order to start up the various processors, then it boots the Linux kernel.
More information at https://www.raspberrypi.org/documentation/
- Add empty
ssh
file enable SSH on boot. - Add
wpa_supplicant.conf
file to boot folder to configure wifi on boot.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=RU
network={
ssid="YOUR_WIFI_SID"
psk="YOUR_WIFI_PASSWORD"
key_mgmt=WPA-PSK
}
- Connect to RPI via ssh, default login:pass -
pi:raspberry
- Update packages
sudo apt-get update && sudo apt-get upgrade
- Configure your Raspberry Pi
sudo raspi-config
Install Docker
curl -sSL https://get.docker.com | sh
Add permission to Pi User to run Docker Commands
sudo usermod -aG docker pi
❗ Reboot here or run the next commands with a sudo
Test Docker installation
docker run hello-world
Install proper dependencies
sudo apt-get install -y libffi-dev libssl-dev
sudo apt-get install -y python3 python3-pip
sudo apt-get remove python-configparser
Install Docker Compose
sudo pip3 install docker-compose
Clone the repo
git clone https://github.com/aatrubilin/pinger
Go to project path
cd pinger
Up docker compose
docker-compose up -d --build
Boom! 🔥 It's done! Go to http://{RPI IP}
Tests not ready yet...
Make sure to have the following on your host:
Clone the repo
git clone https://github.com/aatrubilin/pinger
Go to project path
cd pinger
Create a virtualenv:
python3 -m venv venv
Activate the virtualenv you have just created:
source venv/bin/activate
Install development requirements:
pip3 install -r requirements-dev.txt
Install pre-commit hooks
pre-commit install
Create a new PostgreSQL user and database:
sudo -u postgres psql
CREATE DATABASE pinger;
CREATE USER pinger WITH ENCRYPTED PASSWORD 'pinger';
GRANT ALL PRIVILEGES ON DATABASE pinger TO pinger;
Set the environment variables
export FLASK_ENV=development
export PING_HOSTS=google.com
export PING_DELAY_SEC=60
export PING_FAIL_DELAY_SEC=5
export DB_URL=postgresql://pinger:pinger@db/pinger
Run the app
python pinger/run.py
- Flask - Python web microframework
- Highcharts - SVG-based, multi-platform charting library
- Flatpickr - Javascript datetime picker
- PostgreSQL 10 - Relational Database
- Docker - App containerization
- Alexandr Trubilin - Initial work - AATrubilin
This project is licensed under the MIT License - see the LICENSE file for details