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

How to use JS to check if an element is within the viewport

Preface Share two methods to monitor whether an e...

What you need to know about responsive design

Responsive design is to perform corresponding ope...

Detailed analysis of the principles and usage of MySQL views

Preface: In MySQL, views are probably one of the ...

Summary of the use of element's form elements

There are many form elements. Here is a brief sum...

Vue implements mobile phone verification code login

This article shares the specific code of Vue to i...

Vue project implements left swipe delete function (complete code)

Achieve results The code is as follows html <t...

The whole process of developing a Google plug-in with vue+element

Simple function: Click the plug-in icon in the up...

Summary of knowledge points about covering index in MySQL

If an index contains (or covers) the values ​​of ...

Ubuntu starts the SSH service remote login operation

ssh-secure shell, provides secure remote login. W...

Vue: Detailed explanation of memory leaks

What is a memory leak? A memory leak means that a...

How to debug loader plugin in webpack project

Recently, when I was learning how to use webpack,...

WeChat applet picker multi-column selector (mode = multiSelector)

Table of contents 1. Effect diagram (multiple col...

Vue3 AST parser-source code analysis

Table of contents 1. Generate AST abstract syntax...