Zabbix: (4) Add a custom monitoring project and use it.

Source: Internet
Author: User

From the first day of installation, there will inevitably be questions about the poor use of the default monitoring template, or there is no such thing as what to do? It doesn't matter. Like Nagios, zabbix can customize monitoring items, including alarm rules and views.


Add a custom Monitoring Project:

Before the operation, you need to know the principle: the principle is that the server calls the script configured by the agent, and then transmits the script parameters to the server, and the server writes the script to the database, then get a new value and then process it and display it to the user at the front end.

Therefore, we need to do three things:

First, write monitoring scripts

Second, modify the configuration of zabbix_agent.

Third, add a new monitoring project on zabbix_web

Please note that step 1 and Step 2 are done on the zabbix_agent side, and do not involve the zabbix_server side. Step 3 is the web side.

The following is an example of monitoring Java processes in Linux:

The first step is to check my monitoring script, which is quite simple. It only monitors the number of Java processes and the number of Tomcat processes.

# Check the script Vim checkjava. Sh #! /Bin/bash # PPP # scripts for Java status function JWC {/bin/PS aux | grep Java | grep-V grep | WC-l} function ctom {/bin/PS aux | grep Java | grep Tomcat | WC-l} $1 # Run it, there are 9 Java processes and 1 Tomcat process bash checkjava. sh uninstall c9bash checkjava. sh ctom1

Step 2: add the key value in zabbix_agent to call the script configuration:

If you have the following configurations:

cat /etc/zabbix/zabbix_agentd.conf |grep Include= |grep -v \#Include=/etc/zabbix/zabbix_agentd.conf.d/

Then, the configuration of your new key value call script can be loaded to/etc/zabbix/zabbix_agentd.conf.d/. If not, add it to the last line of/etc/zabbix/zabbix_agentd.conf, in fact, they are all the same. Let's take a look at the example below:

# Enter the directory CD/etc/zabbix/zabbix_agentd.conf.d/# ll, these are my custom metrics lltotal 24-rw-r -- r -- 1 Root 64 Nov 30 checkjava-RW-r -- 1 Root 60 Nov 11 iostatus-RW-R -- r -- 1 Root 56 Nov 10 redis-RW-r -- 1 Root 51 Nov 10 TCP # others are not studied yet, let's take a look at the target configuration Vim checkjava # monitor Java userparameter = checkjava [*],/Shell/checkjava. sh $1 # defines a key value checkjava and calls/Shell/checkjava. sh script and input parameters. # Then, do not forget to restart zabbix_agent/etc/init. d/zabbix-Agent restart

Then, you can test it in zabbix_server.

# Run the following command to debug the remote Agent key value zabbix_get-S 10. x. x. x-p10050-k "checkjava [JWC]" 5 # obtain the desired data.

Step 3: Add a new monitoring project on zabbix_web:

As it looks like, I won't talk about it when I log on. I just want to talk about the interface:

Click Configure-template-create template:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/8A/F0/wKiom1g_moyg_e7fAABhkbEJet8565.png "style =" float: none; "Title =" 1.png" alt = "wkiom1g_moyg_e7faabhkbejet8565.png"/>

Change the name first. You can select the default templates for the group, or you have your own interests.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M02/8A/EC/wKioL1g_mo2w2YgPAAB0h9gwBK4079.png "style =" float: none; "Title =" 2.png" alt = "wkiol1g_mo2w2ygpaab0h9gwbk4079.png"/>

Click <metric item> above and click <create metric item> to create the following two items.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M01/8A/F0/wKiom1g_m4jhBUF5AACWqs5aRWc967.png "style =" float: none; "Title =" 3.png" alt = "wkiom1g_m4jhbuf5aacwqs5arwc967.png"/>

Fill in the information:

Name: Do not give words or do not give up your mind. It will be reflected in graphics and monitoring alarms.

Type: no other special settings. The default setting is good.

Key value: the key value configured in the conf. D folder in zabbix_agent corresponds to the name of the script function.

Information type: It depends on the numeric value obtained by your script, whether it is a pure number or a percentage floating point number. It can be a character text or anything, because I am an integer here, so it is a number (No plus or minus.

Data Type: corresponds to the preceding data type. Generally, it is in decimal format.

Unit: Write if any. If not, do not write. For example, the percentage is %, and the traffic is bps.

Data Update Interval: depending on the actual situation, it is undeniable that some monitoring sites are not suitable for monitoring as frequently as possible. On the contrary, some monitoring sites must be frequent. For example, I think one minute is enough, some people think it takes 10 seconds.

Historical data retention duration and dead data storage cycle are based on the actual situation, because as your zabbix usage time increases, the data volume will inevitably grow bigger and bigger, the definition is shorter.

If you don't need to worry about anything else, just confirm the update and add another tomcat, it will become the figure above.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M00/8A/EC/wKioL1g_m4niJwK5AACFXrjebzs762.png "style =" float: none; "Title =" 4.png" alt = "wkiol1g_m4nijwk5aacfxrjebzs762.png"/>

The metric item is available. Of course we still need to see the figure, right?

Click <image> next to the metric item and click <Create Image>.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M02/8A/F0/wKiom1g_oOSCzBk3AABUiUx64ug498.png "style =" float: none; "Title =" 1.png" alt = "wkiom1g_oosczbk3aabuiux64ug498.png"/>

Fill in the information:

Name: displays the information of the image, which is then monitored.

You can test it on your own,

Go directly to <metric items>-click <add> to bring up a new window.

650) This. width = 650; "src =" http://s2.51cto.com/wyfs02/M02/8A/EC/wKioL1g_oOWxSfVrAACFieXRZj4946.png "style =" float: none; "Title =" 2.png" alt = "wkiol1g_oowxsfvraacfiexrzj4946.png"/>

Select the metric item that you want to display in the graph. Select all items here. Click <SELECT> to return to the above box and click <Update>.

650) This. width = 650; "src =" http://s2.51cto.com/wyfs02/M00/8A/F0/wKiom1g_oOjDSOp1AACWlVcr1wA813.png "style =" float: none; "Title =" 3.png" alt = "wkiom1g_oojdsop1aacwlvcr1wa813.png"/>

After adding the image, I still think he has an alarm. A reasonable requirement is that I need to generate an alarm when the number of Tomcat processes is not 1.

Do you still remember the trigger next to the metric item? Next let's take a look:

Click the <trigger> In The Middle Of The Metric item and graph. Then click <create trigger>. A new dialog box is displayed.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M00/8A/F0/wKiom1g_qs7hTmnUAABk47t5gZU940.png "style =" float: none; "Title =" 1.png" alt = "wkiom1g_qs7htmnuaabk47t5gzu940.png"/>

Select the <metric item> You Want To trigger the alarm. A dialog box is displayed.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M01/8A/F0/wKiom1g_qs_DJSpJAABy7ylKY38924.png "style =" float: none; "Title =" 3.png" alt = "wkiom1g_qs_djspjaaby7ylky38924.png"/>

Here, we need an alarm when the number of Tomcat processes changes to 0, so select <Tomcat total number> and return to the previous dialog box.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M02/8A/F0/wKiom1g_qs-iCpTUAACWwsXhuW4029.png "style =" float: none; "Title =" 4.png" alt = "wKiom1g_qs-iCpTUAACWwsXhuW4029.png"/>

In the <function> Option's rightmost triangle drop-down list, select the trigger condition you want. Generally, the trigger conditions are greater than or less than, or not equal to, and you have chosen them as needed. I don't want to say more, after the selection, continue with the following conditions.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M02/8A/EC/wKioL1g_qs-xXntZAAC17UwlY5M682.png "style =" float: none; "Title =" 5.png" alt = "wKioL1g_qs-xXntZAAC17UwlY5M682.png"/>

The two <last> and <shift schedule> below can work together to make your alarm interval more flexible. I will not elaborate on them here. You will test them slowly, obtaining desired results is the most important thing.

The final <n> is actually the meaning of N selected in the <function> above, so the meaning here is: the latest tvalue is not 1, t is the value obtained by zabbix through the script, finally, click Insert to obtain the graph starting with the trigger.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M00/8A/F0/wKiom1g_qtDznm0vAABRTjmSpp8195.png "style =" float: none; "Title =" 6.png" alt = "wkiom1g_qtdznm0vaabrtjmspp8195.png"/>

The whole monitoring project is added here, but we need to add it to the server configuration to make it really complete. Otherwise, it will not work. Let's look at how to use it.


Use a custom Monitoring Project:

In fact, it is the same as the second article. You need to add a template for use. For details, see the following:

Click Configure-host, select the host for which you want to add this metric item, and go to the second page.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/8A/ED/wKioL1g_um3yW_OFAAFbhya93mo996.png "style =" float: none; "Title =" 1.png" alt = "wkiol1g_um3yw_ofaafbhya93mo996.png"/>

Click <template> on the top and <SELECT> template to be added in the lower right corner. A dialog box is displayed.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M00/8A/ED/wKioL1g_um6SVoeGAABXvbuGoUU030.png "style =" float: none; "Title =" 2.png" alt = "wkiol1g_um6svoegaabxvbugou030.png"/>

Select our target template. Here is the Java monitoring template. Click "select" and return to the previous dialog box.

650) This. width = 650; "src =" http://s1.51cto.com/wyfs02/M00/8A/F1/wKiom1g_um-Di2FiAADeRyQIDWo875.png "style =" float: none; "Title =" 3.png" alt = "wKiom1g_um-Di2FiAADeRyQIDWo875.png"/>

Click <add> below and then click <Update>

650) This. width = 650; "src =" http://s1.51cto.com/wyfs02/M00/8A/ED/wKioL1g_unCCz9RtAABdMkhj1uY328.png "style =" float: none; "Title =" 4.png" alt = "wkiol1g_unccz9rtaabdmkhj1uy328.png"/>

After adding, let's see the results:

650) This. width = 650; "src =" http://s2.51cto.com/wyfs02/M02/8A/ED/wKioL1g_u-LSCFx7AAC7jQTjkIs587.png "Title =" 5.png" alt = "wKioL1g_u-LSCFx7AAC7jQTjkIs587.png"/>

Even if this is done, you can study other monitoring methods on your own.


Add custom monitoring for Windows:

I don't know much about this, And zabbix's built-in template and zabbix_agent's self-discovery function are powerful, and most of the desired monitoring functions are available. In fact, there are not many things to add.

His automatic discovery has been powerful. All services you define can be detected, and traffic monitoring can also be detected automatically, the only pity is that the CPU monitoring percentage is reduced, so let's add it below.

I will not post so many images this time. You know where I am talking:

Click <configuration>-<template>-select <template OS Windows>-top <metric item>-<create metric item>

Enter information:

Name: CPU percentage
Key Value: perf_counter [\ processor (_ total) \ % processor time]
Data Type: Numeric (floating point)
Unit: %
Data Update Interval (SEC): 30
Application set: CPU

Click Add or update below.

650) This. width = 650; "src =" http://s4.51cto.com/wyfs02/M02/8A/EE/wKioL1g_wszy_v8rAACRjg09eN0457.png "style =" float: none; "Title =" 6.png" alt = "wkiol1g_wszy_v8raacw.g09en0457.png"/>

Then, add the image, which is not mentioned here. Please refer to the above

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/8A/F2/wKiom1g_ws3hAi40AABxLhhpyPQ449.png "style =" float: none; "Title =" 7.png" alt = "wkiom1g_ws3hai40aabxlhhpypq449.png"/>

Finally, add a trigger. You can set it yourself.

650) This. width = 650; "src =" http://s1.51cto.com/wyfs02/M00/8A/F2/wKiom1g_ws-BOXKCAAB0X9-rDNI433.png "style =" float: none; "Title =" 8.png" alt = "wKiom1g_ws-BOXKCAAB0X9-rDNI433.png"/>

Look at the final results

650) This. width = 650; "src =" http://s1.51cto.com/wyfs02/M01/8A/F2/wKiom1g_w3qyEcFBAAFp3p7p6D8492.png "Title =" 9.png" alt = "wkiom1g_w3qyecfbaafp3p7p6d8492.png"/>

OK, you can use it. here we will talk about it. The rest will be studied slowly.


Zabbix: (4) Add a custom monitoring project and use it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.