array configuration.importcompare(object parameters)
このメソッドは、インポートファイルを現在のシステム要素と比較することを可能にし、このインポート ファイルがインポートされる場合に何が変更されるかを示します。
このメソッドは、あらゆるタイプのユーザーが利用できます。 メソッドを呼び出す権限は、ユーザーの役割の設定で取り消すことができます。 詳細は、ユーザーの役割を参照してください。
(object)
インポート可能なデータと、そのデータをどのように処理するかのルールを含むパラメータ
パラメータ | Type | 説明 |
---|---|---|
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. |
ルールが与えられていない場合、更新するものはなく、結果は空になります。
比較は、ホストグループとテンプレートに対してのみ行われます。トリガーとグラフの比較は、インポートされたテンプレートに
対してのみ行われ、それ以外は「新規」とみなされます。
rules
オブジェクトは以下のパラメータをサポートしています。
パラメータ | Type | 説明 |
---|---|---|
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 . |
(array)
行われる構成の変更を含む配列を返します。
YAML文字列に含まれるテンプレートと item を インポートします。YAMLに含まれていない項目がある場合、それらは削除された
ものとして表示され、それ以外は変更されずに残ります。
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
}
CConfiguration::importcompare() は ui/include/classes/api/services/CConfiguration.php にあります。