Zabbix cannot obtain the value of the custom script.

Source: Internet
Author: User

AGENT:

Zabbix Custom Script

[[email protected] script]# cat check_ping.sh #!/bin/bashresult=$(/usr/local/nagios/libexec/check_icmp -s $1 $2)a=$(echo $result | awk ‘{print $1}‘)if [ $a == "OK" ];then    echo "0000"else    echo "2222"fi[[email protected] script]# 

Run the script:

[[email protected] script]# sh check_ping.sh 172.16.8.11 www.baidu.com0000[[email protected] script]# 
[[email protected] script]# sh check_ping.sh 172.16.8.11 www.nimeiakao.com
2222
[[email protected] script]

Modify zabbix_agentd.conf configuration and restart the service:

+++++++++++++### Option: UnsafeUserParameters#       Allow all characters to be passed in arguments to user-defined parameters.#       0 - do not allow#       1 - allow## Mandatory: no# Range: 0-1# Default:UnsafeUserParameters=1### Option: UserParameter#       User-defined parameter to monitor. There can be several user-defined parameters.#       Format: UserParameter=<key>,<shell command>#       See ‘zabbix_agentd‘ directory for examples.## Mandatory: no# Default:UserParameter=check.icmpping[*],/usr/local/zabbix/script/check_ping.sh $1 $2++++++++++++++++++++++++++
[[email protected] etc]# /etc/init.d/zabbix_agentd restart
Shutting down zabbix_agentd:                               [  OK  ]
Starting zabbix_agentd:                                    [ OK ]
[[email protected] etc]#

Use commands on the server to check whether the custom key is feasible:

[[Email protected] ~] # Zabbix_get-s 172.16.8.11-P 10050-k "check. icmpping [172.16.8.11, 172.16.8.12]" 0000 [[email protected] ~] # Zabbix_get-s 172.16.8.11-P 10050-k "check. icmpping [172.16.8.11, 192.168.1.2]" zbx_notsupported [[email protected] ~] #
We can see from the above that zabbix server cannot get the value for the value that cannot be obtained, and zbx_notsupported appears.

Zabbix cannot be used as a solution:

Modify the agent timeout and restart the agent service:

### Option: Timeout#       Spend no more than Timeout seconds on processing## Mandatory: no# Range: 1-30# Default:#Timeout=3Timeout=8
[[email protected] etc]# /etc/init.d/zabbix_agentd restart
Shutting down zabbix_agentd:                               [  OK  ]
Starting zabbix_agentd:                                    [  OK  ]
[[email protected] etc]#

Test again on the server:

[[email protected] ~]# zabbix_get -s 172.16.8.11 -p 10050 -k "check.icmpping[172.16.8.11,172.16.8.12]"0000[[email protected] ~]# zabbix_get -s 172.16.8.11 -p 10050 -k "check.icmpping[172.16.8.11,192.168.1.2]"2222[[email protected] ~]# 

 

Zabbix cannot obtain the value of the custom script.

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.