diff options
author | Andrejs Kozlovs <andrejs.kozlovs@zabbix.com> | 2022-03-02 15:47:06 +0300 |
---|---|---|
committer | Andrejs Kozlovs <andrejs.kozlovs@zabbix.com> | 2022-03-02 15:51:10 +0300 |
commit | 3afda2e67cb9d4da28e2df0b923c7572bd9fed22 (patch) | |
tree | 29d36089f248f5e8c17fcea538dd8fffe5a19625 | |
parent | 6f511438414426a8511cb9a1604f57d01c01723e (diff) |
........S. [ZBX-19965] fixed database upgrade for SNMP interfaces
Merge in ZBX/zabbix from feature/ZBX-19965-5.0 to release/5.0
* commit '8428e686d25219411878f1a7fe6b147d183ff964':
........S. [ZBX-19965] fixed database upgrade for SNMP interfaces
(cherry picked from commit 95f3ea21166c3bdf1e024fbe22888e289971c3ef)
-rw-r--r-- | ChangeLog.d/bugfix/ZBX-19965 | 1 | ||||
-rw-r--r-- | src/libs/zbxdbupgrade/dbupgrade_4050.c | 16 |
2 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog.d/bugfix/ZBX-19965 b/ChangeLog.d/bugfix/ZBX-19965 new file mode 100644 index 00000000000..416058f981c --- /dev/null +++ b/ChangeLog.d/bugfix/ZBX-19965 @@ -0,0 +1 @@ +........S. [ZBX-19965] fixed database upgrade for SNMP interfaces (akozlovs) diff --git a/src/libs/zbxdbupgrade/dbupgrade_4050.c b/src/libs/zbxdbupgrade/dbupgrade_4050.c index 4a941def487..eeadac4ad67 100644 --- a/src/libs/zbxdbupgrade/dbupgrade_4050.c +++ b/src/libs/zbxdbupgrade/dbupgrade_4050.c @@ -1043,14 +1043,22 @@ static int DBpatch_items_update(zbx_vector_dbu_snmp_if_t *snmp_ifs) for (i = 0; i < snmp_ifs->values_num && SUCCEED == ret; i++) { + int item_type; dbu_snmp_if_t *s = &snmp_ifs->values[i]; + if (ZBX_IF_SNMP_VERSION_1 == s->version) + item_type = ITEM_TYPE_SNMPv1; + else if (ZBX_IF_SNMP_VERSION_2 == s->version) + item_type = ITEM_TYPE_SNMPv2c; + else + item_type = ITEM_TYPE_SNMPv3; + zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, #ifdef HAVE_ORACLE "update items i set type=%d, interfaceid=" ZBX_FS_UI64 " where exists (select 1 from hosts h" " where i.hostid=h.hostid and" - " i.type in (%d,%d,%d) and h.status <> 3 and" + " i.type=%d and h.status <> 3 and" " i.interfaceid=" ZBX_FS_UI64 " and" " (('%s' is null and i.snmp_community is null) or" " i.snmp_community='%s') and" @@ -1067,7 +1075,7 @@ static int DBpatch_items_update(zbx_vector_dbu_snmp_if_t *snmp_ifs) " i.snmpv3_contextname='%s') and" " (('%s' is null and i.port is null) or" " i.port='%s'));\n", - ITEM_TYPE_SNMP, s->interfaceid, ITEM_TYPE_SNMPv1, ITEM_TYPE_SNMPv2c, ITEM_TYPE_SNMPv3, + ITEM_TYPE_SNMP, s->interfaceid, item_type, s->item_interfaceid, s->community, s->community, s->securityname, s->securityname, (int)s->securitylevel, s->authpassphrase, s->authpassphrase, s->privpassphrase, s->privpassphrase, (int)s->authprotocol, (int)s->privprotocol, s->contextname, @@ -1080,7 +1088,7 @@ static int DBpatch_items_update(zbx_vector_dbu_snmp_if_t *snmp_ifs) "update items i set type=%d, interfaceid=" ZBX_FS_UI64 " from hosts h" # endif " where i.hostid=h.hostid and" - " type in (%d,%d,%d) and h.status <> 3 and" + " type=%d and h.status <> 3 and" " interfaceid=" ZBX_FS_UI64 " and" " snmp_community='%s' and" " snmpv3_securityname='%s' and" @@ -1092,7 +1100,7 @@ static int DBpatch_items_update(zbx_vector_dbu_snmp_if_t *snmp_ifs) " snmpv3_contextname='%s' and" " port='%s';\n", ITEM_TYPE_SNMP, s->interfaceid, - ITEM_TYPE_SNMPv1, ITEM_TYPE_SNMPv2c, ITEM_TYPE_SNMPv3, + item_type, s->item_interfaceid, s->community, s->securityname, (int)s->securitylevel, s->authpassphrase, s->privpassphrase, (int)s->authprotocol, (int)s->privprotocol, s->contextname, s->item_port); |