shell sendEmail使用,以及Tomcat监控

#!/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= c o m p u t e r " T O M C A T " {computer}"机器TOMCAT进程意外关闭-" {date_time}

邮件内容

email_content= c o m p u t e r " " {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=" {tomcat}
fi

转自:http://www.cnblogs.com/duwenlei/

猜你喜欢

转载自blog.csdn.net/shaozhiliang/article/details/89515370
今日推荐