Nagios monitoring using SendMail to send mail alerts using a third-party SMTP service

Source: Internet
Author: User

Use the SendMail service that comes with the CentOS system as a client to send mail alerts using a third-party SMTP service.

This feature is implemented on the basis of the normal installation and operation of the Nagios service, so the basic Nagios operating environment should be installed first, this can refer to my related blog post.


1. Software Inspection and Installation

#rpm-Q SendMail

Does not exist how to install

#yum-y Install SendMail


2. Stop SendMail Service

There is no need for sendmail to run as a mail server, so close the SendMail service.

#service SendMail Stop


3. Configuring the SendMail Service

Configure mailbox authentication information for sending messages

Vi/etc/mail.rc

---Add the following content---

Set [email protected]

Set smtp=smtp.xxx.com

Set Smtp-auth-user=mailname

Set SMTP-AUTH-PASSWORD=YOURPASSWD

Set Smtp-auth=login


4. Test the Send mail feature

Format: echo "Mail Content" | Mail-s "Mail Header" Destination email address

echo "Hello word" | Mail-s "Mail title" [Email protected]


5. Configure Nagios Mail Send command

Modifying the nagios command configuration file

#vim nagios/etc/object/command.cfg

#notify definition of the-host-by-email command

Define Command{

#命令名称, which defines a command that sends a message when a host exception is defined.

Command_name Notify-host-by-email

#命令具体的执行方式.

command_line/usr/bin/printf "%b" "* * * * Nagios *****\n\nnotification Type: $NOTIFICATIONTYPE $\nhost: $HOSTNAME $\nstat E: $HOSTSTATE $\naddress: $HOSTADDRESS $\ninfo: $HOSTOUTPUT $\n\ndate/time: $LONGDATETIME $\n "| /bin/mail -S "* * $NOTIFICATIONTYPE $ Host Alert: $HOSTNAME $ is $HOSTSTATE $ * *" $CONTACTEMAIL $

}


#notify definition of the-service-by-email command

Define Command{

#命令名称, which defines a command to send a message when a service exception is defined

Command_name Notify-service-by-email

command_line/usr/bin/printf "%b" "* * * * Nagios *****\n\nnotification Type: $NOTIFICATIONTYPE $\n\nservice: $SERVICEDES C$\nhost: $HOSTALIAS $\naddress: $HOSTADDRESS $\nstate: $SERVICESTATE $\n\ndate/time: $LONGDATETIME $\n\nadditional Info:\n\n$serviceoutput$\n "| /bin/mail -S "* * $NOTIFICATIONTYPE $ Service Alert: $HOSTALIAS $/$SERVICEDESC $ is $SERVICESTATE $ * *" $ contactemail$

}

Note: The command is on one line, where the layout problem is divided into multiple lines.


It then modifies the alarm mechanism of the hosts and services defined in Nagios, enabling Nagios to use automatic mail alerting.



Acknowledgement: I refer to a number of articles after summing up, in this thank you network share!

This article is from the "4699096" blog, please be sure to keep this source http://4709096.blog.51cto.com/4699096/1703980

Nagios monitoring using SendMail to send mail alerts using a third-party SMTP service

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.