Nagios使用mutt发用报警邮件-创新互联
Nagios使用mutt发用报警邮件
成都创新互联公司是一家专注于网站设计制作、网站制作与策划设计,任丘网站建设哪家好?成都创新互联公司做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:任丘等地区。任丘做网站价格咨询:18980820575一.开始配置
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
二. 安装软件包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
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
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
名称栏目:Nagios使用mutt发用报警邮件-创新互联
文章路径:http://ybzwz.com/article/jpigg.html