Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!bin/bash
- # Recogemos en un array lo argumentos que se pasan al script
- services_check=($@)
- mail=educacionit@localhost
- func_sendMail () {
- # codigo para enviar el mensaje
- # de la variable $err_msg al destinario $mail
- echo "$1" | mail -s "Service checker" $2
- }
- # Aplicar el comando 'systemctl is-active' por cada elemento que contiene el array.
- for service in "${services_check[@]}"; do
- if systemctl is-active $service > /dev/null;then
- echo "$service running"
- else
- err_msg="$(date) - $service is not running"
- echo $err_msg | tee -a /var/log/services_checker.log
- func_sendMail "$err_msg" "$mail"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement