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

When MySQL is upgraded to 5.7, WordPress reports error 1067 when importing data

I recently upgraded MySQL to 5.7, and WordPress r...

Table shows the border code you want to display

Common properties of tables The basic attributes ...

Detailed explanation of selinux basic configuration tutorial in Linux

selinux ( Security-Enhanced Linux) is a Linux ker...

Java example code to generate random characters

Sample code: import java.util.Random; import java...

Recommend a cool interactive website made by a front-end engineer

Website link: http://strml.net/ By Samuel Reed Ti...

How to create a MySQL master-slave database using Docker on MacOS

1. Pull the MySQL image Get the latest MySQL imag...

Detailed tutorial on Docker pulling Oracle 11g image configuration

Without further ado Start recording docker pullin...

Discussion on the problem of iframe node initialization

Today I suddenly thought of reviewing the producti...

202 Free High Quality XHTML Templates (1)

Here 123WORDPRESS.COM presents the first part of ...

Summary of clipboard.js usage

Table of contents (1) Introduction: (2) The ways ...

Design of pop-up windows and floating layers in web design

In the trend of gradual transition from tradition...

Use personalized search engines to find the personalized information you need

Many people now live on the Internet, and searchin...