修正Pangu输出配置命中结果功能中的越界写问题,HTTP监测功能初步调通。

This commit is contained in:
Lu Qiuwen
2018-09-23 20:02:07 +08:00
parent e128dba934
commit 0776cb3ec8
2 changed files with 482 additions and 474 deletions

View File

@@ -1,5 +1,3 @@
#include "pangu_logger.h"
#include <tfe_utils.h>
#include <cjson/cJSON.h>
#include <librdkafka/rdkafka.h>
@@ -15,6 +13,9 @@
#include <pthread.h>
#include <errno.h>
#include <tfe_utils.h>
#include "pangu_logger.h"
struct json_spec
{
const char *log_filed_name;
@@ -42,8 +43,6 @@ struct pangu_logger
char local_log_path[TFE_STRING_MAX];
};
static unsigned int get_ip_by_eth_name(const char *ifname)
{
int sockfd;
@@ -99,8 +98,6 @@ static rd_kafka_t * create_kafka_handle(const char* brokerlist)
return handle;
}
struct pangu_logger* pangu_log_handle_create(const char* profile, const char* section, void* local_logger)
{
int ret=-1;
@@ -218,7 +215,7 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
}
for(size_t i=0;i<sizeof(resp_fields)/sizeof(struct json_spec);i++)
{
tmp_val=_wrap_std_field_read(http->req, resp_fields[i].field_id);
tmp_val=_wrap_std_field_read(http->resp, resp_fields[i].field_id);
if(tmp_val!=NULL)
{
cJSON_AddStringToObject(common_obj,resp_fields[i].log_filed_name, tmp_val);
@@ -234,6 +231,8 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
cJSON_AddNumberToObject(per_hit_obj, "cfg_id", log_msg->result[i].config_id);
cJSON_AddNumberToObject(per_hit_obj, "service", log_msg->result[i].service_id);
log_payload = cJSON_Print(per_hit_obj);
fprintf(stderr, "%s\n", log_payload);
kafka_status = rd_kafka_produce(handle->kafka_topic, RD_KAFKA_PARTITION_UA, RD_KAFKA_MSG_F_COPY,
log_payload, strlen(log_payload), NULL, 0, NULL);
free(log_payload);
@@ -247,5 +246,3 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
cJSON_free(common_obj);
return 0;
}