Monitor the program of this machine and send alarm emails abnormally
#!/bin/bash
# Native IP
HOST=‘59.110.69.217’
# Mail service address
URL=‘http://101.201.150.205:9527’
# Mail receiving end; separated by spaces, not commas
MAILS=(‘[email protected]****.net‘ ‘[email protected]***.net’ ‘[email protected]***.net’)
# Monitoring process
PROCESS=(‘callout1‘ ‘callout2‘ ‘callout4’)
# Splicing receiver
data=‘‘
for mail in ${MAILS[@]};
do
data="$data""receivers=$mail&"
done
# implement
for proc in ${PROCESS[@]};
do
echo ‘>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>‘
result=`ps -ef | grep $proc | grep -v ‘grep‘`
echo -e "grep $proc process result
$result"
if ["$result" = ‘‘ ]; then
echo -e "$proc process is dead"
wget --post-data="$data""content=HOST:$HOST PRODESS:$proc MESSAGE:monitor process is not alive&title=process monitor error!" $URL
echo -e "$proc send email
"
else
echo -e "$proc process is alive
"
fi
done
#!/bin/bash
# Native IP
HOST=‘59.110.69.217’
# Mail service address
URL=‘http://101.201.150.205:9527’
# Mail receiving end; separated by spaces, not commas
MAILS=(‘[email protected]****.net‘ ‘[email protected]***.net’ ‘[email protected]***.net’)
# Monitoring process
PROCESS=(‘callout1‘ ‘callout2‘ ‘callout4’)
# Splicing receiver
data=‘‘
for mail in ${MAILS[@]};
do
data="$data""receivers=$mail&"
done
# implement
for proc in ${PROCESS[@]};
do
echo ‘>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>‘
result=`ps -ef | grep $proc | grep -v ‘grep‘`
echo -e "grep $proc process result
$result"
if ["$result" = ‘‘ ]; then
echo -e "$proc process is dead"
wget --post-data="$data""content=HOST:$HOST PRODESS:$proc MESSAGE:monitor process is not alive&title=process monitor error!" $URL
echo -e "$proc send email
"
else
echo -e "$proc process is alive
"
fi
done
