Giter Site home page Giter Site logo

mabusdogma / watchdog Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 61 KB

Python script for Linux. Checks Home Assistant supervised and internet connection, to restart server / router if necessary

Python 98.89% Shell 1.11%
crontab home-assistant restart-router restart-server router watchdog

watchdog's Introduction

IMG-20221012-WA0007

Watchdog / Restart weekly

Python scripts for Linux. They check Home Assistant supervised and internet connection, to restart server / router if necessary, and make a weekly restart of the server and router.

Scripts de python para Linux. Revisan la conexión de Home Assistant supervised y de internet, para reiniciar el router o el servidor si es necesario, y reinician semanalmente el servidor y el router.

Watchdog revisa periodicamente la conexión a internet y que se pueda acceder a Home Assistant. En caso necesario, intentará reiniciar (en este orden) el servicio de Home Assistant, el servidor, o la conexión a internet (es decir, reiniciar el router).

Weekly restart realiza un reinicio del router y, con un minuto de pausa, reinicia el servidor de Home asistant, para limpiar memoria.

Los archivo watchdog.py y weekly_restart.py se pueden programar con crontab para usarse automáticamente.

Los archivo watchdog.csv y weekly_restart.csv guardan toda la información creada cada vez que crontaba los activa.

En este ejemplo de crontab, watchdog se activa cada hora y weekly restart a las 5hrs del sábado:

XAUTHORITY=/home/<user>/.Xauthority
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DISPLAY=:0

0 * * * * watchdog.py >> watchdog.csv
* 5 * * 6 weekly_restart.py >> log_weekly_restart.csv

Si se colocan los csv como se indica aqui https://www.home-assistant.io/integrations/file/#sensor se tendrá la información actualizada en Home Assistant.

Debido a que los scripts utilizan pyautogui, es necesario incluir en el archivo crontab al menos Xauthority, PATH y DISPLAY (cambiar por usuario), si no se incluye esta información, no funcionará el reinicio del router.

Se deja un ejemplo de los archivos bash que se utilizarán para ejecutar las órdenes de crontab, también es necesario en ellos cambiar por usuario de Linux.

Se puede utizar el archivo clics.py para crear una "macro", y saber donde dar clics para entrar a la página del router y reiniciarlo (por si telnet está bloqueado en el router).

watchdog's People

Contributors

mabusdogma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.