Python Persistent Server Reporter è un’applicazione cross-platform che:
- Raccoglie metriche di sistema (IP, MAC, hostname, OS, CPU, memoria, disco, utenti)
- Invia report via SMTP a intervalli configurabili
- Gira in background come Windows Service o systemd daemon
- Si riavvia automaticamente in caso di crash o kill
- Auto-parte all’avvio del sistema
- Python 3.7+
- pip (o venv)
- Su Windows: privilegi di amministratore per installare il servizio
- Su Linux:
systemd
e permessisudo
git clone https://github.com/youruser/python-reporter.git
cd python-reporter
pip install -r requirements.txt
Modifica config.yaml
secondo le tue esigenze:
schedule: "@every 30m" # oppure cron "0 8 * * *"
smtp:
host: "smtp.example.com"
port: 587
username: "[email protected]"
password: "supersecret"
sender: "[email protected]"
recipients:
- "[email protected]"
- "[email protected]"
log:
path: "server.log"
level: "INFO"
python main.py
- Il processo rimane in foreground
- CTRL+C per terminare
- Installa il servizio:
python windows_service.py install
- Configura recovery policy:
sc.exe failure PyServerReport reset= 0 actions= restart/5000
- Avvia:
python windows_service.py start
- Stop & rimozione:
python windows_service.py stop python windows_service.py remove
- Copia file:
sudo mkdir -p /opt/server-report sudo cp main.py config.yaml /opt/server-report/ sudo cp linux_server.service /etc/systemd/system/python-server-report.service
- Abilita & avvia:
sudo systemctl daemon-reload sudo systemctl enable python-server-report sudo systemctl start python-server-report
- Status & log:
sudo systemctl status python-server-report journalctl -u python-server-report -f
pip install pyinstaller
pyinstaller --onefile app.py service.py
# quindi:
dist/service.exe install
- Costruisci immagine:
docker build -t py-server-reporter .
- Esegui:
docker run -d \ -v $(pwd)/config.yaml:/app/config.yaml:ro \ --name py-server-report \ py-server-reporter
- Email failures: controlla credenziali e port forwarding SMTP
- Svc non parte: verifica che
service.py
punti al corretto interprete Python - systemd non parte: usa
journalctl -xe
per debug
- Fork del progetto
- Branch feature:
git checkout -b feat/my-feature
- Commit e PR
GPL License – vedi LICENSE
Autore: Bocaletto Luca (@bocaletto-luca)