I am looking for a shell script which can ssh to multiple servers and grep the required process and send an email alert if it is not running .
I have 10 servers to monitor from the host and each server is having 8 applications running. Is that possible to setup the alert. I am on CEntos 7
Appreciate the earliest response !!
Thanks in advance !!
#!/bin/bash
for host in $(cat /tmp/host.txt)
do
echo -n > /tmp/$host.txt
for process in $(cat /tmp/process.txt)
do
ssh $host "ps ax | grep $process | grep -v grep" > /tmp/$host.txt
if [[ -s /tmp/$host.txt ]] ; then
echo $process is running in $host
else
echo $process is not running in $host
sendEmail -f -t -u "Subject" -l /var/log/sendEmail -o message-content-type=auto -m "" -s -xu -xp
fi ;
done
done
192.168.10.13
192.168.10.19
java
snmp
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.