设为首页 加入收藏

TOP

zabbix wait for 15s seconds 出现原因及调优建议(四)
2018-12-07 00:08:47 】 浏览:732
Tags:zabbix wait for 15s seconds 出现 原因 建议
OLARSSL) || defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL) char tls_issuer[HOST_TLS_ISSUER_LEN_MAX]; char tls_subject[HOST_TLS_SUBJECT_LEN_MAX]; char tls_psk_identity[HOST_TLS_PSK_IDENTITY_LEN_MAX]; char tls_psk[HOST_TLS_PSK_LEN_MAX]; #endif char error[HOST_ERROR_LEN_MAX]; char snmp_error[HOST_ERROR_LEN_MAX]; char ipmi_error[HOST_ERROR_LEN_MAX]; char jmx_error[HOST_ERROR_LEN_MAX]; } DC_HOST; //db.h #define ZBX_FLAGS_AGENT_STATUS_AVAILABLE 0x00000001 #define ZBX_FLAGS_AGENT_STATUS_ERROR 0x00000002 #define ZBX_FLAGS_AGENT_STATUS_ERRORS_FROM 0x00000004 #define ZBX_FLAGS_AGENT_STATUS_DISABLE_UNTIL 0x00000008 #define ZBX_FLAGS_AGENT_STATUS (ZBX_FLAGS_AGENT_STATUS_AVAILABLE | \ ZBX_FLAGS_AGENT_STATUS_ERROR | \ ZBX_FLAGS_AGENT_STATUS_ERRORS_FROM | \ ZBX_FLAGS_AGENT_STATUS_DISABLE_UNTIL) //common.h #define FAIL -1

 

#8  根据agent_type 设置主机状态

    //dbconfig.c
    int    DChost_deactivate(zbx_uint64_t hostid, unsigned char agent_type, const zbx_timespec_t *ts,
            zbx_agent_availability_t *in, zbx_agent_availability_t *out, const char *error_msg)
    {
        int        ret = FAIL, errors_from,disable_until;
        const char    *error;
        unsigned char    available;
        ZBX_DC_HOST    *dc_host;


        /* don't try deactivating host if the unreachable delay has not passed since the first error */
        if (CONFIG_UNREACHABLE_DELAY > ts->sec - in->errors_from) 
            goto out;

        WRLOCK_CACHE;

        if (NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_search(&config->hosts, &hostid)))
            goto unlock;

        /* Don't try deactivating host if:                */
        /* - (server, proxy) it's not monitored any more; */
        /* - (server) it's monitored by proxy.            */
        if ((0 != (program_type & ZBX_PROGRAM_TYPE_SERVER) && 0 != dc_host->proxy_hostid) ||
                HOST_STATUS_MONITORED != dc_host->status)
        {
            goto unlock;
        }

        DChost_get_agent_availability(dc_host, agent_type, in);

        available = in->available;
        error = in->error;

        if (0 == in->errors_from)
        {
            /* first error, schedule next unreachable check */
            errors_from = ts->sec;
            disable_until = ts->sec + CONFIG_UNREACHABLE_DELAY;
        }
        else
        {
            errors_from = in->errors_from;
            disable_until = in->disable_until;

            /* Check if other pollers haven't already attempted deactivating host. */
            /* In that case should wait the initial unreachable delay before       */
            /* trying to make it unavailable.                                      */
            if (CONFIG_UNREACHABLE_DELAY <= ts->sec - errors_from)
            {
                /* repeating error */
                if (CONFIG_UNREACHABLE_PERIOD > ts->sec - errors_from)
                {
                    /* leave host available, schedule next unreachable check */
                    disable_until = ts->sec + CONFIG_UNREACHABLE_DELAY;
                }
                else
                {
                    /* make host unavailable, schedule next unavailable check */
                    disable_until = ts->sec + CONFIG_UNAVAILABLE_DELAY;
                    available = HOST_AVAILABLE_FALSE;
                    error = error_msg;
                }
            }
        }

        zbx_agent_availability_init(out, available, error, errors_from, disable_until);
        DChost_set_agent_availability(dc_host, ts->sec, agent_type, out);

        if (ZBX_FLAGS_AGENT_STATUS_NONE != out->flags)
            ret = SUCCEED;
    unlock:
        UNLOCK_CACHE;
    out:
        return ret;
    }

主要看下这段:

if (0 == in->errors_from)
        {
            /* first error, schedule next unreachable check */
            errors_from = ts->sec;
            disable_until = ts->sec + CONFIG_UNREACHABLE_DELAY;
        }
        else
        {
            errors_from = in->errors_from;
            disable_until = in->disable_until
首页 上一页 1 2 3 4 5 6 7 下一页 尾页 4/7/7
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇移位操作 下一篇PAT (Basic Level) Practice (中..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目