Custom key solves the problem of inaccurate Zabbix port monitor value

Source: Internet
Author: User
Tags 04x

Today, a friend asked me a question about Zabbix monitoring TCP port, obviously the port is listening, but the value taken by Net.tcp,listen is 0. After a simple Goole discovery, this has been a long-standing problem: The root cause of the problem is that the Zabbix key (Net.tcp,listen) is being collected by reading the/proc/net/tcp file, and/proc/ File is not thread-safe, so there is a problem with inaccurate values.      In addition, this mechanism has another hidden danger: When the/proc/net/tcp file has a lot of entries, it will result in a slow value, so it is possible to cause the problem of value failure. Then we should solve this problem, the Internet has found a solution, I am here when the nature of the Porter ~ Haha solution is to add a new user-defined key to replace the Zabbix to provide their own monitoring method, the specific steps are as follows: #1, add a custom key---net.tcp.listen.grep[*]Add the following configuration in the Agentd configuration file for the Zabbix client, or in the Include profile directory declared by Zabbix Agentd:
Userparameter=net.tcp.listen.grep[*],grep-q $$ (printf '%04x.00000000:0000.0a ' $)/proc/net/tcp && echo 1 | | Echo 0

For example, my choice is in the/ETC/ZABBIX/ZABBIX-AGENTD.CONF.D directory, created a file net_tcp_listen.conf, the above key to write the declaration to the file, because my zabbix_ The configuration file directory contains the declarations that have been made in agentd.conf:

thatsit:~ # grep ^include/etc/zabbix/zabbix-agentd.confinclude=/etc/zabbix/zabbix-agentd.conf.d/thatsit:~ #thatsit : ~ # Cat  /etc/zabbix/zabbix-agentd.conf.d/net_tcp_listen.confuserparameter=net.tcp.listen.grep[*],grep-q $$ ( printf '%04x.00000000:0000.0a ' $/proc/net/tcp && echo 1 | | Echo 0thatsit:~ #
#2, restart the zabbix-agentd for the configuration to take effect
shipeng:~ #/etc/init.d/zabbix-agentd restartshutting down Zabbix agentd donestarting Zabbix                                              agentd                                                   doneshipeng:~ #
#3, test with Zabbix_get
thatsit:~ # zabbix_get-s 192.168.3.154-k "net.tcp.listen.grep[22]" 1thatsit:~ # zabbix_get-s 192.168.3.154-k "NET.TCP.L ISTEN.GREP[23] "0thatsit:~ #
#4, on the web side, add this monitoring item to the pointing host.

The key of the monitoring item is:net.tcp.listen.grep[the port number to monitor]

#5, configuration complete, troubleshooting ideas

This configuration has been completed, if there is a problem, you can follow the following ideas to troubleshoot, the general problem in the log can be found in the clues.

# Troubleshooting Ideas:There are a few things to note when adding a key: Note the owner or group configuration of a configuration file or custom script if you use a custom script, note that if you need to execute a custom script, you also need to open the following parameter in zabbix_agentd.conf:
thatsit:~ # grep ^unsafe/etc/zabbix/zabbix-agentd.confunsafeuserparameters=1thatsit:~ #
Reference Link: http://www.oschina.net/question/224285_128311

Custom key solves the problem of inaccurate Zabbix port monitor value

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.