Zabbix templates, monitoring items and triggers

The process of adding a monitoring host to zabbix

Customized monitoring item implementation process

  • The controlled end adds monitoring items /etc/zabbix_agent2.d/xxx.conf UserParameter=key , command; restart
  • Server-side test zabbix_get -s host -k key
  • web creation template
  • web Add monitoring items to the template
  • The web template is associated with the host
  • Observe data and graphs

Create the name of the monitoring item.
Get the command of the monitoring item
. Web interface. Create a template.
Web interface. Create a customized monitoring item. Add it to the template.
Web interface. Associate the template to the monitored host.

Monitoring items added later will be added to the template.

Zabbix is ​​an open source network monitoring solution that allows you to monitor various network devices and applications. Zabbix provides the function of custom monitoring items, which you can use to monitor specific indicators or data you are interested in.

To create a custom monitoring item, follow the steps below:

  1. Log in to Zabbix's web interface.
  2. Go to the "Configuration" menu and select "Hosts".
  3. Select the host to which you want to add custom monitoring items.
  4. On the host page, choose the Items tab.
  5. Click the "Create Monitoring Item" button.
  6. On the monitoring item configuration page, fill in the monitoring item's name, key value, and other relevant information.
  7. According to your needs, select the appropriate monitoring item type, such as numeric type, character type, etc.
  8. Configure options such as triggers, graphs, and alerts to take action when certain conditions are met.
  9. Click the "Add" button to save the monitoring item configuration.

After completing the above steps, your custom monitoring items will start to be monitored in Zabbix and provide corresponding data and alarm functions. Note that creating custom items requires some technical knowledge and understanding of basic Zabbix concepts. If you need more detailed guidance, please refer to Zabbix's official documentation or seek professional support.

Create monitoring items on the monitored host

root@ubuntu20:/etc/zabbix/zabbix_agent2.d# vim user_login_count.conf

UserParameter=user.login.count,uptime |awk -F " " ‘{print $4}’

Test monitoring items, there are 4 users connected to
root@ubuntu20:/etc/zabbix/zabbix_agent2.d# zabbix_agent2 -t user.login.count
user.login.count [s|4]
Restart the service
systemctl restart zabbix-agent2.service

Monitoring terminal test
root@ubuntu20:~# zabbix_get -s 192.168.1.151 -k user.login.count
4

Add template
insert image description here

Create new monitoring item
insert image description here

Fill in the key value and test
insert image description here

Host Parallel Template》View data
insert image description here
View graphics
insert image description here

Value mapping of monitoring items

In order to display the received value in a more "humanized" way, you can bind the relationship between the value and the string through value mapping. Example: http
response
code
'200' → 'OK'
'403' → 'Forbidden'
'404' → 'Not Found''

insert image description here

insert image description here

Update the monitoring item in the template, and add the value mapping created above to view the value
insert image description here

In Zabbix 6.0, value mapping is integrated in templates and triggers. You can find the value mapping by following these steps:

  1. Enter the Zabbix web interface.
  2. Navigate to Templates or Triggers under the Configuration tab.
  3. In the list of templates or triggers, select the template or trigger that interests you.
  4. Go to the detail page of a template or trigger.
  5. In the details page you can find the Value Mapping tab or section.
  6. Click Value Maps and you will see a list of value maps associated with that template or trigger.

Note that the specific interface layout may vary between Zabbix versions. If the value mapping cannot be found, please refer to Zabbix's documentation or seek further support.

Implement parameters for custom monitoring items

root@ubuntu20:/etc/zabbix/zabbix_agent2.d# cat tcp.state.conf 
UserParameter=tcp.state.[*],netstat -ant| grep -c $1

root@ubuntu20:/etc/zabbix/zabbix_agent2.d# zabbix_agent2  -t tcp.state.[LISTEN]
tcp.state.[LISTEN]                            [s|24]

root@ubuntu20:/etc/zabbix/zabbix_agent2.d# zabbix_agent2  -t tcp.state.[TIME_WAIT]
tcp.state.[TIME_WAIT]                         [s|94]


服务端测试
root@ubuntu20:~# zabbix_get  -s    192.168.1.151  -k   tcp.state.[LISTEN]
24


insert image description here

Add monitoring items
insert image description here

View data
insert image description here

Add other monitoring items
insert image description here

Value of type “string” is not suitable for value type “Numeric (unsigned)” appears in zabbix6.0
. Value “min,” the
information type in the template is changed to text
insert image description here

Add memory monitoring items

root@server01:/etc/zabbix/zabbix_agent2.d# cat mem.conf 
UserParameter=mem_use_percent,free | awk 'NR==2{print $3/$2*100}'
UserParameter=mem_unuse_percent,free | awk 'NR==2{print 100-($3/$2*100)}'


服务端测试
root@server02:~# zabbix_get  -s  172.29.21.67 -k mem_use_percent
35.3378

Add monitoring items to the web page, and after the test passes
Add memory monitoring items

trigger

Template-》Trigger》Create trigger
insert image description here

Add an expression, and an alarm will be triggered when the user logs in to 5.
insert image description here
View the effect
insert image description here

Add graphics to templates

Template - "Graphics" to create graphics
insert image description here

Check
insert image description here

insert image description here

Create an aggregate graph

Method 1: Add it in the template, and then check after adding it - check in the host,
Method 2: Monitor - Add aggregation graph, add

insert image description here

insert image description here

insert image description here

Click Select, select the host group owner, select 151 and 220 machines respectively
insert image description here
Select, select the tcp connection status and memory usage respectively
insert image description here

Adjust the width and height to see the effect

insert image description here

Use multiple aggregated graphics to realize slideshow function (carousel graphics)

3.6.5.1 Create Slide

insert image description here
insert image description here

It can be observed that each aggregated graph will be rotated every 3s
insert image description here

zabbix user management

insert image description here

Configured as administrator privileges
Administrator, manage specific groups
insert image description here

Create a group owner

insert image description here

Configure mailbox

Generate authorization code
insert image description here

Configure media, you can create a new one

insert image description here

Configure the recipient
Find a user admin and add a mailbox
insert image description here

Configure actions.
Add an action,
add conditions
insert image description here
, configure the alarm operation, send it to the group, and restore it to the admin user

insert image description here
Custom message content



故障:{
    
    TRIGGER.STATUS} 服务器:{
    
    HOSTNAME1} 事件:{
    
    TRIGGER.NAME}故障!

告警主机:{
    
    HOSTNAME1} 
告警时间:{
    
    EVENT.DATE} {
    
    EVENT.TIME} 
告警等级:{
    
    TRIGGER.SEVERITY} 
告警信息:{
    
    TRIGGER.NAME} 
告警项目:{
    
    TRIGGER.KEY1} 
问题详情:{
    
    ITEM.NAME}:{
    
    ITEM.VALUE} 
当前状态:{
    
    TRIGGER.STATUS}:{
    
    ITEM.VALUE1}
事件ID:{
    
    EVENT.ID}

insert image description here
Step duration: How long the alarm will be sent
Step:
When the step is set to 0, it means that the alarm will be sent continuously. It is generally recommended that 1 to 3 means that it will be executed three times.
The step duration indicates the interval between execution of subsequent steps if there are any. The default value is 0, which means that the subsequent
steps minimum value cannot be less than 60s and the maximum cannot exceed 604800s. It can be set from 1 to 5m ( minutes) is more appropriate

Add which users the recovery operation is sent to, and configure custom message content

Stop the nginx service and test
insert image description here

insert image description here
Hierarchical alarm
1-2 Send emails to admin for the 1st-2nd time, every 1 minute
3-4 Send emails to admin2 for the 3rd-4th time

Script to send email

1. Deployment script
root@ubuntu20:/usr/lib/zabbix/alertscripts# ls
send_email

2. Create a medium

insert image description here

3. User adds media
insert image description here

4. Create an action
Clone the previous action and modify it as a script to send mail
insert image description here

5. Test
insert image description here

Guess you like

Origin blog.csdn.net/m0_37749659/article/details/132643294