In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to customize key in zabbix, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
How to customize key in zabbix and use it.
Zabbix is an open source, free monitoring tool. It has many default monitoring options that come with it. But sometimes, the built-in monitoring options are not enough. At this point, you need to customize your own monitoring options. I have written several monitoring options, which are used to monitor the status of mysql, the status of mysql master-slave replication, and the time difference between mysql master-slave replication.
1. Open the configuration file of zabbix agent, and add the following statement at the end of the file, as shown below:
UnsafeUserParameters=1
/ / this value defaults to 0. Changing to 1 means that custom key is enabled.
UserParameter=mysql.ping,netstat-an | find / I / c "3308"
/ / Custom key is mysql.ping. The value of this key is obtained from the command netstat-an | find / I / c "3308"
UserParameter=mysql.slavetime,C:\ Zabbix\ userdfscrpts\ slaveTime.bat
/ / Custom key is mysql. Slavetime, the output value of the script C:\ Zabbix\ userdfscrpts\ slaveTime.bat is passed to mysql. Go to slavetime.
UserParameter=mysql.slavestatus,C:\ Zabbix\ userdfscrpts\ slaveStatus.bat
/ / Custom key is mysql.slavestatus, and the output value of the script C:\ Zabbix\ userdfscrpts\ slaveStatus.bat is passed to mysql. Go to slavestatus.
2. The content of the script is as follows:
(1) C:\ Zabbix\ userdfscrpts\ slaveStatus.bat
@ echo off
Cd / d D:\ XXX\ mysql-5.6.19-winx64\ bin
Mysql-uroot-p "XXX"-e "SHOW SLAVE STATUS\ G" > C:\ Zabbix\ middlefiles\ status2.txt 2 > C:\ Zabbix\ middlefiles\ waring2.txt
Rem pause
Cd / DC:\ Zabbix\ middlefiles
Type status2.txt | findstr "\" | find / I / c "Yes" > status.txt
For / f% I in (status.txt) do set status=%%i
Echo status%
Rem pause
(2) C:\ Zabbix\ userdfscrpts\ slaveTime.bat
@ echo off
Rem set MYSQL_PWD=XXXX
Cd / d D:\ XXXX\ mysql-5.6.19-winx64\ bin
Mysql-uroot-p "XXXX"-e "SHOW SLAVE STATUS\ G" > C:\ Zabbix\ middlefiles\ status1.txt 2 > C:\ Zabbix\ middlefiles\ waring.txt
Type C:\ Zabbix\ middlefiles\ status1.txt | find "Seconds_Behind_Master" > C:\ Zabbix\ middlefiles\ losttime.txt
For / f "delims=: tokens=2"% I in (C:\ Zabbix\ middlefiles\ losttime.txt) do set time=%%i
Echo time%
Rem pause
3. Test the key value on the machine where the zabbix server is located.
[jobadmin@i611-zabbixnw-1 ~] $zabbix_get-s 172.30.30.4-p 10050-k "mysql.slavestatus"
Here the-s option is followed by the host IP address where the key value to be tested is located,-p is followed by the port, and-k is followed by the name of the key value to be tested. If the returned result is normal, it means that the key is ready for use.
4. Add the previously customized key to the item of the host where the zabbix agent resides, as follows:
(1) Log in to the monitoring page of zabbix, select hosts under configuration, and then filter out the host where the modified zabbix agent is based on Group or Filter.
(2) Click the hostname, then click the items option, and select Create item on the page that comes out.
(3) fill in the necessary information on the create new item page. After filling in the information, click Add to add.
The Name field represents the name of the item, which is defined by yourself.
The Key field is the custom key we just created in the configuration file of zabbix agent. Here I fill in mysql.ping.
Type of information field: indicates what type the key value returns, whether it is a character or unsigned number type, a decimal type or a text format
Data type field: is a supplement to the Type of information field
Units field: indicates the unit. For example, the result returned by key is the percentage. Enter% here.
Applications field: indicates which category you want your new item to be classified into. This Application is also to be built by yourself to represent a class. Such as hardware, software, CPU and so on.
(4) Click the hostname, then click the Triggers option, and select Create trigger on the page that comes out.
(5) fill in the necessary information on the create new Trigger page. After filling in the information, click Add to add.
Name field: indicates the name of Trigger, which is defined by yourself.
The Expression field: is the body of the Trigger, indicating under what conditions you want to trigger the Trigger.
Description field: is a supplementary explanation of Trigger. For example, in the expression of Trigger, 0 indicates success, 1 indicates failure, and so on.
Severity field: indicates the level of Trigger, from low to high.
Click Add next to the Expression field, and the interface for entering the condition will pop up, as follows:
The Item field: indicates which item the Trigger was created from. Select select, and all available item will appear. We can choose the Item we just created.
Function field: there are various conditions in this drop-down list, so choose one according to your needs.
N: this N is the N value in the conditional expression in the Function field.
4. Check whether Trigger is effective:
Going back to the Trigger page, you can see all the Trigger on the host. If the status of the Trigger is Enabled, it means that the Trigger is normal and available. Otherwise, there's a problem.
Thank you for reading this article carefully. I hope the article "how to customize key in zabbix" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.