Nagios使用mutt发用报警邮件

发布时间:2020-08-02 11:16:57 作者:yujianglei
来源:网络 阅读:561

Nagios使用mutt发用报警邮件

 

.开始配置

mkdir -p /usr/local/msmtp/etc

vi  /root/.msmtprc

host smtp.163.com

tls off

auth plain

from 15614119390@163.com

user 15614119390

password 123456

 

vi /root/.muttrc

set sendmail="/usr/local/msmtp/bin/msmtp"

set use_from=yes

set from=15614119390@163.com

set envelope_from=yes

 

vi /usr/local/msmtp/etc/msmtprc

defaults

account 15614119390

host smtp.163.com

from 15614119390@163.com

auth login

port 25

tls off

user  15614119390@163.com

password 123456

account default: 15614119390

logfile /usr/local/msmtp/log/msmtp.log

 

 

echo 'setsendmail="/usr/local/msmtp/bin/msmtp"' >>/etc/Muttrc

echo "set use_from=yes" >>/etc/Muttrc

echo 'set realname="15614119390@163.com"'>>/etc/Muttrc

echo 'set editor="vim"' >>/etc/Muttrc

Nagios使用mutt发用报警邮件

 

 

. 安装软件msmtp

https://sourceforge.net/projects/msmtp/

tar   xf  msmtp-1.6.3.tar.gz

cd  msmtp-1.6.3

./configure --prefix=/usr/local/msmtp

make 

make  install

ln -s /usr/local/msmtp/bin/msmtp /usr/bin

 

 

.安装软件包Mutt

http://www.linuxfromscratch.org/blfs/view/7.8/basicnet/mutt.html

wget  ftp://ftp.mutt.org/pub/mutt/mutt-1.5.24.tar.gz

tar  xf   mutt-1.5.24.tar.gz

cd mutt-1.5.24

./configure --prefix=/usr/local/mutt

make

make  install

ln -s /usr/local/mutt/bin/mutt  /usr/bin

 

 

.发送测试邮件

echo  "test"  | mutt -s "test"  1075841124@qq.com

 

Nagios使用mutt发用报警邮件

 

 

 

.配置Nagios

vi   command.cfg

define command{

      command_name   notify-host-by-email

      command_line    /usr/bin/printf"%b" "***** Nagios *****\n\nNotification Type:$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo:$HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mutt -s "**$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"$CONTACTEMAIL$

       }

 

define command{

      command_name   notify-service-by-email

      command_line    /usr/bin/printf"%b" "***** Nagios *****\n\nNotification Type:$NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState:$SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n"| /usr/bin/mutt -s "** $NOTIFICATIONTYPE$ Service Alert:$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

       }

 

.重启Nagios

service nagios  stop

serivce nagios  start

 

 


推荐阅读:
  1. nagios邮件报警配置
  2. Nagios之邮件报警

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

nagios mutt

上一篇:掌握分布式事务锁,这个大厂实战订单锁你一定要会

下一篇:laravel5.4 打印sql语句

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》