A robust, lightweight Linux shell script that automatically monitors Internet connectivity and manages system reboots for unattended servers. Perfect for headless Raspberry Pi, remote servers, and IoT devices.
-
🔍 Intelligent Network Monitoring
- Real-time ICMP ping checks to verify internet connectivity
- Configurable target hosts (default: Google DNS
8.8.8.8) - Smart failure detection with customizable retry attempts
-
🔄 Automated Recovery System
- Self-healing through automatic system reboots
- Configurable failure thresholds
- Zero human intervention required
-
📊 Comprehensive Logging
- Detailed timestamp-based logging
- Easy-to-analyze log format
- Built-in log rotation support
# Clone the repository
git clone https://github.com/proars/inetmonit.git
# Make the script executable
chmod +x inetmonit.sh
# Move to system directory (optional)
sudo mv inetmonit.sh /usr/local/bin/-
Customize Settings (Optional)
# Open the script in your favorite editor nano inetmonit.shAdjust these variables according to your needs:
TARGET="8.8.8.8" # Target host for ping tests RETRIES=3 # Number of failed attempts before reboot LOGFILE="/var/log/inetmonit.log" # Log file location
-
Schedule Monitoring
# Open crontab editor crontab -eAdd one of these lines:
# Check every 5 minutes */5 * * * * /usr/local/bin/inetmonit.sh # OR check every 30 minutes */30 * * * * /usr/local/bin/inetmonit.sh
-
Set Up Log Rotation Create a new logrotate configuration:
# Run the script manually
sudo /usr/local/bin/inetmonit.sh
# Monitor the logs
tail -f /var/log/inetmonit.log
# Check last 20 log entries
tail -n 20 /var/log/inetmonit.log- Operating System: Linux (Compatible with Debian, Ubuntu, Raspberry Pi OS, and most POSIX systems)
- Required Tools:
pingutility (pre-installed on most systems)cronservicelogrotate(recommended for log management)
- Permissions: Root access for system reboot functionality
We welcome contributions to make InetMonit even better! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you find InetMonit useful, please consider:
- Giving it a star on GitHub
- Sharing it with others who might benefit
- Contributing to its improvement
- Create an issue for bug reports or feature requests
- Star the repository to show your support
- Fork the project to contribute improvements