Closed jrbeilke closed 7 years ago
So it's not just items that are affected by this, but anything that requires more than a single field to be identified properly in Zabbix when using templates, like:
The Graphs class already overrides create_or_update() to be more specific, so it seems like we need something similar added to the other classes.
def create_or_update(data)
graphid = get_id(:name => data[:name], :templateid => data[:templateid])
graphid ? _update(data.merge(:graphid => graphid)) : create(data)
end
We're using zabbixapi to keep our Zabbix templates in-sync and up-to-date, but we're having an issue when trying to use create_or_update() on templated items.
Here's the code we're using to create/update one of the items on our templates:
Looks like create_or_update() makes a call to get_id() to find the itemid, but the filter on that query is not specific enough to only pull the itemid attached to the template. Instead get_id() pulls the itemid from one of the hosts linked to the template instead, since the item gets copied to the hosts using that template.