Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if Nagios+mutt+msmtp can't send an email?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what to do about how Nagios+mutt+msmtp can not send email. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Recently, CentOS 6.3x86x64 + Mutt 1.5.2. + Msmtp 1.4.27 + Nagios 3.2 to build a monitoring platform, encountered a depressing problem, that is, Mutt+Msmtp can not send email alarm in commands.cfg.

Problem description:

You can send mail by using the mutt command alone

For example: echo "This is a new mail." | mutt-s "new message" mymail@163.com

The command is defined in the configuration file (commands.cfg). When the host and service are pawned, you cannot send mail. Check / usr/local/msmtp/etc/msmtp.log, there are no send mail logs. Check the Nagios log and find that the command has been executed, but the mail is not received. The Nagios log code is as follows

Feb 6 05:59:35 localhost nagios: SERVICE NOTIFICATION: Nagiosash mystical QL employees check slaveworlds CRITICALTION notifyMurray Smithsonian ERRORPLAR rides the Slave Mysql Server Was downloads Feb 6 05:59:36 localhost nagios: SERVICE NOTIFICATION: Nagiosadminism mystical qldom serverten checkpoint slaveability CRITICALTH notifyMurray Byby Murray smsma Erro Roundup display the Slave Mysql Server Was Downboat!

Check the configuration file through the command / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg, and there is no error report. Check the commands.cfg configuration file separately, and no errors are detected. The commands.cfg configuration file code is as follows

Define command {command_name notify-by-sms command_line / usr/bin/printf "% b"* Nagios-service *\ 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 Service-by-email command_line / usr/bin/printf "% b * Nagios-host *\ 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$}

Contacts.cfg configuration file is also correct, this problem is very troublesome ah, there is no error, that is, the alarm email cannot be sent in Nagios. Later, through querying information, I know that Mutt will generate a sent file under the home directory, and the records you send will be written to this file, while I am logging in with root users, and nagios calls mutt background execution, but there is no permission to write data in the sent file, so this problem occurs.

Well, if the root cause of the problem is found, it will be much easier to solve it. Write the / root directory and / root/sent directly to nagios, and the problem is solved.

This is the end of the article on "what if Nagios+mutt+msmtp cannot send email". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report