#!/bin/sh
configurations
computer 设备名称
target 监控目标
watcher 跟踪者(邮箱)
computer=“ehetong”
target=“home/ehetong/apache-tomcat-7.0.33”
date_time=$(date +%c)
收件人
email_addressee="952589031@qq.com 823633682@qq.com"
发件人
email_sender="do-not-reply@itrusign.cn"
发件人用户名
email_user="do-not-reply@itrusign.cn"
发件人密码
email_password=“XXXXXXXXXXXXXXXXXXXXXXXXXXXX”
smtp服务器地址
email_smtp=“smtp.exmail.qq.com”
邮件标题
email_title= c o m p u t e r " 机 器 T O M C A T 进 程 意 外 关 闭 − " {computer}"机器TOMCAT进程意外关闭-" computer"机器TOMCAT进程意外关闭−"{date_time}
邮件内容
email_content= c o m p u t e r " − − − " {computer}"---" computer"−−−"{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
(
d
a
t
e
+
(date +%F" "%T)"--info--:tomcat进程存在,pid="
(date+{tomcat}
fi