This Python script checks internet connectivity by attempting to retrieve the external IP address. If the internet is not available, it triggers a system reboot.
Have you ever wanted an automated way to check internet connectivity and reboot your system if the internet is not available? This Python script does just that. It attempts to retrieve the external IP address and, if unsuccessful after multiple attempts, triggers a system reboot.
- Internet Connectivity Check: Uses an external service to check internet connectivity.
- Automatic Reboot: If the internet is not available, the script triggers a system reboot.
- Logging and Error Handling: Detailed logging of events and error handling for improved diagnostics.
- Python 3.x
- Internet connection for the script to check
-
Clone the repository:
git clone https://github.com/xhico/CheckInternet .git
-
Change into the project directory:
cd CheckInternet -
Run the script:
python3 CheckInternet.py
- Execute the script, and it will check internet connectivity.
- If the internet is not available, the script will trigger a system reboot.
The script logs events and errors for better diagnostics. You can find the log file at CheckInternet.log in the same directory as the script.
If an error occurs during script execution, an email notification with the error details will be sent using the sendEmail function.
If you'd like to contribute to this project, feel free to fork the repository and submit a pull request. For major changes, please open an issue first to discuss the proposed changes.
This project is licensed under the MIT License - see the LICENSE file for details.