Zabbix email alert

Source: Internet
Author: User

Zabbix email alerts read a lot of documents, which is called an egg pain. It clearly did not send an email, so it was hard to confuse the audience. I was also fooled.

 

 

Operating system environment:

 

Centos 5.5 x84_64-bit

Zabbix version 2.2.3

Web server: lnmp

 

For environment deployment, refer to other reliable documents. We suggest official documents. Today we will talk about zabbix email alerts.

 

 

A project is a monitoring item. A trigger is equivalent to setting a threshold for a monitoring item. A trigger is triggered based on an expression to generate an alarm.

 

For versions earlier than centos6.0, you can use the MAIL command to call the SM-client of Sendmail to send emails. Therefore, if you Disable sendmail, you cannot send emails according to many online documents.

 

If you observe the MAIL command carefully, mailx is actually called to call a third-party non-local smpt service.

 

1. Uninstall (or stop) senmail to upgrade and install mailx

 

1) Stop Sendmail:

[[email protected] ~]# /etc/init.d/sendmail stop[[email protected] ~]# chkconfig sendmail off[[email protected] ~]#

 

2) install mailx:

[[email protected] workplace]# lsmailx-12.4  mailx-12.4.tar.bz2  zabbix-2.2.3  zabbix-2.2.3.tar.gz[[email protected] workplace]#[[email protected] workplace]# cd mailx-12.4[[email protected] mailx-12.4]# make &&  make install UCBINSTALL=/usr/bin/install   

 

If an error occurs, resolve it by yourself.

3) Configure mailx:

[[email protected] ~]# cd /usr/local/bin/[[email protected] bin]# cp mailx /bin/mailcp: overwrite `/bin/mail‘? y[[email protected] bin]#

 

4) configure a third-party SMTP Service:

You can register Sina mail to test and send it to Netease mail.

Mailx configuration file/etc/nail. RC ~

[[Email protected] ~] # Vi/etc/nail. rcset from = [email protected] # Set SMTP = SMTP: // smtp.sina.cn: 25 set SMTP-auth-user = [email protected] # Set SMTP-auth-Password = test001 # Your Password

 

 

5) test sending an email

 

Log on to 163 and check whether the email is received.

 

 

 

 

The configuration of the third-party email server is completed. The advantage of mailx is that it occupies a small amount of system resources, is fast, and the configuration is simple.

You can also use it to connect to the company's internal servers.

2. Configure the zabbix configuration file.

1) First, we configure the zabbix configuration file so that it supports scripts for the warning media.

Modify zabbix_server.conf

# Alertscriptspath =$ {datadir}/zabbix/alertscripts

Is

Alertscriptspath =/usr/loca/zabbix/alertscripts

 

 

2) create a directory for storing executable scripts of the alert media:

[root@localhost ~]# mkdir /usr/local/zabbix/alertscripts[root@localhost ~]# chmod 755 /usr/local/zabbix/alertscripts[root@localhost ~]# chown -R zabbix:zabbix /usr/local/zabbix/alertscripts

 

These steps are very important !!!

3) Compile the script:

[root@localhost ~]# cat /usr/local/zabbix/alertscripts/sendmail.sh#!/bin/bashecho "$3" | /bin/mail   -s "$2"  $1[root@localhost ~]#

 

Very simple:

Description: $3 is the email content.

$2 Mail title

$1 to whom

 

 

Iii. zabbix web page Configuration:

1) Alarm media Configuration:

 

 

 

Note the type and Script Name.

Select the Script Type and select the name of the script file created in the alertscripts directory.

2) User Configuration

 

 

 

 

Multiple recipients, separated by commas, and archived.

Note: select the name you have defined in the alert media for this type.

 

3) Action Configuration:

 

 

 

4) test:

Adjust the trigger threshold.

 

Email effect:

 

 

 

5) How can I view the successful email sending on the web page?

 

 

6) if the email is successfully sent to the Linux service provider, it means zabbix cannot be sent successfully. Where can I check it?

Some friends at 51cto may encounter this problem.

  1. First, check the permission, and grant the executable permission to the zabbix Script directory and the user, and use zabbix to check whether the user can send emails. If the permission is 755, the user can send emails without zabbix.
  2. Then, the audit that comes with zabbix Web

 

 

 

If the message fails to be sent, it is usually displayed in the Information bar, such as timeout.

 

In the Information bar, you can see:Timeout while executing a shell scriptDescriptionZabbixserverOfTimeoutThe setting is too low to send emails. The default setting is3Seconds, changed10-30Second should solve the problem!

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.