/****************************************************************************** * * * Function: process_httptests * * * * Purpose: process httptests * * * * Parameters: now - current timestamp * * * * Return value: * * * * Author: Alexei Vladishev * * * * Comments: always SUCCEED * * * ******************************************************************************/ void process_httptests(int httppoller_num, int now) { const char *__function_name = "process_httptests"; DB_RESULT result; DB_ROW row; DB_HTTPTEST httptest; zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name); result = DBselect( "select t.httptestid,t.name,t.applicationid,t.nextcheck,t.status," "t.macros,t.agent,t.authentication,t.http_user,t.http_password" " from httptest t,applications a,hosts h" " where t.applicationid=a.applicationid" " and a.hostid=h.hostid" " and t.nextcheck<=%d" " and " ZBX_SQL_MOD(t.httptestid,%d) "=%d" " and t.status=%d" " and h.status=%d" " and (h.maintenance_status=%d or h.maintenance_type=%d)" DB_NODE, now, CONFIG_HTTPPOLLER_FORKS, httppoller_num - 1, HTTPTEST_STATUS_MONITORED, HOST_STATUS_MONITORED, HOST_MAINTENANCE_STATUS_OFF, MAINTENANCE_TYPE_NORMAL, DBnode_local("t.httptestid")); while (NULL != (row = DBfetch(result))) { ZBX_STR2UINT64(httptest.httptestid, row[0]); httptest.name = row[1]; ZBX_STR2UINT64(httptest.applicationid, row[2]); httptest.nextcheck = atoi(row[3]); httptest.status = atoi(row[4]); httptest.macros = row[5]; httptest.agent = row[6]; httptest.authentication = atoi(row[7]); httptest.http_user = row[8]; httptest.http_password = row[9]; process_httptest(&httptest); } DBfree_result(result); zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name); }
/****************************************************************************** * * * Function: process_httptests * * * * Purpose: process httptests * * * * Parameters: now - current timestamp * * * * Return value: * * * * Author: Alexei Vladishev * * * * Comments: always SUCCEED * * * ******************************************************************************/ int process_httptests(int httppoller_num, int now) { const char *__function_name = "process_httptests"; DB_RESULT result; DB_ROW row; zbx_httptest_t httptest; DC_HOST host; int httptests_count = 0; zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name); /* create macro cache to use in http tests */ zbx_vector_ptr_pair_create(&httptest.macros); result = DBselect( "select h.hostid,h.host,h.name,t.httptestid,t.name,t.variables,t.agent," "t.authentication,t.http_user,t.http_password,t.http_proxy,t.retries" " from httptest t,hosts h" " where t.hostid=h.hostid" " and t.nextcheck<=%d" " and " ZBX_SQL_MOD(t.httptestid,%d) "=%d" " and t.status=%d" " and h.proxy_hostid is null" " and h.status=%d" " and (h.maintenance_status=%d or h.maintenance_type=%d)" ZBX_SQL_NODE, now, CONFIG_HTTPPOLLER_FORKS, httppoller_num - 1, HTTPTEST_STATUS_MONITORED, HOST_STATUS_MONITORED, HOST_MAINTENANCE_STATUS_OFF, MAINTENANCE_TYPE_NORMAL, DBand_node_local("t.httptestid")); while (NULL != (row = DBfetch(result))) { ZBX_STR2UINT64(host.hostid, row[0]); strscpy(host.host, row[1]); strscpy(host.name, row[2]); ZBX_STR2UINT64(httptest.httptest.httptestid, row[3]); httptest.httptest.name = row[4]; httptest.httptest.variables = zbx_strdup(NULL, row[5]); substitute_simple_macros(NULL, NULL, NULL, NULL, NULL, &host, NULL, &httptest.httptest.variables, MACRO_TYPE_HTTPTEST_FIELD, NULL, 0); httptest.httptest.agent = zbx_strdup(NULL, row[6]); substitute_simple_macros(NULL, NULL, NULL, NULL, &host.hostid, NULL, NULL, &httptest.httptest.agent, MACRO_TYPE_COMMON, NULL, 0); if (HTTPTEST_AUTH_NONE != (httptest.httptest.authentication = atoi(row[7]))) { httptest.httptest.http_user = zbx_strdup(NULL, row[8]); substitute_simple_macros(NULL, NULL, NULL, NULL, &host.hostid, NULL, NULL, &httptest.httptest.http_user, MACRO_TYPE_COMMON, NULL, 0); httptest.httptest.http_password = zbx_strdup(NULL, row[9]); substitute_simple_macros(NULL, NULL, NULL, NULL, &host.hostid, NULL, NULL, &httptest.httptest.http_password, MACRO_TYPE_COMMON, NULL, 0); } httptest.httptest.http_proxy = zbx_strdup(NULL, row[10]); substitute_simple_macros(NULL, NULL, NULL, NULL, &host.hostid, NULL, NULL, &httptest.httptest.http_proxy, MACRO_TYPE_COMMON, NULL, 0); httptest.httptest.retries = atoi(row[11]); /* add httptest varriables to the current test macro cache */ http_process_variables(&httptest, httptest.httptest.variables, NULL, NULL); process_httptest(&host, &httptest); zbx_free(httptest.httptest.http_proxy); if (HTTPTEST_AUTH_NONE != httptest.httptest.authentication) { zbx_free(httptest.httptest.http_password); zbx_free(httptest.httptest.http_user); } zbx_free(httptest.httptest.agent); zbx_free(httptest.httptest.variables); /* clear the macro cache used in this http test */ httptest_remove_macros(&httptest); httptests_count++; /* performance metric */ } /* destroy the macro cache used in http tests */ zbx_vector_ptr_pair_destroy(&httptest.macros); DBfree_result(result); zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name); return httptests_count; }