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

Zabbix realizes real-time alarm through the integration of NetEase mailbox, WeCom and nails.

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Zabbix can send alarm information to the designated person in a variety of ways, such as email, Wechat, nails and so on. This blog mainly introduces these three alarm methods.

First, configure NetEase mailbox to realize alarm

This blog article uses NetEase mailbox to achieve alarm! Do the following:

Zabbix server needs to be configured as follows:

[root@zabbix ~] # yum-y install perl-Net-SSLeay perl-IO-Socket-SSL / / for installation depends on [root@zabbix ~] # wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz// to download the sendEmail package [root@zabbix ~] # tar zxf sendEmail-v1.56.tar.gz-C / usr/src [root@zabbix ~] # cd / usr/src/sendEmail-v1.56/ [root@zabbix sendEmail -v1.56] # cp-a sendEmail / usr/local/bin/ [root@zabbix sendEmail-v1.56] # chmod + x / usr/local/bin/sendEmail [root@zabbix ~] # cd / usr/local/zabbix/share/zabbix/alertscripts [root@zabbix alertscripts] # vim sendEmail.sh / / write a test script #! / bin/bashto=$1subject=$2body=$3/usr/local/bin/sendEmail-o tls=no-f zhen18732036806@163.com-t "$to"-s smtp.163.com-u "$subject"-o message-content-type=html-o message-charset=utf8-xu zhen18732036806@163.com-xp abcd1234-m "$body"

Various explanations of the contents of the email:

-f from@163.com: sender's mailbox

-t to@163.com: recipient mailbox

-s smtp.163.com: the smtp server of the sender's mailbox

-u "I am the subject of the message": the title of the message

-o message-content-type=html: the content of the message is in html format

-o message-charset=utf8: message content coding

-xu from@163.com: the user name of the sender's mailbox

-xp abcd1234: sender's email authorization code (the one I just generated)

-m "I am the content of the message": the specific content of the message

[root@zabbix alertscripts] # chmod + x sendEmail.sh [root@zabbix alertscripts] # chown zabbix.zabbix sendEmail.sh / / Grant permissions to the script [root@zabbix alertscripts] # sh sendEmail.sh zhen18732036806@163.com test 123Jan 30 16:40:04 zabbix sendEmail [2584]: Email was sent delivery fullyqualified / this message indicates that it was sent successfully

The e-mail received is as follows:

1) create an alarm medium

Select "manage → alarm media → to create alarm media" as follows:

The three parameters filled in the figure:

{ALERT.SENDTO} / / recipient address {ALERT.SUBJECT} / / topic {ALERT.MESSAGE} / / details 2) Associate the alarm medium to the user

Select "manage → users → Admin → alarm media" as follows:

After the creation is complete, do the following:

3) create an action

The added code is as follows:

Fault message host: {HOSTNAME} IP: {IPADDRESS} Monitoring item: {ITEM.NAME} trigger: {TRIGGER.NAME} key value: {ITEM.KEY}: {ITEM.VALUE} time: {DATE} {TIME}

4) configure triggers

5) Test email alarm [root@agent] # systemctl stop zabbix-agent//agent side shuts down the agent process

The e-mail received is as follows:

[root@agent ~] # systemctl start zabbix-agent//agent side starts the agent process

The e-mail received is as follows:

Realize the email alarm successfully!

Second, configure WeCom to realize the alarm

If you want to make WeCom report to the police, you need to register a WeCom by yourself. Because the process is too simple, it will be skipped here!

1) WeCom web page setup

After registration is complete, do the following:

You can add users to WeCom, but not here. Take a user as an example to view the details of the user:

Create an application, as shown below:

So far, the content of WeCom's registration and configuration has been introduced!

2) obtain Wechat alarm script

To send an alarm message to Wechat, you need to use a sending script, as follows:

[root@zabbix ~] # wget https://www.ixdba.net/zabbix/weixin_linux_amd64[root@zabbix ~] # mv weixin_linux_amd64 / usr/local/zabbix/share/zabbix/alertscripts/weixin// script path is very important [root@zabbix ~] # chmod 755 / usr/local/zabbix/share/zabbix/alertscripts/weixin [root@zabbix ~] # chown zabbix.zabbix / usr/local/zabbix/share/zabbix/alertscripts/weixin [root@zabbix ~] # vim / usr/local/zabbix/etc/zabbix_server.conf// confirm the following AlertScriptsPath=usr/local/zabbix/share/zabbix/alertscripts [root@zabbix ~] # cd / usr/local/zabbix/share/zabbix/alertscripts/ [root@zabbix alertscripts] #. / weixin-- corpid=ww35e57441212e7560-- corpsecret=t10UEVBtSuW-00CJMYFnz5xxBhTvf6XCz2vcUY3xS8M-- msg= "test"-- user=LvZhenJiang-- agentid=1000007 {"errcode": 0 "errmsg": "ok", "invaliduser": ""} / / Test the Wechat script This message indicates that the test was successful!

The meaning of each configuration item:

-- Enterprise ID in corpid=: Enterprise account

-- ID of Secret in self-built applications of corpsecret=:

-- the content of the message sent by msg=:

-- use=: specifies the user's name, which can be found when viewing the user's details

-- Agentid in agentid=: self-built applications

WeCom received the following message:

3) configuration of zabbix web page 1) create alarm medium

As shown in the figure:

The contents of the two variables are as follows (the variable in the figure is incorrect):

-- user= {ALERT.SENDTO}-- msg= {ALERT.MESSAGE} 2) Associate the alarm medium to the user

As shown in the figure:

3) create an action

As shown in the figure:

The code added in the figure is as follows:

Default title: server: {HOST.NAME} occurrence: {TRIGGER.NAME} Fault message content: alarm host: {HOST.NAME} alarm address: {HOST.IP} Monitoring Project: {ITEM.NAME} Monitoring value: {ITEM.LASTVALUE} alarm level: {TRIGGER.SEVERITY} current status: {TRIGGER.STATUS} alarm Information: {TRIGGER.NAME} alarm time: {EVENT.DATE} {EVENT.TIME} event ID: {EVENT.ID}

The warning message that occurs in the event of such a failure has been configured! Next, configure the information sent by the restore operation, as follows:

The code in the figure is as follows:

Default title: server: {HOST.NAME}: {TRIGGER.NAME} fault recovered message content: alarm host: {HOST.NAME} alarm address: {HOST.IP} Monitoring Project: {ITEM.NAME} Monitoring value: {ITEM.LASTVALUE} alarm level: {TRIGGER.SEVERITY} current status: {TRIGGER.STATUS} alarm Information: {TRIGGER.NAME} alarm time: {EVENT.DATE} {EVENT.TIME} event ID: {EVENT.ID}

So far, the configuration is complete! Careful friends may find that triggers are not created, because they have already been created during the mail test, and they share the same trigger!

4) Test Wechat alarm [root@agent ~] # systemctl stop zabbix-agent//agent to shut down the agent process

You can check whether the message was sent successfully in the following interface!

WeCom received the following message:

[root@agent ~] # systemctl start zabbix-agent//agent side starts the agent process

WeCom received the following message:

Wechat alarm successfully achieved!

Third, configure nails to realize alarm 1) about nailing robot alarm

Nails are similar to Wechat, but prefer to work. Through the group robot function of nails, the alarm information can be sent to the nail group through the robot.

The advanced extension function of nail group in swarm robot. Swarm robots can aggregate the information of third-party services into group chat to achieve automatic information synchronization.

Zabbix configuration nail alarm, compared with Wechat, much simpler, a few minutes to complete the configuration, the following details!

2) add nailing robot

The registration of nails is very simple, and there is not too much introduction here. After logging in to nails after registration, start a group chat and join the people who receive nail alarm information, as follows:

Note: keywords must be defined according to the actual situation, that is, what is contained in the message. It is recommended to use the way to define keywords!

The robot configuration is over!

3) get the nail alarm script

Because requests is used in the script, which is python's http client library, it is not installed as follows:

[root@zabbix ~] # yum-y install epel-release python-pip [root@zabbix ~] # pip install-- upgrade pip [root@zabbix ~] # pip install requests [root@zabbix ~] # vim dingding.py / / Custom script #! / usr/bin/python#-*-coding: utf-8-*-import requestsimport jsonimport sysimport osheaders = {'Content-Type':' application/json Charset=utf-8'} api_url = "https://oapi.dingtalk.com/robot/send?access_token=df27d0f8ed866576f0d213ededcf8bdc6a0a3d24bf1c904fcd58b14b606ec7c6"# changed to the URL of his robot Def msg (text): json_text= {"msgtype": "text", "text": {"content": text},} print requests.post (api_url,json.dumps (json_text)) Headers=headers) .contentif _ name__ = ='_ main__': text = sys.argv [1] msg (text) can also get [root@zabbix ~] # wget https://www.ixdba.net/zabbix/dingding.zip[root@zabbix ~] # unzip dingding.zip [root@zabbix ~] # mv dingding.py / usr/local/zabbix/share/zabbix/alertscripts/// to guarantee the path where the script is located [root@zabbix ~] # Cd / usr/local/zabbix/share/zabbix/alertscripts/ [root@zabbix alertscripts] # chmod 755 dingding.py [root@zabbix alertscripts] # chown zabbix.zabbix dingding.py / usr/local/zabbix/share/zabbix/alertscripts/weixin [root@zabbix ~] # vim / usr/local/zabbix/etc/zabbix_server.conf// confirm the following AlertScriptsPath=usr/local/zabbix/share/zabbix/alertscripts [root@zabbix alertscripts] #. / dingding.py monitoring alarm https://oapi.dingtalk. Com/robot/send?access_token=df27d0f8ed866576f0d213ededcf8bdc6a0a3d24bf1c904fcd58b14b606ec7c6 {"errcode": 0 "errmsg": "ok"}

The messages received by the nails are as follows:

Nail alarm script configuration completed!

4) configure nail alarm on zabbix web 1) add alarm medium

2) Associate the alarm medium to the user

'

3) configure actions

As shown in the figure:

As the code in the photo is consistent with the code in the Wechat test, it will not be copied here, it needs to be copied by itself!

4) Test nail alarm

'

[root@agent ~] # systemctl stop zabbix-agent//agent side shuts down the agent process

The messages received by the nails are as follows:

[root@agent ~] # systemctl start zabbix-agent//agent side opens the agent process

The messages received by the nails are as follows:

To achieve nail alarm completion!

-that's all for this blog. Thank you for reading-

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

Servers

Wechat

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

12
Report