See www.zabbix.com for the official Zabbix site.

Docs/specs/ZBXNEXT-219

From Zabbix.org
Jump to: navigation, search

Ability to remove resources missing in XML file

ZBXNEXT-219

Status: v1.2

Owner: Alexei

Summary

A new option 'Delete missing' will make updating of existing hosts and templates much easier. Copying of a template from test to production is a typical use case.

Details

Third column 'Delete missing' will be introduced in XML import screen. It will be unchecked by default and available for:

 Template screens
 Applications
 Items
 Discovery rules
 Triggers
 Graphs

If the option is selected then objects missing in XML file will be removed from Zabbix database.

Enabling this option will delete only objects from the imported hosts. For example: if we have two hosts: H1 and H2 and a trigger that belongs to both hosts. When we export H1 and import it back using this option, only triggers on H1 will be removed. Even though the XML file contains a trigger from H2, its triggers will not be removed, since H2 itself is not present in the XML file.

Objects discovered by LLD rules will not be affected by this option.

If at least one of the checkboxes is enabled, a confirmation pop up will appear when clicking "Import" saying: "Delete all elements that are not present in the XML file?"

To avoid confusion caused by using the word "missing" in two columns, the "Add missing" column will be renamed to "Create new".

Process order

Missing objects will be deleted before any other objects are imported. Otherwise, the following situation might occur:

  1. We export a host with two items and a graph that uses these two items.
  2. We remove one of the items from the XML file and import it back with the "delete missing" checkbox checked for items. The XML is imported and the item is removed. Note, that the graph will be imported, but only with one item.
  3. We import the XML file again with the same parameters as in the previous step. Now it will fail because the graph references an item which does not exist.

Deleting objects before importing anything else will allow us to fail when other imported objects reference them.

Applications

To implement this functionality for applications, a new row will be added to the import form before the "Items" row: "Applications" with two checkboxes for creating and deleting applications. The create checkbox must be checked by default when importing templates and hosts.

API changes

configuration.import

A "deleteMissing" parameter will be added for the following configuration.import parameters: "templateScreens", "applications", "items", "discoveryRules", "triggers" and "graphs".

Translation strings

New strings

  • Create new
  • Delete missing
  • Delete all elements that are not present in the XML file?

Removed strings

  • Add missing

Documentation

  • What's new in 2.4
  • XML Import section

Also discussed

The option is introduced for template and host resources only. It's too dangerous to introduce it for hosts/templates and higher-level objects.

ChangeLog

  • v1.1
    • added a confirmation message
    • renamed "Remove if missing in XML" to "Delete missing" and "Add missing" to "Create new"
  • v1.2
    • add a new "Applications" row to the import form