This is a translation of the original English documentation page. Help us make it better.

configuration.importcompare

Leírás

array configuration.importcompare(object parameters)

Ez a módszer lehetővé teszi az importfájl összehasonlítását a jelenlegi rendszerelemekkel és megmutatja, hogy mi fog megváltozni, ha ezt az importfájlt importálják.

Ez a módszer bármilyen típusú felhasználó számára elérhető. Engedélyek A metódus meghívása a felhasználói szerepkör beállításaiban visszavonható. Lásd: User roles további információért.

Parameters

(object) Parameters containing the possible data to import and rules how the data should be handled.

Parameter Type Description
format
(required)
string Format of the serialized string.

Possible values:
yaml - YAML;
xml - XML;
json - JSON.
source
(required)
string Serialized string containing the configuration data.
rules
(required)
object Rules on how new and existing objects should be imported.

The rules parameter is described in detail in the table below.

If no rules are given, there will be nothing to update and result will be empty.

Comparison will be done only for host groups and templates. Triggers and graphs will be compared only for imported templates, any other will be considered as "new".

The rules object supports the following parameters.

Parameter Type Description
discoveryRules object Rules on how to import LLD rules.

Supported parameters:
createMissing - (boolean) if set to true, new LLD rules will be created; default: false;
updateExisting - (boolean) if set to true, existing LLD rules will be updated; default: false;
deleteMissing - (boolean) if set to true, LLD rules not present in the imported data will be deleted from the database; default: false.
graphs object Rules on how to import graphs.

Supported parameters:
createMissing - (boolean) if set to true, new graphs will be created; default: false;
updateExisting - (boolean) if set to true, existing graphs will be updated; default: false;
deleteMissing - (boolean) if set to true, graphs not present in the imported data will be deleted from the database; default: false.
groups object Rules on how to import host groups.

Supported parameters:
createMissing - (boolean) if set to true, new host groups will be created; default: false;
updateExisting - (boolean) if set to true, existing host groups will be updated; default: false.
hosts object Rules on how to import hosts.

Supported parameters:
createMissing - (boolean) if set to true, new hosts will be created; default: false;
updateExisting - (boolean) if set to true, existing hosts will be updated; default: false.

This parameter will make no difference to the output. It is allowed only for consistency with configuration.import.
httptests object Rules on how to import web scenarios.

Supported parameters:
createMissing - (boolean) if set to true, new web scenarios will be created; default: false;
updateExisting - (boolean) if set to true, existing web scenarios will be updated; default: false;
deleteMissing - (boolean) if set to true, web scenarios not present in the imported data will be deleted from the database; default: false.
images object Rules on how to import images.

Supported parameters:
createMissing - (boolean) if set to true, new images will be created; default: false;
updateExisting - (boolean) if set to true, existing images will be updated; default: false.

This parameter will make no difference to the output. It is allowed only for consistency with configuration.import.
items object Rules on how to import items.

Supported parameters:
createMissing - (boolean) if set to true, new items will be created; default: false;
updateExisting - (boolean) if set to true, existing items will be updated; default: false;
deleteMissing - (boolean) if set to true, items not present in the imported data will be deleted from the database; default: false.
maps object Rules on how to import maps.

Supported parameters:
createMissing - (boolean) if set to true, new maps will be created; default: false;
updateExisting - (boolean) if set to true, existing maps will be updated; default: false.

This parameter will make no difference to the output. It is allowed only for consistency with configuration.import.
mediaTypes object Rules on how to import media types.

Supported parameters:
createMissing - (boolean) if set to true, new media types will be created; default: false;
updateExisting - (boolean) if set to true, existing media types will be updated; default: false.

This parameter will make no difference to the output. It is allowed only for consistency with configuration.import.
templateLinkage object Rules on how to import template links.

Supported parameters:
createMissing - (boolean) if set to true, new links between templates and host will be created; default: false;
deleteMissing - (boolean) if set to true, template links not present in the imported data will be deleted from the database; default: false.
templates object Rules on how to import templates.

Supported parameters:
createMissing - (boolean) if set to true, new templates will be created; default: false;
updateExisting - (boolean) if set to true, existing templates will be updated; default: false.
templateDashboards object Rules on how to import template dashboards.

Supported parameters:
createMissing - (boolean) if set to true, new template dashboards will be created; default: false;
updateExisting - (boolean) if set to true, existing template dashboards will be updated; default: false;
deleteMissing - (boolean) if set to true, template dashboards not present in the imported data will be deleted from the database; default: false.
triggers object Rules on how to import triggers.

Supported parameters:
createMissing - (boolean) if set to true, new triggers will be created; default: false;
updateExisting - (boolean) if set to true, existing triggers will be updated; default: false;
deleteMissing - (boolean) if set to true, triggers not present in the imported data will be deleted from the database; default: false.
valueMaps object Rules on how to import host or template value maps.

Supported parameters:
createMissing - (boolean) if set to true, new value maps will be created; default: false;
updateExisting - (boolean) if set to true, existing value maps will be updated; default: false;
deleteMissing - (boolean) if set to true, value maps not present in the imported data will be deleted from the database; default: false.

Visszatérési értékek

(array) Egy tömböt ad vissza a konfiguráció módosításával, ez lesz elkészítve.

Példák

Importing hosts and items

Import the template and items contained in the YAML string. If any items in YAML are missing, they will be shown as deleted, and everything else will be left unchanged.

Request:

{
           "jsonrpc": "2.0",
           "method": "configuration.import",
           "params": {
               "format": "xml",
               "rules": {
                   "groups": {
                       "createMissing": true,
                       "updateExisting": true
                   },
                   "templates": {
                       "createMissing": true,
                       "updateExisting": true
                   },
                   "items": {
                       "createMissing": true,
                       "updateExisting": true,
                       "deleteMissing": true
                   },
                   "triggers": {
                       "createMissing": true,
                       "updateExisting": true,
                       "deleteMissing": true
                   },
                   "discoveryRules": {
                       "createMissing": true,
                       "updateExisting": true,
                       "deleteMissing": true
                   },
                   "valueMaps": {
                       "createMissing": true,
                       "updateExisting": false
                   }
               },
               "source": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><zabbix_export><version>5.4</version><date>2021-05-27T07:12:07Z</date><groups><group><uuid>6f6799aa69e844b4b3918f779f2abf08</uuid><name>Zabbix servers</name></group></groups><templates><template><uuid>e1bde9bf2f0544f5929f45b82502e744</uuid><template>Export template</template><name>Export template</name><groups><group><name>Zabbix servers</name></group></groups><items><item><uuid>3237bc89226e42ed8207574022470e83</uuid><name>Item</name><key>item.key</key><delay>30s</delay><valuemap><name>Host status</name></valuemap><triggers><trigger><uuid>bd1ed0089e4b4f35b762c9d6c599c348</uuid><expression>last(/Export template/item.key)=0</expression><name>Trigger</name></trigger></triggers></item></items><discovery_rules><discovery_rule><uuid>c91616bcf4a44f349539a1b40cb0979d</uuid><name>Discovery rule</name><key>rule.key</key><item_prototypes><item_prototype><uuid>7e164881825744248b3039af3435cf4b</uuid><name>Item prototype</name><key>prototype.key</key></item_prototype></item_prototypes></discovery_rule></discovery_rules><valuemaps><valuemap><uuid>7e666857c5df4af3a338349586f2afc3</uuid><name>Host status</name><mappings><mapping><value>0</value><newvalue>Up</newvalue></mapping><mapping><value>2</value><newvalue>Unreachable</newvalue></mapping></mappings></valuemap></valuemaps></template></templates></zabbix_export>"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
          "jsonrpc":"2.0",
          "result":{
             "templates":{
                "updated":[
                   {
                      "before":{
                         "uuid":"e1bde9bf2f0544f5929f45b82502e744",
                         "template":"Export template",
                         "name":"Export template"
                      },
                      "after":{
                         "uuid":"e1bde9bf2f0544f5929f45b82502e744",
                         "template":"Export template",
                         "name":"Export template"
                      },
                      "items":{
                         "added":[
                            {
                               "after":{
                                  "uuid":"3237bc89226e42ed8207574022470e83",
                                  "name":"Item",
                                  "key":"item.key",
                                  "delay":"30s",
                                  "valuemap":{
                                     "name":"Host status"
                                  }
                               },
                               "triggers":{
                                  "added":[
                                     {
                                        "after":{
                                           "uuid":"bd1ed0089e4b4f35b762c9d6c599c348",
                                           "expression":"last(/Export template/item.key)=0",
                                           "name":"Trigger"
                                        }
                                     }
                                  ]
                               }
                            }
                         ],
                         "removed":[
                            {
                               "before":{
                                  "uuid":"bd3e7b28b3d544d6a83ed01ddaa65ab6",
                                  "name":"Old Item",
                                  "key":"ite_old.key",
                                  "delay":"30s",
                                  "valuemap":{
                                     "name":"Host status"
                                  }
                               }
                            }
                         ]
                      },
                      "discovery_rules":{
                         "updated":[
                            {
                               "before":{
                                  "uuid":"c91616bcf4a44f349539a1b40cb0979d",
                                  "name":"Discovery rule",
                                  "key":"rule.key"
                               },
                               "after":{
                                  "uuid":"c91616bcf4a44f349539a1b40cb0979d",
                                  "name":"Discovery rule",
                                  "key":"rule.key"
                               },
                               "item_prototypes":{
                                  "updated":[
                                     {
                                        "before":{
                                           "uuid":"7e164881825744248b3039af3435cf4b",
                                           "name":"Old item prototype",
                                           "key":"prototype_old.key"
                                        },
                                        "after":{
                                           "uuid":"7e164881825744248b3039af3435cf4b",
                                           "name":"Item prototype",
                                           "key":"prototype.key"
                                        }
                                     }
                                  ]
                               }
                            }
                         ]
                      }
                   }
                ]
             }
          },
          "id":1
       }

Forrás

CConfiguration::importcompare() in ui/include/classes/api/services/CConfiguration.php.