Skip to content

scriptpy/service-monitor-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Service Status Monitor Script

A bash script that monitors critical services and automatically restarts them if they fail, ensuring high availability and preventing service downtime.

🚀 Features

  • Service Monitoring: Checks if critical services are running (SSH, Apache, MySQL, Nginx, Docker)
  • Automatic Restart: Attempts to restart failed services automatically
  • Detailed Logging: Records all activities with timestamps
  • Status Reporting: Clear status messages for each service
  • Configurable: Easy to add or remove services to monitor

📋 Monitored Services

  • SSH - Secure shell access
  • Apache2 - Web server
  • MySQL - Database server
  • Nginx - Web server/proxy
  • Docker - Container runtime

🛠️ Installation

  1. Clone this repository:
git clone https://github.com/scriptpy/service-monitor-script.git
cd service-monitor-script
  1. Make the script executable:
chmod +x service-monitor-complete.sh
  1. Run the script:
./service-monitor-complete.sh

📊 Usage

The script will:

  1. Check each service in the SERVICES array
  2. Report which services are running or failed
  3. Attempt to restart any failed services
  4. Log all activities to /var/log/service-monitor.log
  5. Provide clear status messages

⚙️ Configuration

You can modify these variables in the script:

  • SERVICES=("ssh" "apache2" "mysql" "nginx" "docker") - Services to monitor
  • LOG_FILE="/var/log/service-monitor.log" - Log file location

📝 Logging

All activities are logged with timestamps. Check the log file:

tail -f /var/log/service-monitor.log

🔧 Adding More Services

To monitor additional services, edit the SERVICES array:

SERVICES=("ssh" "apache2" "mysql" "nginx" "docker" "postgresql" "redis")

🤝 Contributing

This script is part of my DevOps learning journey. I'm building real solutions as I learn, and I welcome feedback and contributions!

📞 Contact & Customization

Need a personalized version? Contact me! I can customize this script for your specific needs, add web dashboards, or multi-server monitoring.

⚠️ Disclaimer

This README was written with AI assistance as part of my learning journey. The script itself was built through hands-on learning and real-world problem solving.

📄 License

This project is open source and available under the MIT License.

💖 Support

If this script helped you, consider:

  • ⭐ Starring this repository
  • 🐛 Reporting issues
  • 💡 Suggesting improvements
  • Buy me a coffee (Crypto donations welcome!)

Crypto Addresses:

Bitcoin: bc1q60fgpcmem6t9j8u0qyu9yccccyf0zh7u8mqfsd

Ethereum: 0xC98765ea54BE48a9a0dFA239890b92CaA30E2464

BNB: 0xC98765ea54BE48a9a0dFA239890b92CaA30E2464

Part of my DevOps Learning Journey - Building real solutions while learning. Follow my progress and join the journey! 🚀

About

Service Status Monitor Script - Part of my DevOps learning journey

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages