zoukankan      html  css  js  c++  java
  • zabbix 获取不到自定义脚本的值解决

    agent端:

    zabbix 自定义脚本

    [root@localhost script]# cat check_ping.sh 
    #!/bin/bash
    result=$(/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
    [root@localhost script]# 

    执行脚本:

    [root@localhost script]# sh check_ping.sh 172.16.8.11 www.baidu.com
    0000
    [root@localhost script]# 
    [root@localhost script]# sh check_ping.sh 172.16.8.11 www.nimeiakao.com
    2222
    [root@localhost script]

    修改zabbix_agentd.conf配置并重启服务:

    +++++++++++++
    ### 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
    ++++++++++++++++++++++++++
    [root@localhost etc]# /etc/init.d/zabbix_agentd restart
    Shutting down zabbix_agentd:                               [  OK  ]
    Starting zabbix_agentd:                                    [ OK ]
    [root@localhost etc]#

    在服务端使用命令检测自定义key是否可行:

    [root@localhost ~]# zabbix_get -s 172.16.8.11 -p 10050 -k "check.icmpping[172.16.8.11,172.16.8.12]"
    0000
    [root@localhost ~]# zabbix_get -s 172.16.8.11 -p 10050 -k "check.icmpping[172.16.8.11,192.168.1.2]"
    ZBX_NOTSUPPORTED
    [root@localhost ~]# 
    从上面可以看出,对于不通的值zabbix服务端始终取不到值,出现ZBX_NOTSUPPORTED

    zabbix取不到值得解决办法:

    修改agent端的超时时间并重启agent服务:

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

    在server端再次测试:

    [root@localhost ~]# zabbix_get -s 172.16.8.11 -p 10050 -k "check.icmpping[172.16.8.11,172.16.8.12]"
    0000
    [root@localhost ~]# zabbix_get -s 172.16.8.11 -p 10050 -k "check.icmpping[172.16.8.11,192.168.1.2]"
    2222
    [root@localhost ~]# 
  • 相关阅读:
    使用python2 对服务器监控(监控内存,CPU,网卡流量等)
    centos7使用yum提示有事物未完成的解决办法:
    如何判断Linux下 网卡是虚拟还是物理网卡?
    python3监控系统资源最终版(获取CPU,内存,磁盘,网卡等信息),返回json格式。
    python3 系统监控脚本(2) (监控CPU,内存等信息)
    python3 系统监控脚本(CPU,memory,网络,disk等)
    获取Linux系统运行时间
    Linux之jq
    hadoop--presto安装部署
    docker 笔记--运行中的容器如何添加端口映射
  • 原文地址:https://www.cnblogs.com/osxlinux/p/3949094.html
Copyright © 2011-2022 走看看