Çok gelişmiş monitoring sistemleri olmasına rağmen bazen ihtiyaç olduğunda kullanabileceğiniz,linux ortamlarda çalıştırdığınız servisleri check etmek için basit bir Servis Durum Kontrol Scripti;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#!/bin/bash ###edit the following service=service_name email=user@domain.com ###stop editing host=`hostname -f` if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 )) then echo "$service is running" else /etc/init.d/$service start if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 )) then subject="$service at $host has been started" echo "$service at $host wasn't running and has been started" | mail -s "$subject" $email else subject="$service at $host is not running" echo "$service at $host is stopped and cannot be started!!!" | mail -s "$subject" $email fi fi |
https://github.com/omeroner/sysadmin/blob/master/scripts/bash/service_check.sh
So, what do you think ?