diff --git a/src/common/args.c b/src/common/args.c index 6c82ec54c98b929bad423f3f80bb7f17ed194421..359502d04cce3c8e0d02e57c39eeb9f603dbaedb 100644 --- a/src/common/args.c +++ b/src/common/args.c @@ -17,7 +17,7 @@ #include #include #include - +#include "logs.h" #include "args.h" #define OUT_PUT_PERIOD_MAX (120) // 2mim @@ -68,7 +68,7 @@ static int __period_arg_parse(char opt, char *arg, struct probe_params *params) case 't': interval = (unsigned int)atoi(arg); if (interval < OUT_PUT_PERIOD_MIN || interval > OUT_PUT_PERIOD_MAX) { - printf("Please check arg(t), val shold inside 1~120.\n"); + ERROR("Please check arg(t), val shold inside 1~120.\n"); return -1; } params->period = interval; @@ -86,7 +86,7 @@ static int __period_arg_parse(char opt, char *arg, struct probe_params *params) case 'c': cport_flag = (unsigned int)atoi(arg); if (cport_flag != 0 && cport_flag != 1) { - printf("Please check arg(t), val shold be 1:cport_valid 0:cport_invalid.\n"); + ERROR("Please check arg(t), val shold be 1:cport_valid 0:cport_invalid.\n"); return -1; } params->cport_flag = (unsigned char)cport_flag; diff --git a/src/common/logs.cpp b/src/common/logs.cpp index fbdfcce6be31555eb5bf0fa9caa3f2f6cc08114c..3078dd1b706118e613a947cf6a9f0ba6d8a281e4 100644 --- a/src/common/logs.cpp +++ b/src/common/logs.cpp @@ -90,7 +90,7 @@ static int get_file_name(struct log_mgr_s* mgr, char is_metrics, int file_id, ch } if (path_len == 0) { - (void)fprintf(stderr, "Path is null.\n"); + ERROR("Get file_name failed, path is null.\n"); return -1; } @@ -132,7 +132,7 @@ static int en_queue(struct files_queue_s *files_que, int file_id, size_t len) { int pos; if (is_full_queue(files_que)) { - (void)fprintf(stderr, "Files queue is full.(front = %d, rear = %d)\n", files_que->front, files_que->rear); + ERROR("Files queue is full.(front = %d, rear = %d)\n", files_que->front, files_que->rear); return -1; } @@ -263,7 +263,7 @@ static char que_current_is_invalid(struct log_mgr_s *mgr, int is_metrics, int ma char full_path[PATH_LEN]; if (get_file_name(mgr, is_metrics, files_que->current.file_id, full_path, PATH_LEN)) { - (void)fprintf(stderr, "is current invalid fail(get file name).\n"); + ERROR("is current invalid fail(get file name).\n"); invalid = 1; goto out; } @@ -314,7 +314,7 @@ static int append_meta_logger(struct log_mgr_s * mgr) size_t path_len = strlen(mgr->meta_path); if (path_len == 0) { - (void)fprintf(stderr, "Meta path is null.\n"); + ERROR("Meta path is null.\n"); return -1; } @@ -339,7 +339,7 @@ static int append_raw_logger(struct log_mgr_s * mgr) { size_t path_len = strlen(mgr->raw_path); if (path_len == 0) { - (void)fprintf(stderr, "Raw path is null.\n"); + ERROR("Raw path is null.\n"); return -1; } @@ -362,7 +362,7 @@ static int append_debug_logger(struct log_mgr_s * mgr) size_t path_len = strlen(mgr->debug_path); if (path_len == 0) { - (void)fprintf(stderr, "Debug path is null.\n"); + ERROR("Debug path is null.\n"); return -1; } @@ -395,12 +395,12 @@ static int append_metrics_logger(struct log_mgr_s * mgr) char full_path[PATH_LEN]; if (que_get_next_file(mgr->metrics_files)) { - (void)fprintf(stderr, "Append metrics logger failed(get next file).\n"); + ERROR("Append metrics logger failed(get next file).\n"); return -1; } if (get_file_name(mgr, 1, mgr->metrics_files->current.file_id, full_path, PATH_LEN)) { - (void)fprintf(stderr, "Append metrics logger failed(get file name).\n"); + ERROR("Append metrics logger failed(get file name).\n"); return -1; } @@ -419,12 +419,12 @@ static int append_event_logger(struct log_mgr_s * mgr) char full_path[PATH_LEN]; if (que_get_next_file(mgr->event_files)) { - (void)fprintf(stderr, "Append event logger failed(get next file).\n"); + ERROR("Append event logger failed(get next file).\n"); return -1; } if (get_file_name(mgr, 0, mgr->event_files->current.file_id, full_path, PATH_LEN)) { - (void)fprintf(stderr, "Append event logger failed(get file name).\n"); + ERROR("Append event logger failed(get file name).\n"); return -1; } @@ -572,16 +572,18 @@ int read_metrics_logs(char logs_file_name[], size_t size) struct log_mgr_s *mgr = local; if (!mgr) { + ERROR("Read metrics_logs failed, mgr is null.\n"); return -1; } file_id = que_pop_file(mgr->metrics_files); if (!IS_VALID_FILE_ID(file_id)) { - (void)fprintf(stderr, "File id invalid(%d)!\n", file_id); + DEBUG("File id invalid(%d)!\n", file_id); return -1; } if (get_file_name(mgr, 1, file_id, logs_file_name, size)) { + ERROR("Read metrics_logs failed, get log's file_name failed.\n"); return -1; } return 0; @@ -611,16 +613,18 @@ int read_event_logs(char logs_file_name[], size_t size) struct log_mgr_s *mgr = local; if (!mgr) { + ERROR("Read event_logs failed, mgr is null.\n"); return -1; } file_id = que_pop_file(mgr->event_files); if (!IS_VALID_FILE_ID(file_id)) { - (void)fprintf(stderr, "File id invalid(%d)!\n", file_id); + DEBUG("File id invalid(%d)!\n", file_id); return -1; } if (get_file_name(mgr, 0, file_id, logs_file_name, size)) { + ERROR("Read event_logs failed, get log's file_name failed.\n"); return -1; } return 0; diff --git a/src/common/logs.h b/src/common/logs.h index aa0b592f10223621626919c815d15eb40a9f9d36..b85ee0bf750ff4f76dea11f918edbea6143000a5 100644 --- a/src/common/logs.h +++ b/src/common/logs.h @@ -21,13 +21,7 @@ extern "C" { #pragma once #include - -#if !defined(UTEST) #include "common.h" -#else -#define COMMAND_LEN 256 -#define PATH_LEN 256 -#endif #define LOGS_SWITCH_ON 1 diff --git a/src/common/tc_loader.c b/src/common/tc_loader.c index 8f603f6c0a3246832cba05a9e460bc36eb6b8076..6d24ec1339d51edbb3920e4f4d803abeefb76f3c 100644 --- a/src/common/tc_loader.c +++ b/src/common/tc_loader.c @@ -114,7 +114,7 @@ static int disable_one_netcard(const char *ethdev) return TC_ERR; } - printf("offload netcard[%s] tc bpf success\n", ethdev); + INFO("offload netcard[%s] tc bpf success\n", ethdev); return TC_OK; } @@ -123,7 +123,7 @@ static int enable_one_netcard(const char *ethdev) unsigned long i; int ret; if (netcard_enabled_the_tc_bpf(ethdev)) { - printf("netcard[%s] has already enabled tc bpf\n", ethdev); + WARN("netcard[%s] has already enabled tc bpf\n", ethdev); return TC_OK; } @@ -151,7 +151,7 @@ static int enable_one_netcard(const char *ethdev) } } - printf("load netcard[%s] tc bpf success\n", ethdev); + INFO("load netcard[%s] tc bpf success\n", ethdev); return TC_OK; clear: @@ -284,7 +284,7 @@ static int init_global(const char *tc_bpf_o, enum tc_type_e tc_type) void load_tc_bpf(char netcard_list[], const char *tc_bpf_o, enum tc_type_e tc_type) { if (init_global(tc_bpf_o, tc_type) < 0) { - printf("load no tc bpf"); + ERROR("load no tc bpf.\n"); return; } diff --git a/src/egress/egress.c b/src/egress/egress.c index 428c476cca09cd09919d5386ef0c079deba83f06..0935d822cbbf422845295bfd7cb37d0f6b9676cc 100644 --- a/src/egress/egress.c +++ b/src/egress/egress.c @@ -81,19 +81,19 @@ static int EgressInit(EgressMgr *mgr) m_event.data.ptr = mgr->metric_fifo; ret = epoll_ctl(mgr->epoll_fd, EPOLL_CTL_ADD, mgr->metric_fifo->triggerFd, &m_event); if (ret < 0) { - printf("[EGRESS] add EPOLLIN m_event failed.\n"); + ERROR("[EGRESS] add EPOLLIN m_event failed.\n"); return -1; } - printf("[EGRESS] add EGRESS METRIC FIFO trigger success.\n"); + INFO("[EGRESS] add EGRESS METRIC FIFO trigger success.\n"); e_event.events = EPOLLIN; e_event.data.ptr = mgr->event_fifo; ret = epoll_ctl(mgr->epoll_fd, EPOLL_CTL_ADD, mgr->event_fifo->triggerFd, &e_event); if (ret < 0) { - printf("[EGRESS] add EPOLLIN e_event failed.\n"); + ERROR("[EGRESS] add EPOLLIN e_event failed.\n"); return -1; } - printf("[EGRESS] add EGRESS EVENT FIFO trigger success.\n"); + INFO("[EGRESS] add EGRESS EVENT FIFO trigger success.\n"); return 0; } diff --git a/src/ingress/ingress.c b/src/ingress/ingress.c index f71119b0ac2f7ae7e9488dde24946ceff666010c..04c18e42efa0daf31f19aa9bccd5439c6f111484 100644 --- a/src/ingress/ingress.c +++ b/src/ingress/ingress.c @@ -62,11 +62,11 @@ static int IngressInit(IngressMgr *mgr) ret = epoll_ctl(mgr->epoll_fd, EPOLL_CTL_ADD, probe->fifo->triggerFd, &event); if (ret < 0) { - printf("[INGRESS] add EPOLLIN event failed, probe %s.\n", probe->name); + ERROR("[INGRESS] add EPOLLIN event failed, probe %s.\n", probe->name); return -1; } - printf("[INGRESS] Add EPOLLIN event success, probe %s.\n", probe->name); + INFO("[INGRESS] Add EPOLLIN event success, probe %s.\n", probe->name); } // add all extend probe triggerfd into mgr->epoll_fd @@ -78,11 +78,11 @@ static int IngressInit(IngressMgr *mgr) ret = epoll_ctl(mgr->epoll_fd, EPOLL_CTL_ADD, extendProbe->fifo->triggerFd, &event); if (ret < 0) { - printf("[INGRESS] add EPOLLIN event failed, extend probe %s.\n", extendProbe->name); + ERROR("[INGRESS] add EPOLLIN event failed, extend probe %s.\n", extendProbe->name); return -1; } - printf("[INGRESS] Add EPOLLIN event success, extend probe %s.\n", extendProbe->name); + INFO("[INGRESS] Add EPOLLIN event success, extend probe %s.\n", extendProbe->name); } return 0; diff --git a/src/lib/config/config.c b/src/lib/config/config.c index 803c17f42980b9a36850579f9d78abdd18efefc1..b2ae8982f19af47a61070828438ec7f695c030be 100644 --- a/src/lib/config/config.c +++ b/src/lib/config/config.c @@ -221,7 +221,7 @@ static int ConfigMgrLoadEgressConfig(void *config, config_setting_t *settings) ret = config_setting_lookup_int(settings, "time_range", &intVal); if (ret == 0) { - printf("[CONFIG] load config for egress time_range failed.\n"); + ERROR("[CONFIG] load config for egress time_range failed.\n"); return -1; } egressConfig->timeRange = intVal; diff --git a/src/probes/extends/ebpf.probe/src/endpointprobe/endpoint.c b/src/probes/extends/ebpf.probe/src/endpointprobe/endpoint.c index f25eebaab65252beb08813d44b7ca296579356d3..ef4c8c5e53c62f0ea602ae8d09f4ea80d05c33cc 100644 --- a/src/probes/extends/ebpf.probe/src/endpointprobe/endpoint.c +++ b/src/probes/extends/ebpf.probe/src/endpointprobe/endpoint.c @@ -65,7 +65,7 @@ static void print_tcp_listen_metrics(struct endpoint_val_t *value) "|%s|%d|%s|%d|%s|%lu|%lu|%lu|%lu|%lu|%lu|\n", LISTEN_TBL_NAME, value->key.key.tcp_listen_key.tgid, - "", + "*", value->key.key.tcp_listen_key.port, LISTEN_TBL_NAME, value->ep_stats.stats[EP_STATS_LISTEN_DROPS], @@ -141,7 +141,7 @@ static void build_entity_id(struct endpoint_val_t *ep, char *buf, int buf_len) if (ep->key.type == SK_TYPE_LISTEN_TCP) { (void)snprintf(buf, buf_len, "%d_%s_%d_%s", ep->key.key.tcp_listen_key.tgid, - "", + "*", ep->key.key.tcp_listen_key.port, LISTEN_TBL_NAME); } else if (ep->key.type == SK_TYPE_CLIENT_TCP) { diff --git a/src/probes/system_infos.probe/system_cpu.c b/src/probes/system_infos.probe/system_cpu.c index 4c5807fadb3eeace7c9bab21894424937b5b01db..4696bfe0182d7270dc6e0a5c743d842e3c528397 100644 --- a/src/probes/system_infos.probe/system_cpu.c +++ b/src/probes/system_infos.probe/system_cpu.c @@ -133,7 +133,7 @@ static int get_proc_stat_info(void) continue; } if (index >= cpus_num) { - printf("[SYSTEM_PROBE] cpu_probe records beyond max cpu nums(%d).\n", cpus_num); + ERROR("[SYSTEM_PROBE] cpu_probe records beyond max cpu nums(%d).\n", cpus_num); (void)fclose(f); return -1; } @@ -146,7 +146,7 @@ static int get_proc_stat_info(void) &cur_cpus[index]->cpu_irq_total_second, &cur_cpus[index]->cpu_softirq_total_second); if (ret < PROC_STAT_FILEDS_NUM) { - printf("system_cpu.probe faild get proc_stat metrics.\n"); + DEBUG("system_cpu.probe faild get proc_stat metrics.\n"); } index++; } @@ -227,15 +227,15 @@ static int get_softnet_stat_info(void) static int get_cpu_info(void) { if (get_softirq_info() < 0) { - printf("[SYSTEM_PROBE] fail to collect softirq info\n"); + ERROR("[SYSTEM_PROBE] fail to collect softirq info\n"); return -1; } if (get_proc_stat_info() < 0) { - printf("[SYSTEM_PROBE] fail to collect proc stat info\n"); + ERROR("[SYSTEM_PROBE] fail to collect proc stat info\n"); return -1; } if (get_softnet_stat_info() < 0) { - printf("[SYSTEM_PROBE] fail to collect softnet stat info\n"); + ERROR("[SYSTEM_PROBE] fail to collect softnet stat info\n"); return -1; } return 0; @@ -276,13 +276,13 @@ int system_cpu_init(void) { cpus_num = (int)sysconf(_SC_NPROCESSORS_CONF); if (cpus_num < 0 || cpus_num > MAX_CPU_NUM) { - printf("[SYSTEM_PROBE] sysconf to read the number of cpus error\n"); + ERROR("[SYSTEM_PROBE] sysconf to read the number of cpus error\n"); return -1; } cur_cpus = alloc_memory(); old_cpus = alloc_memory(); if (cur_cpus == NULL || old_cpus == NULL) { - printf("[SYSTEM_PROBE] fail alloc memory for cpu probe structure\n"); + ERROR("[SYSTEM_PROBE] fail alloc memory for cpu probe structure\n"); if (cur_cpus != NULL) { dealloc_memory(cur_cpus); cur_cpus = NULL; @@ -310,7 +310,7 @@ int system_cpu_probe(struct probe_params *params) struct cpu_stat *tmp_ptr; int ret; if (get_cpu_info()) { - printf("[SYSTEM_PROBE] fail to collect cpus info\n"); + ERROR("[SYSTEM_PROBE] fail to collect cpus info\n"); return -1; } if (is_first_get == true) { diff --git a/src/probes/system_infos.probe/system_disk.c b/src/probes/system_infos.probe/system_disk.c index ee0b4fdc578fcb2f3d14877714c267f1ed1ae82c..0c9bf0b54985399c288d9c0bcb1f0fcd017cf633 100644 --- a/src/probes/system_infos.probe/system_disk.c +++ b/src/probes/system_infos.probe/system_disk.c @@ -38,7 +38,7 @@ static int get_df_fields(char *line, df_stats *stats) &stats->fsname, &stats->fstype, &stats->inode_or_blk_sum, &stats->inode_or_blk_used, &stats->inode_or_blk_free, &stats->inode_or_blk_used_per, &stats->mount_on); if (ret < DF_FIELD_NUM) { - printf("[SYSTEM_DISK] get df stats fields fail.\n"); + DEBUG("[SYSTEM_DISK] get df stats fields fail.\n"); return -1; } return 0; @@ -166,7 +166,7 @@ static int get_diskstats_fields(const char *line, disk_stats *stats) &stats->disk_name, &stats->rd_ios, &stats->rd_sectors, &stats->rd_ticks, &stats->wr_ios, &stats->wr_sectors, &stats->wr_ticks, &stats->io_ticks, &stats->time_in_queue); if (ret < DISKSTAT_FIELD_NUM) { - printf("[SYSTEM_DISK] get disk stats fields fail.\n"); + DEBUG("[SYSTEM_DISK] get disk stats fields fail.\n"); return -1; } return 0; diff --git a/src/probes/system_infos.probe/system_infos.c b/src/probes/system_infos.probe/system_infos.c index b06fb4e6814ad7ccbea4ddccd2f685ac8986a5d4..b79a2923d1dbdbbc6a0279c2b8bf2a513e6ab5eb 100644 --- a/src/probes/system_infos.probe/system_infos.c +++ b/src/probes/system_infos.probe/system_infos.c @@ -83,37 +83,37 @@ int main(struct probe_params * params) for (;;) { ret = system_meminfo_probe(); if (ret < 0) { - printf("[SYSTEM_PROBE] system meminfo probe fail.\n"); + ERROR("[SYSTEM_PROBE] system meminfo probe fail.\n"); goto err; } ret = system_cpu_probe(params); if (ret < 0) { - printf("[SYSTEM_PROBE] system cpu probe fail.\n"); + ERROR("[SYSTEM_PROBE] system cpu probe fail.\n"); goto err; } ret = system_tcp_probe(); if (ret < 0) { - printf("[SYSTEM_PROBE] system tcp probe fail.\n"); + ERROR("[SYSTEM_PROBE] system tcp probe fail.\n"); goto err; } ret = system_net_probe(params); if (ret < 0) { - printf("[SYSTEM_PROBE] system net probe fail.\n"); + ERROR("[SYSTEM_PROBE] system net probe fail.\n"); goto err; } ret = system_disk_probe(params); if (ret < 0) { - printf("[SYSTEM_PROBE] system disk probe fail.\n"); + ERROR("[SYSTEM_PROBE] system disk probe fail.\n"); goto err; } ret = system_iostat_probe(params); if (ret < 0) { - printf("[SYSTEM_PROBE] system iostat probe fail.\n"); + ERROR("[SYSTEM_PROBE] system iostat probe fail.\n"); goto err; } ret = system_proc_probe(); if (ret < 0) { - printf("[SYSTEM_PROBE] system proc probe fail.\n"); + ERROR("[SYSTEM_PROBE] system proc probe fail.\n"); goto err; } sleep(params->period); diff --git a/src/probes/system_infos.probe/system_net.c b/src/probes/system_infos.probe/system_net.c index 9f3bd0f561d356331820698c1de54ab7eadd1810..0e0d7978791675bfb1b902d97429065802619657 100644 --- a/src/probes/system_infos.probe/system_net.c +++ b/src/probes/system_infos.probe/system_net.c @@ -37,7 +37,7 @@ static int get_netsnmp_fileds(const char *net_snmp_info, net_snmp_stat *stats) int ret; char *colon = strchr(net_snmp_info, ':'); if (colon == NULL) { - printf("[SYSTEM_NET] net_snmp not find symbol ':' \n"); + DEBUG("[SYSTEM_NET] net_snmp not find symbol ':' \n"); return -1; } *colon = '\0'; @@ -150,7 +150,7 @@ static int get_netdev_fileds(const char *net_dev_info, net_dev_stat *stats) &stats->rx_bytes, &stats->rx_packets, &stats->rx_errs, &stats->rx_dropped, &stats->tx_bytes, &stats->tx_packets, &stats->tx_errs, &stats->tx_dropped); if (ret < NETDEV_FIELD_NUM) { - printf("[SYSTEM_NET] system_net.probe faild get net_dev metrics.\n"); + DEBUG("[SYSTEM_NET] system_net.probe faild get net_dev metrics.\n"); return -1; } return 0; @@ -169,12 +169,12 @@ static int get_netdev_status(net_dev_stat *stats) (void)snprintf(cmd, COMMAND_LEN, SYSTEM_NET_DEV_STATUS, stats->dev_name); f = popen(cmd, "r"); if (f == NULL) { - printf("[SYSTEM_NET] ethtool dev(%s) failed, popen error.\n", stats->dev_name); + ERROR("[SYSTEM_NET] ethtool dev(%s) failed, popen error.\n", stats->dev_name); return -1; } line[0] = 0; if (fgets(line, LINE_BUF_LEN, f) == NULL) { - printf("[SYSTEM_NET] ethtool dev(%s) failed, line is NULL.\n", stats->dev_name); + ERROR("[SYSTEM_NET] ethtool dev(%s) failed, line is NULL.\n", stats->dev_name); (void)pclose(f); return -1; } @@ -197,12 +197,12 @@ static int do_read_qdisc_line(char *dev_name, char *keywords, char *filter, char (void)snprintf(cmd, COMMAND_LEN, fmt, SYSTEM_NET_QDISC_SHOW, dev_name, keywords, filter); f = popen(cmd, "r"); if (f == NULL) { - printf("[SYSTEM_NET] get net(%s) qdisc(%s) failed, popen error.\n", dev_name, keywords); + ERROR("[SYSTEM_NET] get net(%s) qdisc(%s) failed, popen error.\n", dev_name, keywords); return -1; } line[0] = 0; if (fgets(line, LINE_BUF_LEN, f) == NULL) { - printf("[SYSTEM_NET] get net(%s) qdisc(%s) failed, line is NULL.\n", dev_name, keywords); + ERROR("[SYSTEM_NET] get net(%s) qdisc(%s) failed, line is NULL.\n", dev_name, keywords); (void)pclose(f); return -1; } @@ -225,7 +225,7 @@ static int get_netdev_qdisc(net_dev_stat *stats) } ret = sscanf(line, "%d%*c%d",&stats->tc_sent_drop_count, &stats->tc_sent_overlimits_count); if (ret < QDISC_SENT_FILED_NUM) { - printf("[SYSTEM_NET] faild get qdisc sent metrics.\n"); + ERROR("[SYSTEM_NET] faild get qdisc sent metrics.\n"); return -1; } @@ -235,7 +235,7 @@ static int get_netdev_qdisc(net_dev_stat *stats) } ret = sscanf(line, "%d%*c",&stats->tc_backlog_count); if (ret < QDISC_BACKLOG_FIELD_NUM) { - printf("[SYSTEM_NET] faild get qdisc backlog metrics.\n"); + ERROR("[SYSTEM_NET] faild get qdisc backlog metrics.\n"); return -1; } @@ -354,7 +354,7 @@ int system_net_probe(struct probe_params *params) continue; } if (index > g_netdev_num) { - printf("[SYSTEM_NET] net_probe records beyond max netdev nums(%d).\n", g_netdev_num); + ERROR("[SYSTEM_NET] net_probe records beyond max netdev nums(%d).\n", g_netdev_num); continue; } (void)get_netdev_name(line, dev_name); diff --git a/src/probes/system_infos.probe/system_net.meta b/src/probes/system_infos.probe/system_net.meta index de7696edd5176bf494c3578a9e55d49e5f4f3144..05f492bd670a2d340cf31531fd5f74778f5740af 100644 --- a/src/probes/system_infos.probe/system_net.meta +++ b/src/probes/system_infos.probe/system_net.meta @@ -14,7 +14,7 @@ measurements: }, { description: "dev_status", - type: "key", + type: "label", name: "status", }, { diff --git a/src/probes/system_infos.probe/system_procs.c b/src/probes/system_infos.probe/system_procs.c index c7b05da68b21300eec184968cef73cb34d747d09..acedd5a836055f4406ab743c62143bfca1ca40c5 100644 --- a/src/probes/system_infos.probe/system_procs.c +++ b/src/probes/system_infos.probe/system_procs.c @@ -147,12 +147,12 @@ static int do_read_line(const char* pid, const char *command, const char *fname, (void)snprintf(fname_or_cmd, LINE_BUF_LEN, command, pid); f = popen(fname_or_cmd, "r"); if (f == NULL) { - printf("[SYSTEM_PROBE] proc cat fail, popen error.\n"); + ERROR("[SYSTEM_PROBE] proc cat fail, popen error.\n"); return -1; } if (fgets(line, LINE_BUF_LEN, f) == NULL) { (void)pclose(f); - printf("[SYSTEM_PROBE] proc get_info fail, line is null.\n"); + ERROR("[SYSTEM_PROBE] proc get_info fail, line is null.\n"); return -1; } @@ -242,7 +242,7 @@ static void get_java_proc_cmd(const char* pid, proc_info_t *proc_info) char cmd[LINE_BUF_LEN]; char line[LINE_BUF_LEN]; if (is_jinfo_installed() == JINFO_NOT_INSTALLED) { - printf("[SYSTEM_PROBE] jinfo not installed, please check.\n"); + ERROR("[SYSTEM_PROBE] jinfo not installed, please check.\n"); return; } cmd[0] = 0; diff --git a/src/web_server/web_server.c b/src/web_server/web_server.c index 775c9a54c412f5eb4128e4b96c48a35fc45cea03..0aa8fedf8b5ff9c81548dbedac3c50716fc91aac 100644 --- a/src/web_server/web_server.c +++ b/src/web_server/web_server.c @@ -63,13 +63,12 @@ static int WebRequestCallback(void *cls, } if (ReadMetricsLogs(log_file_name) < 0) { - fprintf(stderr, "Failed to get metric log filename.\n"); return MHD_NO; } fd = open(log_file_name, O_RDONLY); if (fd < 0) { - fprintf(stderr, "Failed to open '%s': %s\n", log_file_name, strerror(errno)); + ERROR("Failed to open '%s': %s\n", log_file_name, strerror(errno)); return MHD_NO; } if ((fstat(fd, &buf) == -1) || !S_ISREG(buf.st_mode)) {