Recently we had a crash of our Zabbix database server. We lost some data but we were able to locate the missing entries. It's in the 'item_discovery' table.
For example: Theres the template "Template SNMP Interfaces" (ID: 10060) with a discovery rule "Network interfaces" (ID: 22700). But it looks like all item and trigger prototypes are gone:

I was able to find them in the 'items' table by searching for the id 10060:
No result by searching in the 'item_discovery' table for a 'parent_itemid' 22700:
So I created a new entry for the item prototype "Description of interface" (ID: 22703) related to the discovery rule (ID: 22700):
Et voilĂ , the item prototype is restored and again viewable in the frontend:

There's the same problem fore some hosts, too. The previously discovered item isn't anymore related to the discovery rule (golden link) and by clicking on it, there's an error:

I was also able to insert the relation in the 'item_discovery' table and the golden link was restored, but yeah... It's a lot of work to fix the lost relations. Is there a way to fix that automatically or recreate/regenerate the 'item_discovery' table?
Thanks
For example: Theres the template "Template SNMP Interfaces" (ID: 10060) with a discovery rule "Network interfaces" (ID: 22700). But it looks like all item and trigger prototypes are gone:

I was able to find them in the 'items' table by searching for the id 10060:
Code:
zabbix=> select itemid, name, key_ from items where hostid=10060;
itemid | name | key_
--------+------------------------------------+-----------------------------
22709 | Number of network interfaces | ifNumber
22703 | Description of interface $1 | ifDescr[{#SNMPVALUE}]
22708 | Alias of interface $1 | ifAlias[{#SNMPVALUE}]
22702 | Outgoing traffic on interface $1 | ifOutOctets[{#SNMPVALUE}]
22706 | Inbound errors on interface $1 | ifInErrors[{#SNMPVALUE}]
22705 | Admin status of interface $1 | ifAdminStatus[{#SNMPVALUE}]
22701 | Incoming traffic on interface $1 | ifInOctets[{#SNMPVALUE}]
22704 | Operational status of interface $1 | ifOperStatus[{#SNMPVALUE}]
22700 | Network interfaces | discovery.ifName
22707 | Outbound errors on interface $1 | ifOutErrors[{#SNMPVALUE}]
31045 | Type of interface $1 | ifType[{#SNMPVALUE}]
(11 rows)
Code:
zabbix=> select * from item_discovery where parent_itemid=22700; itemdiscoveryid | itemid | parent_itemid | key_ | lastcheck | ts_delete -----------------+--------+---------------+------+-----------+----------- (0 rows)
Code:
zabbix=> insert into item_discovery (itemid, parent_itemid) values (22703, 22700); INSERT 0 1

There's the same problem fore some hosts, too. The previously discovered item isn't anymore related to the discovery rule (golden link) and by clicking on it, there's an error:

I was also able to insert the relation in the 'item_discovery' table and the golden link was restored, but yeah... It's a lot of work to fix the lost relations. Is there a way to fix that automatically or recreate/regenerate the 'item_discovery' table?
Thanks