From 4cf7357a227c521412cc270162130d9c2250932f Mon Sep 17 00:00:00 2001 From: hxy7yx <1595670487@qq.com> Date: Wed, 26 Jul 2023 17:17:45 +0800 Subject: [PATCH] Log optimization --- src/adapter/storage.c | 2 +- src/persist/persist.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/adapter/storage.c b/src/adapter/storage.c index e176d6cee..030152c62 100644 --- a/src/adapter/storage.c +++ b/src/adapter/storage.c @@ -125,7 +125,7 @@ int adapter_load_setting(const char *node, char **setting) { int rv = neu_persister_load_node_setting(node, (const char **) setting); if (0 != rv) { - nlog_error("load %s setting fail", node); + nlog_warn("load %s setting fail", node); return -1; } diff --git a/src/persist/persist.c b/src/persist/persist.c index f93c7f88c..bb38a09fe 100644 --- a/src/persist/persist.c +++ b/src/persist/persist.c @@ -599,11 +599,20 @@ void neu_persister_destroy() int neu_persister_store_node(neu_persist_node_info_t *info) { - int rv = - execute_sql(global_db, - "INSERT INTO nodes (name, type, state, plugin_name) " - "VALUES (%Q, %i, %i, %Q)", - info->name, info->type, info->state, info->plugin_name); + int rv = 0; + if (strcmp(info->plugin_name, "Monitor") == 0) { + rv = execute_sql( + global_db, + "INSERT OR IGNORE INTO nodes (name, type, state, plugin_name) " + "VALUES (%Q, %i, %i, %Q)", + info->name, info->type, info->state, info->plugin_name); + } else { + rv = + execute_sql(global_db, + "INSERT INTO nodes (name, type, state, plugin_name) " + "VALUES (%Q, %i, %i, %Q)", + info->name, info->type, info->state, info->plugin_name); + } if (0 == rv) { node_count_add(1); }