Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitrijs Goloscapovs <dmitrijs.goloscapovs@zabbix.com>2022-06-20 03:52:21 +0300
committerDmitrijs Goloscapovs <dmitrijs.goloscapovs@zabbix.com>2022-06-20 03:52:21 +0300
commiteca08a567e24f3a7421c4135957e0a0c59f702a3 (patch)
tree558ae4c533e874ae7017b8c9cb70524e779a81a2
parentb67764696352d70cce264e7aa315a585104180de (diff)
.......PS. [ZBX-20638] refactored x2
-rw-r--r--include/db.h2
-rw-r--r--include/zbxdb.h2
-rw-r--r--src/libs/zbxdb/db.c76
-rw-r--r--src/libs/zbxdbhigh/db.c75
-rw-r--r--src/zabbix_proxy/proxy.c2
-rw-r--r--src/zabbix_server/server.c2
6 files changed, 79 insertions, 80 deletions
diff --git a/include/db.h b/include/db.h
index 0a229773850..e2a192fd56c 100644
--- a/include/db.h
+++ b/include/db.h
@@ -945,4 +945,6 @@ void zbx_db_trigger_get_itemids(const DB_TRIGGER *trigger, zbx_vector_uint64_t *
int DBselect_ids_names(const char *sql, zbx_vector_uint64_t *ids, zbx_vector_str_t *names);
+int DBcheck_version_info(struct zbx_db_version_info_t *info, int allow_unsupported);
+
#endif
diff --git a/include/zbxdb.h b/include/zbxdb.h
index acfc12a6977..751ccc969d0 100644
--- a/include/zbxdb.h
+++ b/include/zbxdb.h
@@ -240,6 +240,4 @@ void zbx_db_version_json_create(struct zbx_json *json, struct zbx_db_version_inf
void zbx_db_set_character_set(const char *char_set);
#endif
-int zbx_check_db_version_info(struct zbx_db_version_info_t *info);
-
#endif
diff --git a/src/libs/zbxdb/db.c b/src/libs/zbxdb/db.c
index 71f452f0100..0ec070cea26 100644
--- a/src/libs/zbxdb/db.c
+++ b/src/libs/zbxdb/db.c
@@ -21,7 +21,6 @@
#include "log.h"
#include "zbxdb.h"
-#include "db.h"
#if defined(HAVE_MYSQL)
# include "mysql.h"
@@ -72,12 +71,9 @@ static int txn_end_error = ZBX_DB_OK; /* transaction result */
static char *last_db_strerror = NULL; /* last database error message */
extern int CONFIG_LOG_SLOW_QUERIES;
-extern int CONFIG_ALLOW_UNSUPPORTED_DB_VERSIONS;
static int db_auto_increment;
-extern unsigned char program_type;
-
#if defined(HAVE_MYSQL)
static MYSQL *conn = NULL;
static zbx_uint32_t ZBX_MYSQL_SVERSION = ZBX_DBVERSION_UNDEFINED;
@@ -2500,78 +2496,6 @@ int zbx_db_version_check(const char *database, zbx_uint32_t current_version, zbx
return flag;
}
-/*********************************************************************************
- * *
- * Purpose: verify that Zabbix server/proxy will start with provided DB version *
- * and configuration *
- * *
- *********************************************************************************/
-int zbx_check_db_version_info(struct zbx_db_version_info_t *info)
-{
- DBextract_version_info(info);
-
- if (DB_VERSION_NOT_SUPPORTED_ERROR == info->flag ||
- DB_VERSION_HIGHER_THAN_MAXIMUM == info->flag || DB_VERSION_LOWER_THAN_MINIMUM == info->flag)
- {
- const char *program_type_s;
-
- program_type_s = get_program_type_string(program_type);
-
- if (0 == CONFIG_ALLOW_UNSUPPORTED_DB_VERSIONS || (DB_VERSION_LOWER_THAN_MINIMUM == info->flag &&
- 0 == (program_type & ZBX_PROGRAM_TYPE_PROXY)
- && 1 == CONFIG_ALLOW_UNSUPPORTED_DB_VERSIONS))
- {
- zabbix_log(LOG_LEVEL_ERR, " ");
- zabbix_log(LOG_LEVEL_ERR, "Unable to start Zabbix %s due to unsupported %s database"
- " version (%s).", program_type_s, info->database,
- info->friendly_current_version);
-
- if (DB_VERSION_HIGHER_THAN_MAXIMUM == info->flag)
- {
- zabbix_log(LOG_LEVEL_ERR, "Must not be higher than (%s).",
- info->friendly_max_version);
- info->flag = DB_VERSION_HIGHER_THAN_MAXIMUM_ERROR;
- }
- else
- {
- zabbix_log(LOG_LEVEL_ERR, "Must be at least (%s).",
- info->friendly_min_supported_version);
- }
-
- zabbix_log(LOG_LEVEL_ERR, "Use of supported database version is highly recommended.");
- zabbix_log(LOG_LEVEL_ERR, "Override by setting AllowUnsupportedDBVersions=1"
- " in Zabbix %s configuration file at your own risk.", program_type_s);
- zabbix_log(LOG_LEVEL_ERR, " ");
-
- return FAIL;
- }
- else
- {
- zabbix_log(LOG_LEVEL_ERR, " ");
- zabbix_log(LOG_LEVEL_ERR, "Warning! Unsupported %s database version (%s).",
- info->database, info->friendly_current_version);
-
- if (DB_VERSION_HIGHER_THAN_MAXIMUM == info->flag)
- {
- zabbix_log(LOG_LEVEL_ERR, "Should not be higher than (%s).",
- info->friendly_max_version);
- info->flag = DB_VERSION_HIGHER_THAN_MAXIMUM_WARNING;
- }
- else
- {
- zabbix_log(LOG_LEVEL_ERR, "Should be at least (%s).",
- info->friendly_min_supported_version);
- info->flag = DB_VERSION_NOT_SUPPORTED_WARNING;
- }
-
- zabbix_log(LOG_LEVEL_ERR, "Use of supported database version is highly recommended.");
- zabbix_log(LOG_LEVEL_ERR, " ");
- }
- }
-
- return SUCCEED;
-}
-
/******************************************************************************
* *
* Purpose: prepare json for front-end with the DB current, minimum and *
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index f0481b3b6ad..509966688fd 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -820,6 +820,81 @@ void DBflush_version_requirements(const char *version)
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
}
+/*********************************************************************************
+ * *
+ * Purpose: verify that Zabbix server/proxy will start with provided DB version *
+ * and configuration *
+ * *
+ * Parameters: allow_unsupported - [IN] value of AllowUnsupportedDBVersions flag *
+ * *
+ *********************************************************************************/
+int DBcheck_version_info(struct zbx_db_version_info_t *info, int allow_unsupported)
+{
+ DBextract_version_info(info);
+
+ if (DB_VERSION_NOT_SUPPORTED_ERROR == info->flag ||
+ DB_VERSION_HIGHER_THAN_MAXIMUM == info->flag || DB_VERSION_LOWER_THAN_MINIMUM == info->flag)
+ {
+ const char *program_type_s;
+
+ program_type_s = get_program_type_string(program_type);
+
+ if (0 == allow_unsupported || (DB_VERSION_LOWER_THAN_MINIMUM == info->flag &&
+ 0 == (program_type & ZBX_PROGRAM_TYPE_PROXY)
+ && 1 == allow_unsupported))
+ {
+ zabbix_log(LOG_LEVEL_ERR, " ");
+ zabbix_log(LOG_LEVEL_ERR, "Unable to start Zabbix %s due to unsupported %s database"
+ " version (%s).", program_type_s, info->database,
+ info->friendly_current_version);
+
+ if (DB_VERSION_HIGHER_THAN_MAXIMUM == info->flag)
+ {
+ zabbix_log(LOG_LEVEL_ERR, "Must not be higher than (%s).",
+ info->friendly_max_version);
+ info->flag = DB_VERSION_HIGHER_THAN_MAXIMUM_ERROR;
+ }
+ else
+ {
+ zabbix_log(LOG_LEVEL_ERR, "Must be at least (%s).",
+ info->friendly_min_supported_version);
+ }
+
+ zabbix_log(LOG_LEVEL_ERR, "Use of supported database version is highly recommended.");
+ zabbix_log(LOG_LEVEL_ERR, "Override by setting AllowUnsupportedDBVersions=1"
+ " in Zabbix %s configuration file at your own risk.", program_type_s);
+ zabbix_log(LOG_LEVEL_ERR, " ");
+
+ return FAIL;
+ }
+ else
+ {
+ zabbix_log(LOG_LEVEL_ERR, " ");
+ zabbix_log(LOG_LEVEL_ERR, "Warning! Unsupported %s database version (%s).",
+ info->database, info->friendly_current_version);
+
+ if (DB_VERSION_HIGHER_THAN_MAXIMUM == info->flag)
+ {
+ zabbix_log(LOG_LEVEL_ERR, "Should not be higher than (%s).",
+ info->friendly_max_version);
+ info->flag = DB_VERSION_HIGHER_THAN_MAXIMUM_WARNING;
+ }
+ else
+ {
+ zabbix_log(LOG_LEVEL_ERR, "Should be at least (%s).",
+ info->friendly_min_supported_version);
+ info->flag = DB_VERSION_NOT_SUPPORTED_WARNING;
+ }
+
+ zabbix_log(LOG_LEVEL_ERR, "Use of supported database version is highly recommended.");
+ zabbix_log(LOG_LEVEL_ERR, " ");
+ }
+ }
+
+ return SUCCEED;
+}
+
+
/******************************************************************************
* *
* Purpose: checks DBMS for optional features and exit if is not suitable *
diff --git a/src/zabbix_proxy/proxy.c b/src/zabbix_proxy/proxy.c
index e4123ae245d..650ce7eb359 100644
--- a/src/zabbix_proxy/proxy.c
+++ b/src/zabbix_proxy/proxy.c
@@ -1040,7 +1040,7 @@ static void zbx_check_db(void)
{
struct zbx_db_version_info_t db_version_info;
- if (FAIL == zbx_check_db_version_info(&db_version_info))
+ if (FAIL == DBcheck_version_info(&db_version_info, CONFIG_ALLOW_UNSUPPORTED_DB_VERSIONS))
{
zbx_free(db_version_info.friendly_current_version);
exit(EXIT_FAILURE);
diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c
index dcf220bf3ca..e9647901308 100644
--- a/src/zabbix_server/server.c
+++ b/src/zabbix_server/server.c
@@ -1094,7 +1094,7 @@ static void zbx_check_db(void)
struct zbx_json db_version_json;
int result = SUCCEED;
- result = zbx_check_db_version_info(&db_version_info);
+ result = DBcheck_version_info(&db_version_info, CONFIG_ALLOW_UNSUPPORTED_DB_VERSIONS);
if(SUCCEED == result && (SUCCEED != DBcheck_capabilities(db_version_info.current_version) ||
SUCCEED != DBcheck_version()))