zabbix报错分析

zabbix报错分析

报错信息如下:

3128:20150429:114455.871 history data from active proxy on “115.29.182.109” failed: proxy “jinrong” not found

查找源码

[[email protected] src]# grep “history data from active proxy” * -r|more

zabbix_server/trapper/trapper.c: zabbix_log(LOG_LEVEL_WARNING, “history data from active proxy on \”%s\” failed: %s”,

得出是trapper.c 导致。

分析trapper.c

/******************************************************************************
 *                                                                            *
 * Function: recv_proxyhistory                                                *
 *                                                                            *
 * Purpose: processes the received values from active proxies                 *
 *                                                                            *
 ******************************************************************************/
static void     recv_proxyhistory(zbx_sock_t *sock, struct zbx_json_parse *jp)
{
        const char      *__function_name = "recv_proxyhistory";
        zbx_uint64_t    proxy_hostid;
        char            host[HOST_HOST_LEN_MAX], *error = NULL;
        int             ret;

        zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);

        if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
        {
                zabbix_log(LOG_LEVEL_WARNING, "history data from active proxy on \"%s\" failed: %s",
                                get_ip_by_socket(sock), error);
                goto out;
        }

        update_proxy_lastaccess(proxy_hostid);

        ret = process_hist_data(sock, jp, proxy_hostid, error, sizeof(error));
out:
        zbx_send_response(sock, ret, error, CONFIG_TIMEOUT);

        zbx_free(error);

        zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name);
}

也就是说 get_active_proxy_id(jp, &proxy_hostid, host, &error)) 这个函数执行不正确的话,会报上面的错。

问题又转化为 get_active_proxy_id的执行了。

继续搜索 get_active_proxy_id 这个函数的源码文件,

[[email protected] src]# grep get_active_proxy_id * -r
Binary file libs/zbxdbhigh/libzbxdbhigh.a matches
Binary file libs/zbxdbhigh/libzbxdbhigh_a-proxy.o matches
libs/zbxdbhigh/proxy.c: * Function: get_active_proxy_id                                              *
libs/zbxdbhigh/proxy.c:int  get_active_proxy_id(struct zbx_json_parse *jp, zbx_uint64_t *hostid, char *host, char **error)
Binary file zabbix_server/trapper/proxyhosts.o matches
zabbix_server/trapper/proxydiscovery.c: if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
zabbix_server/trapper/trapper.c:    if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
zabbix_server/trapper/trapper.c:    if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
Binary file zabbix_server/trapper/trapper.o matches
Binary file zabbix_server/trapper/proxydiscovery.o matches
Binary file zabbix_server/trapper/proxyconfig.o matches
zabbix_server/trapper/proxyautoreg.c:   if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
zabbix_server/trapper/proxyconfig.c:    if (SUCCEED != get_active_proxy_id(jp, &proxy_hostid, host, &error))
Binary file zabbix_server/trapper/proxyautoreg.o matches
Binary file zabbix_server/trapper/libzbxtrapper.a matches
zabbix_server/trapper/proxyhosts.c: if (SUCCEED != (ret = get_active_proxy_id(jp, &proxy_hostid, host, &error)))
Binary file zabbix_server/zabbix_server matches

可以看到是在libs/zbxdbhigh/proxy.c 文件中定义

/******************************************************************************
 *                                                                            *
 * Function: get_active_proxy_id                                              *
 *                                                                            *
 * Purpose: extract a proxy name from JSON and find the proxy ID in database. *
 *          The proxy must be configured in active mode.                      *
 *                                                                            *
 * Parameters: jp            - [IN] JSON with the proxy name                  *
 *             hostid        - [OUT] proxy host ID found in database          *
 *             host          - [IN] buffer with minimum size                  *
 *                                  ‘HOST_HOST_LEN_MAX‘                       *
 *             error         - [OUT] error message                            *
 *                                                                            *
 * Return value:  SUCCEED - proxy ID was found in database                    *
 *                FAIL    - an error occurred (e.g. an unknown proxy or the   *
 *                          proxy is configured in passive mode               *
 *                                                                            *
 * Author: Alexander Vladishev                                                *
 *                                                                            *
 ******************************************************************************/
int     get_active_proxy_id(struct zbx_json_parse *jp, zbx_uint64_t *hostid, char *host, char **error)
{
        DB_RESULT       result;
        DB_ROW          row;
        char            *host_esc;
        int             ret = FAIL, status;

        if (SUCCEED == zbx_json_value_by_name(jp, ZBX_PROTO_TAG_HOST, host, HOST_HOST_LEN_MAX))
        {
                if (FAIL == zbx_check_hostname(host))
                {
                        *error = zbx_dsprintf(*error, "invalid proxy name \"%s\"", host);
                        return ret;
                }

                host_esc = DBdyn_escape_string(host);

                result = DBselect(
                                "select hostid,status"
                                " from hosts"
                                " where host=‘%s‘"
                                        " and status in (%d,%d)"
                                        ZBX_SQL_NODE,
                                host_esc, HOST_STATUS_PROXY_ACTIVE, HOST_STATUS_PROXY_PASSIVE,
                                DBand_node_local("hostid"));

                zbx_free(host_esc);

                if (NULL != (row = DBfetch(result)) && FAIL == DBis_null(row[0]))
                {
                        if (SUCCEED == is_uint31(row[1], &status))
                        {
                                if (HOST_STATUS_PROXY_ACTIVE == status)
                                {
                                        ZBX_STR2UINT64(*hostid, row[0]);
                                        ret = SUCCEED;
                                }
                                else
                                {
                                        *error = zbx_dsprintf(*error, "proxy \"%s\" is configured in passive mode",
                                                        host);
                                }
                        }
                        else
                                THIS_SHOULD_NEVER_HAPPEN;
                }
                else
                        *error = zbx_dsprintf(*error, "proxy \"%s\" not found", host);

                DBfree_result(result);
        }
        else
                *error = zbx_strdup(*error, "missing name of proxy");

        return ret;
}

分析这段源码,也就是说hosts表中查不到的时候是会报 proxy \”%s\” not found 的。

hosts表结构

MySQL [zabbix]> desc hosts;

+——————–+———————+——+—–+———+——-+

| Field | Type | Null | Key | Default | Extra |

+——————–+———————+——+—–+———+——-+

| hostid | bigint(20) unsigned | NO | PRI | NULL | |

| proxy_hostid | bigint(20) unsigned | YES | MUL | NULL | |

| host | varchar(64) | NO | MUL | | |

| status | int(11) | NO | MUL | 0 | |

| disable_until | int(11) | NO | | 0 | |

| error | varchar(128) | NO | | | |

| available | int(11) | NO | | 0 | |

| errors_from | int(11) | NO | | 0 | |

| lastaccess | int(11)

分析

观察hosts表数据,其实发现status 就是主机状态,HOST_STATUS_PROXY_ACTIVE ,HOST_STATUS_PROXY_PASSIVE 为主动,被动模式的代理,结合zabbix的理论,active 模式的proxy ,只需要配置proxy的名字,不需要配置ip 或者dns 名,是会主动建立和server的连接的。那么现在建立连接的时候没有在hosts表中发现配置,就会报 proxy not found的的错误。联想到之前确实删除过proxy配置,然而机器上面的proxy 还在运行,所以会导致这种情况。但是之前2.2.3都没有这样的报警的。要么是2.2.9里面新push的代码。

处理

在dm 配置中加上原来jinrong的那个proxy 配置之后,zabbix server不在报这样的错。处理完毕。

后记

源码还是要尝试着看,毕竟是“源码面前了无秘密”。

时间: 2024-11-14 12:40:50

zabbix报错分析的相关文章

zabbix报错:Too many processes on node1

zabbix报错:Too many processes on Xining City 报错信息:Too many processes on Xining City(服务器名称) 报错原因分析: 服务器进程大于300,默认值为300,有些服务器进程很容易超过300,这里我们可以调整Too many processes on {HOST.NAME} 修改值为3000,原值为300 解决方法:修改Too many processes on {HOST.NAME}值 1.重新设置触发器的值Configu

const变量赋值报错分析

const变量赋值报错分析 const变量赋值报错 从变量到常量的赋值是合法C++的语法约定的, 如从char 到const char顺畅: 但从char **到 const char **编译器就会报错: error: invalid conversion from `char**' to `const char**' 示例: int main(int argc, char *argv[]) { char a = '1'; const char b = a; char * a2 = "1234

学会WCF之试错法——安全配置报错分析

安全配置报错分析 服务端配置 <system.serviceModel> <bindings> <wsHttpBinding> <binding name ="WsHttpBinding_IService" maxReceivedMessageSize="370000" receiveTimeout="00:10:01" maxBufferPoolSize="100"> <

使用yum安装zabbix报错

背景:我使用yum方式安装软件时,比如zabbix这种软件,我们在安装时一般都是直接到zabbix官网,按照官方的步骤进行安装,但是有一个问题,官方的服务器不在国内,时常会在安装时导致超时报错.此时解决思路就因该是将官方源替换成国内的镜像源,例如阿里云.163的镜像源.要点就是网络问题!网络问题!网络问题! 注意安装zabbix时也要选择阿里云的镜像repo,地址如下: rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x8

安装zabbix报错configure: error: libcurl library not found

libcurl 和libcurl-devel都已经安装 且大于7.13.1 但还是报错,这时需要在configure 指定curl路径即可 ./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl=/usr/bin/curl-config  --with-

FastDFS的一次报错分析

1.故障描述: 配置好fdfs后,测试上传一个/etc/passwd的文件,发现有报错信息(之前已经重启过FastDFS相关的服务过了) [[email protected] fdfs]# fdfs_upload_file /etc/fdfs/client.conf /etc/passwd [2016-04-03 22:40:56] ERROR - file: tracker_proto.c, line: 48, server: 192.168.1.136:22122, response sta

zabbix报错整理--持续更新

遇到第一个问题:发送邮件报错: Failure when receiving data from the peer 报错内容:从对等端接收数据时失败(即从邮件接收端接收数据失败) 可能原因:邮件smtp服务出问题:或者接收邮件的邮箱smtp服务挂了 解决过程:先调试手动触发邮件,如果收不到,则更改邮件报警机制中的授权码,重新调试,发现可以正常发送了 总结:具体原因不清楚,等待后续如果再次报错:继续调试看看,持续更新~~ 原文地址:https://www.cnblogs.com/pingfanvb

rsyslog服务日志报错分析1

客户问题: 最近对服务器进行日志检查时,发现部分主机的rsyslog服务状态有报错,报错详情如下 排查过程: 1.从报错截图来看,报错主要发生在文件'/usr/lib64/rsyslog/omazuremds.so'上 2.经查询该文件模块是由LinuxDiagnostic 2.3的虚拟机扩张进行安装的,该扩展的安装位置见下 3.目前怀疑问题机器的LinuxDiagnostic 2.3扩展没有在机器上正确安装,或在虚拟机内部没能正常启动引起的报错 4.可以通过如下方法检查该扩展的正确性 a.在P

The SELECT would examine more than MAX_JOIN_SIZE rows 报错分析 MYSQL

用了一个联表查询一个大表,21 个字段,近四千万条记录吧.另一个表就几万的记录量. 报错误信息为: #1104 The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay. 分析的原因是: 1,临时表太小了.不能装下查询的中间集. 2,或者没有索引或设置的不好. 3