#!/bin/sh
configurations
computer 设备名称
target 监控目标
watcher 跟踪者(邮箱)
computer=“ehetong”
target=“home/ehetong/apache-tomcat-7.0.33”
date_time=$(date +%c)
收件人
email_addressee="[email protected] [email protected]"
发件人
email_sender="[email protected]"
发件人用户名
email_user="[email protected]"
发件人密码
email_password=“XXXXXXXXXXXXXXXXXXXXXXXXXXXX”
smtp服务器地址
email_smtp=“smtp.exmail.qq.com”
邮件标题
email_title= {date_time}
邮件内容
email_content= {target}"\n在"${date_time}",Tomcat进程意外关闭\nshell脚本搜索不到Tomcat进程PID,请及时处理。"
#tomcat=$(ps -ef|grep $$target | grep -v grep | awk ‘{print $2}’)
tomcat=ps -ef|grep $target | grep -v 'grep\|tail' | awk '{print $2}'
#file_path=""
附件
file_path=""
-a ${file_path}
if test -z ${tomcat}
then
echo $(date +%F" “%T)”–info–:准备发送邮件"
/usr/local/bin/sendEmail -f ${email_sender} -t ${email_addressee} -s ${email_smtp} -u ${email_title} -xu ${email_user} -xp ${email_password} -m ${email_content} -o message-charset=utf-8
echo $(date +%F" “%T)”–info–:发送邮件成功"
else
echo
{tomcat}
fi