Hi all,
I wanted to export my value mappings to be able to import to other zabbix servers and not to manually create these maps.
I thought I succeeded, but there is an issue... Of course
When the zabbix delete some valuemap, then it erases from two tables - mappings and valuemaps.
Let's have an example that we deleted valuemap ID 100 with mappings ID 200 and ID 201.
valuemap ID 100, name "xxx"
- mapping 1->on, 2->off (200, 201)
After that, if I create a new valuemap, it doesn't have ID 100 (replacing deleted valuemap), but 101.
That means a problem for me, because my commands:
don't use the right ID, it is set to 100, but zabbix wants to use 101 through the GUI interface.
That means a problem for me, because I somehow don't handle PRIMARY keys correctly. And it happened that I couldn't add new valuemaps through the GUI until I deleted one mapping of one valuemap...
How can I import/export value mappings correctly? Is there any table with PRIMARY indexes? I think that "autoincrement" isn't set to mentioned tables...
Thanks!
Code example (only part of it):
I wanted to export my value mappings to be able to import to other zabbix servers and not to manually create these maps.
I thought I succeeded, but there is an issue... Of course

When the zabbix delete some valuemap, then it erases from two tables - mappings and valuemaps.
Let's have an example that we deleted valuemap ID 100 with mappings ID 200 and ID 201.
valuemap ID 100, name "xxx"
- mapping 1->on, 2->off (200, 201)
After that, if I create a new valuemap, it doesn't have ID 100 (replacing deleted valuemap), but 101.
That means a problem for me, because my commands:
Code:
select max(valuemapid) into @VAR from valuemaps; select max(mappingid) into @VAR2 from mappings;
That means a problem for me, because I somehow don't handle PRIMARY keys correctly. And it happened that I couldn't add new valuemaps through the GUI until I deleted one mapping of one valuemap...
How can I import/export value mappings correctly? Is there any table with PRIMARY indexes? I think that "autoincrement" isn't set to mentioned tables...
Thanks!
Code example (only part of it):
Code:
USE zabbix; LOCK TABLES `valuemaps` WRITE, `mappings` WRITE; SELECT MAX(valuemapid) INTO @my_valuemapid FROM valuemaps; SELECT MAX(mappingid) INTO @my_mappingid FROM mappings; INSERT INTO `valuemaps` VALUES (@my_valuemapid+1,'AAA'), (@my_valuemapid+2,'BBB'); INSERT INTO `mappings` VALUES (@my_mappingid+1,@my_valuemapid+1,'0','ONE'),(@my_mappingid+2,@my_valuemapid+1,'1','TWO'),(@my_mappingid+3,@my_valuemapid+1,'2','THREE'),(@my_mappingid+4,@my_valuemapid+1,'3','FOUR'), (@my_mappingid+5,@my_valuemapid+2,'0','FIVE'),(@my_mappingid+6,@my_valuemapid+2,'1','SIX'),(@my_mappingid+7,@my_valuemapid+2,'2','SEVEN'); UNLOCK TABLES;