Service monitoring alarm

#!/bin/sh
#auto service monitor
#by zkg 2019-07-15

echo -e "\033[32m \033[1m"
EMAIL=email.txt
DATE=date
M_IPADDR=ifconfig eth0|grep "Bcast"|awk '{print $2}'|awk -F: '{print $2}'br/>[email protected]
cat << EOF

---------------- -------------- alarm monitoring service

The EOF
echo -e "\ 033 [32M \ 033 [0m"
SLEEP 2
IF [the -Z $. 1]; the then
echo -e "\ 033 [32musage: {0 Nginx SH $ | MySQL | list.txt} \ 033 [0m"
echo
Exit
Fi
IF [-a. 1 -f $ "$. 1" == list.txt]; the then
for in I cat list.txt
do
COUNT = ps -ef|grep $i|grep -v service|grep -v grep|wc -l
IF [ "$ COUNT" -eq 0]; the then
CAT> $ << the EOF for EMAIL
* ** the SERVICE the MONITOR ***
notification types: alarm
services: $ i
host: $ M_IPADDR
status: alarm
date / time: $ dATE
additional information:
CRITICAL - the sERVICE the MONITOR: $ i IS the NOT RUN, PLEASE CHECK ..
EOF
dos2unix $ EMAIL >> / dev / null 2>. 1 &
echo -e "\ 033 [32mthe the IS the NOT I $ the RUN, the CHECK PLEASE .. \ 033 [0m"
mail -s "$ I $ M_IPADDR warning"$MYEMAIL <$EMAIL >>/dev/null 2>&1
else
echo "the $i is server 200 ok"
fi
done

the else
COUNT = ps -ef|grep $1|grep -v service|grep -v grep|wc -l
IF [ "$ COUNT" -eq 0]; the then
CAT> $ << the EOF for EMAIL
* the SERVICE the MONITOR *****
notification types: alarm
services: $ 1
host: $ M_IPADDR
Status: alarm
Date / Time: $ DATE
additional information:
CRITICAL - the SERVICE the MONITOR: $ 1 IS the NOT RUN, PLEASE CHECK ..
EOF
dos2unix $ EMAIL >> / dev / null 2> & 1
echo -e "\ 033 [32mthe $ 1 IS the NOT RUN, PLEASE CHECK .. \ 033 [ 0m "
mail -s" $ $ M_IPADDR warning. 1 "myemail $ <$ for EMAIL >> / dev / null 2> &. 1
the else
echo" The $ 200 is OK. 1 IS Server "
Fi
Fi

Guess you like

Origin blog.51cto.com/1009516/2425466