About Zabbix custom monitoring items and triggers

About Zabbix custom monitoring items and triggers

1. Monitoring port

Relationship Description

Trigger: Get the value according to the client's script. When a certain value of the client reaches the requirement, an alarm will be issued.

Monitoring items: Get values ​​according to the client script, set the interval for collecting values, keep and record the values, and form a curve chart

Application set: used to classify and store monitoring items. For example, monitoring items for web services such as 80 and 8080 are placed in the WEB application set, and monitoring items for small services such as 22 and 21 are placed in the SMALL application set.

Template: A template is a set of defined monitoring items. When any host is connected to a template, the monitoring items in the template will be applied to the host. However, to modify these monitoring items, you can only modify them in the template, and after the modification, other connected hosts will also change accordingly.

operate

1. Create a template. The template name is used to indicate the monitoring port. Here, it is named Port. The template must be added to a group. You can create a separate group to distinguish it.

2. Create an application set. You only need to name the application set.

3. Create monitoring items. The name is used to distinguish the values ​​to be monitored. It may be the number of visits to nginx or the number of reads to mysql.

There are two types of key values, one is to click and select to use the system's built-in value, and the other is to customize the script key.

Select net.tcp.listen[port] here, use telnet to find out whether a host is listening to a port, and fill in the port number to be monitored in [port].

4. Create a trigger, {HOST.NAME} will obtain the host name for alarm display. Click Add Expression, or copy the value of other built-in triggers to modify it.
Connect the monitoring item, this is the monitoring item just created, and leave the rest unchanged.

5. Select the corresponding group and find the newly created monitoring item from the group.

6. Port is the template name. If you choose to write the host name or host IP here, it will become a monitoring item for a single host instead of a template.

2. Monitoring Service

Relationship Description

Script: Execute the script to obtain the value. Configuration file: Allows custom keys and associates the key value with the script to obtain the value.
Server-side testing: The server sends instructions to the client, and the client runs the script to obtain the value and then returns it to the server.

operate

1. Create a script to get the value
cd /etc/zabbix/script

vim web_status.sh

#!/bin/bash

case $1 in
Lian)
    netstat -anptu | grep 172.26.98.247:80 | wc -l ;;
Ping
    netstat -unltp | grep -w 80 &>/dev/null && echo 1 || echo 0 ;;
 *)
    echo "Lian | Ping" ;;
esac

Test script ./web_status.sh Ping to see if you can get 1

2. Modify the client configuration file to allow custom keys
vim /etc/zabbix/zabbix_agentd.conf

Include=/etc/zabbix/zabbix_agentd.conf.d/*.conf #Load other configuration files UnsafeUserParameters=1 #Enable custom Key

systemctl restart zabbix-agent

3. Modify the configuration file, set the key value name and script location, so that the configuration file can know which script needs to be executed to obtain this key value

web.ping is a custom key value name, followed by the script path
vim /etc/zabbix/zabbix_agentd.d/web_status.conf

UserParameter=web.ping,/etc/zabbix/script/web_status.sh Ping
UserParameter=web.lian,/etc/zabbix/script/web_status.sh Lian

If you want to use an absolute path for a command, you can also get the value as follows, without having to use a script.
for example

UserParameter=web.shu,/bin/netstat -anptu | wc -l

4. Detection, client testing
zabbix_agentd -t web.ping #Returns 1 if correct

Server-side testing:
/ops/server/zabbix/bin/zabbix_get -s 192.168.1.1 -k web.ping #1 is correct

5. Appear (Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)

This is because the netstat command is used in the script, but the client uses the zabbix user to start the script and does not have permission to use this command.

The client executes chmod +x /bin/netstat

Web page operation:
The key value cannot be found, so write it manually. The trigger expression is also connected to this monitoring item.

3. Import and export of templates

Import:

Export:
Select the template and scroll down

This is the end of this article about zabbix custom monitoring items and triggers. For more relevant zabbix custom monitoring items, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Example code for configuring monitoring items and aggregated graphics in Zabbix

<<:  MySQL database operations and data types

>>:  Example of JSON output in HTML format (test interface)

Recommend

Mysql8.0 uses window functions to solve sorting problems

Introduction to MySQL Window Functions MySQL has ...

Detailed process of installing and deploying onlyoffice in docker

0. System requirements CPU I5-10400F or above Mem...

How to use squid to build a proxy server for http and https

When we introduced nginx, we also used nginx to s...

How to export mysql table structure to excel

The requirements are as follows Export the table ...

Sample code for implementing form validation with pure CSS

In our daily business, form validation is a very ...

Vue-Element-Admin integrates its own interface to realize login jump

1. First look at the request configuration file, ...

Writing methods that should be prohibited in native JS

Table of contents Block-level functions Directly ...

How to implement nginx smooth restart

1. Background During the server development proce...

Solution to Nginx session loss problem

In the path of using nginx as a reverse proxy tom...

Automatic failover of slave nodes in replication architecture in MySQL 8.0.23

I have been in contact with MGR for some time. Wi...

Solution to the problem that Centos8 cannot install docker

Problem [root@zh ~]# [root@zh ~]# [root@zh ~]# yu...

Summary of 16 XHTML1.0 and HTML Compatibility Guidelines

1. Avoid declaring the page as XML type . The pag...

Solve the problem of ugly blue border after adding hyperlink to html image img

HTML img produces an ugly blue border after addin...

Detailed installation and configuration of Subversion (SVN) under Ubuntu

If you are a software developer, you must be fami...