How to implement email alert in zabbix

How to implement email alert in zabbix

Implemented according to the online tutorial. zabbix3.4, using scripts and sendEmail.

1. Download and decompress sendEmail to /usr/local/bin and modify the permissions.

Download URL:

SendEmail - Send email with this free command line email client http://caspian.dotconf.net/menu/Software/SendEmail/

Modify permissions:

chown zabbix:zabbix /usr/local/bin/sendEmail

2. Conduct an email test.

/usr/local/bin/sendEmail -f [email protected] (sending email) -s smtp.163.com -u "Email title" -m "Email content" -o message-content-type=html -o message-charset=utf8 -xu [email protected] (sending email account) -xp "NetEase email authorization code" -t "target email"

3. After the email test is passed, enter the /usr/local/zabbix/share/zabbix/alertscripts/ directory, create a new mail.sh file, and grant permissions;

4.mail.sh content:

#!/bin/bash
to=$1
subject=$2
body=$3
/usr/local/bin/sendEmail -o tls=auto -f [email protected] -t "$to" -s smtp.163.com -u "$subject" -o message-content-type=html -o message-charset=utf8 -xu [email protected] -xp "Mailbox Client Authorization Code" -m "$body"

5. Test error

[root@centos7 alertscripts]# ./mail.sh "Target mailbox" test_topic hello_world!
***********************************************************************
 Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
 is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
 possibly with SSL_ca_file|SSL_ca_path for verification.
 If you really don't want to verify the certificate and keep the
 connection open to Man-In-The-Middle attacks please set
 SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
***********************************************************************
 at /usr/local/bin/sendEmail line 1906.
invalid SSL_version specified at /usr/share/perl5/vendor_perl/IO/Socket/SSL.pm line 444.

In sendemail, line 1906, from

if (! IO::Socket::SSL->start_SSL($SERVER, SSL_version => 'SSLv3 TLSv1')) {

Modified to

if (! IO::Socket::SSL->start_SSL($SERVER)) {

Tested again, success.

[root@centos7 alertscripts]# ./mail.sh "Target mailbox" test_topic hello_world!
***********************************************************************
 Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
 is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
 possibly with SSL_ca_file|SSL_ca_path for verification.
 If you really don't want to verify the certificate and keep the
 connection open to Man-In-The-Middle attacks please set
 SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
***********************************************************************
 at /usr/local/bin/sendEmail line 1906.
Aug 08 15:42:42 wanbu sendEmail[25763]: Email was sent successfully!

6.zabbix-web configuration

In zabbix3.4, there are 3 places that need to be configured: actions, media type, and users. Actions are responsible for judging and sending emails; media type is responsible for selecting scripts and passing parameters; users are responsible for clarifying to whom the alarm information is sent and other information.

Just follow the configuration instructions on the official website. I'm too lazy to write this part. The only thing to note is that the media type needs to add three parameters, namely {ALERT.SENDTO}, {ALERT.SUBJECT}, {ALERT.MESAGE}, which correspond to to, subject and body in mail.sh respectively.

7. Finally, click "Reports"-"action log" to check whether the email was sent successfully and the reason for failure.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Use of Zabbix Api in Linux shell environment
  • Python calls zabbix api method example
  • Tutorial diagram of installing zabbix2.4 under centos6.5
  • Super detailed steps to install zabbix3.0 on centos7
  • Python implements Zabbix to send SMS script
  • Python gets the host through the zabbix api
  • How to obtain information from ZabbixAPI and implement Zabbix-API monitoring in Python
  • Centos7.4 zabbix3.4.7 source code installation method and steps
  • Installation and deployment of Zabbix based on Docker
  • Zabbix system port monitoring status

<<:  Vue implements a draggable tree structure diagram

>>:  Detailed tutorial on installing MySQL 5.7.19 decompressed version on Windows Server 2016

Recommend

Meta tags in simple terms

The META tag, commonly referred to as the tag, is...

Nodejs converts JSON string into JSON object error solution

How to convert a JSON string into a JSON object? ...

Jenkins packaging microservices to build Docker images and run them

Table of contents Environment Preparation start 1...

Vue realizes the function of uploading photos on PC

This article example shares the specific code of ...

How webpack implements static resource caching

Table of contents introduction Distinguish betwee...

How to replace all tags in html text

(?i) means do not match case. Replace all uppercas...

The difference between ${param} and #{param} in MySQL

The parameter passed by ${param} will be treated ...

An article teaches you how to use Vue's watch listener

Table of contents Listener watch Format Set up th...

How to use CSS custom variables in Vue

Table of contents The CSS custom variable functio...

Solve the margin: top collapse problem in CCS

The HTML structure is as follows: The CCS structu...

Detailed example of reading speed of js objects

1. Accessing literals and local variables is the ...

A brief discussion on docker-compose network settings

Networks usage tutorial Official website docker-c...