zabbix uses 163 mailboxes to monitor alarms
1. The basic idea to realize the alarm
- Set sender
- Management—Alarm Media Type—Create Media Type
- Here we select the email type of email alarm
- Management—Alarm Media Type—Create Media Type
- Set recipient
- Click User—Alarm Media—Add Alarm Media
- Generally speaking, it is necessary to create a new user group, such as a development group, an operation and maintenance group, after creating a user group, create a user, set the alarm medium in the user settings
- Click User—Alarm Media—Add Alarm Media
- Start action
- Configure-Action-Enable Action
- The default action is effective for the administrator group, so you need to create a new action
- Configure-Action-Enable Action
- Set alarm content
- Set the alarm content for people to move
2. Use 163 mailbox to alarm
2.1. Define the sender
Management—Alarm Media Type—Create Media Type
- Set the name of the alarm media
- Type select email
- The smtp server address can be checked at 163, the default is smtp.163.com
- Port is 25
- smtp helo is the second-level domain name
- smtp email: fill in which email address to send emails
- Select None for the security link, if it is QQ alarm, check ssl/tls
- Authentication select user name and password
- User name fill in 163 email account
- Password fill in the client authorization code KTTHQZHWIICEIMOA
163 client authorization code
Added successfully
2.2. Define recipients
2.2.1. Create User Group
Click Manage—User Group—Add User Group
2.2.2. Set user group permissions
Click Permission—Select Group—Permission Setting Read
2.2.3. Successfully created user group
2.2.4. Create User
Click Manage-User-Create User
- Set alias name
- Set user information
- Fill in the user password as 123456
2.2.5. Set alarm media for users
Try 163 to send mail to QQ this time
- Type selection 163 alarm
- Recipient choose qq mailbox: [email protected]
- Other defaults are fine
User created successfully
2.3. Enable actions
Configuration—action—action can be created or modified according to the current action
Since the user we just created is a development 1 group, we need to add a development 1 group to the action
Click Action—Operation—Edit—Add—Update—Update
Set successfully
2.4. Add an action
2.4.1. Write alarm content
Configure-Action-Create Action
After creating a new action, you can disable the previous default action
报警内容
发生的
问题发生
当前状态: 未解决❎️
告警主机: {HOSTNAME1}
告警时间: {EVENT.DATE} {EVENT.TIME}
告警等级: {TRIGGER.SEVERITY}
告警信息: {TRIGGER.NAME}
告警项目: {TRIGGER.KEY1}
问题详情: {ITEM.NAME}:{ITEM.VALUE}
事件ID: {EVENT.ID}
恢复的
问题恢复
当前状态: 已处理✅
告警主机: {HOSTNAME1}
告警时间: {EVENT.DATE} {EVENT.TIME}
告警等级: {TRIGGER.SEVERITY}
告警信息: {TRIGGER.NAME}
告警项目: {TRIGGER.KEY1}
问题详情: {ITEM.NAME}:{ITEM.VALUE}
事件ID: {EVENT.ID}
2.4.1. Click action
- Set the name and tick enable
2.4.2. Click to operate
Operation is to alarm when a failure occurs
- Write alarm content and add alarm for that user group
- Click on the small update, click on the big update
2.4.3. Click to restore operation
Recovery operation is the operation after the problem is recovered
- Fill in the alarm content
- Operation details can be selected to notify all participants
3. Test whether an alarm email can occur
Set the maximum number of terminal open triggers for the 192.1.81.230 host
Trigger an alarm
The alarm has been triggered, check the email
Problem occurs
Problem recovery
4. Add monitoring items for host downtime detection and trigger alarm
4.1. Add ping monitoring items
For this kind of ping monitoring, it is generally necessary to monitor on zabbix-server, because when the server is down, the agent will not be detected. It can only be detected on zabbix-server
1.编写脚本
[root@zabbix-server ~]# vim /etc/zabbix/scripts/ping.sh
#!/bin/bash
ping -c3 192.168.81.230 &>/dev/null
echo $?
2.创建自定义监控项key
[root@zabbix-server ~]# vim /etc/zabbix/zabbix_agentd.d/user_monitor.conf
UserParameter=192_168_81_230_ping_host,sh /etc/zabbix/scripts/ping.sh
3.重启zabbix agent
[root@zabbix-server ~]# systemctl restart zabbix-agent
4.zabbix-server测试监控项
[root@zabbix-server ~]# zabbix_get -s 127.0.0.1 -k 192_168_81_230_ping_host
0
4.2. New monitoring items on the page
Configuration-host-monitoring item-new monitoring item
Fill in the key-value application set
- Name: 192.168.81.230-Host survival detection
- Key value: 192_168_81_230_ping_host
- Application set: host survival detection
4.3. Page creation trigger
Configuration—Host—Trigger—New Trigger
{Zabbix server:192_168_81_230_ping_host.last()}>1
Zabbix serve 监控主机
192_168_81_230_ping_host 监控项
last()}>1 最后一个值
Created successfully
Trigger has been bound to the item
4.4. Trigger an alarm
关掉服务器即可
[root@192_168_81_230 ~]# poweroff
5. Another host computer downtime monitoring alarm
5.1. Create a host down trigger
Trigger host down alarm by setting agent.ping monitoring items
Just create a new trigger
The expression is as follows: {Template OS Linux system:agent.ping.nodata(20m)}=1
The meaning of this expression is to trigger a downtime alarm if the result is always 1 within 20 minutes
Expression generation:
Set trigger information
5.2. Trigger an alarm and check email
关掉服务器即可
[root@192_168_81_230 ~]# poweroff
5.3. View alarm mail
Failure occurred
Recovery