Skip to content

Python Persistent Server Reporter Author: Bocaletto Luca 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 c

License

Notifications You must be signed in to change notification settings

bocaletto-luca/Py-Server-Gen

Repository files navigation

Python Persistent Server Reporter

Author: Bocaletto Luca

License: GPL v3 Language: Python Linux-Compatible Status: Complete

Python Persistent Server Reporter è un’applicazione cross-platform che:

  1. Raccoglie metriche di sistema (IP, MAC, hostname, OS, CPU, memoria, disco, utenti)
  2. Invia report via SMTP a intervalli configurabili
  3. Gira in background come Windows Service o systemd daemon
  4. Si riavvia automaticamente in caso di crash o kill
  5. Auto-parte all’avvio del sistema

📋 Prerequisiti

  • Python 3.7+
  • pip (o venv)
  • Su Windows: privilegi di amministratore per installare il servizio
  • Su Linux: systemd e permessi sudo

📥 Installazione

git clone https://github.com/youruser/python-reporter.git
cd python-reporter
pip install -r requirements.txt

⚙️ Configurazione

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"

▶️ Esecuzione Manuale

python main.py
  • Il processo rimane in foreground
  • CTRL+C per terminare

⚙️ Installazione come Servizio

Windows

  1. Installa il servizio:
    python windows_service.py install
  2. Configura recovery policy:
    sc.exe failure PyServerReport reset= 0 actions= restart/5000
  3. Avvia:
    python windows_service.py start
  4. Stop & rimozione:
    python windows_service.py stop
    python windows_service.py remove

Linux (systemd)

  1. 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
  2. Abilita & avvia:
    sudo systemctl daemon-reload
    sudo systemctl enable python-server-report
    sudo systemctl start python-server-report
  3. Status & log:
    sudo systemctl status python-server-report
    journalctl -u python-server-report -f

📦 Packaging

PyInstaller (Windows)

pip install pyinstaller
pyinstaller --onefile app.py service.py
# quindi:
dist/service.exe install

Docker

  1. Costruisci immagine:
    docker build -t py-server-reporter .
  2. Esegui:
    docker run -d \
      -v $(pwd)/config.yaml:/app/config.yaml:ro \
      --name py-server-report \
      py-server-reporter

🐞 Troubleshooting

  • 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

🤝 Contribuire

  1. Fork del progetto
  2. Branch feature: git checkout -b feat/my-feature
  3. Commit e PR

📄 Licenza

GPL License – vedi LICENSE


Autore: Bocaletto Luca (@bocaletto-luca)

About

Python Persistent Server Reporter Author: Bocaletto Luca 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 c

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published