boolean configuration.import(object parameters)
このメソッドは、シリアル化された文字列から設定データをインポートすることができます。
このメソッドは、すべてのタイプのユーザーが利用できます。メソッドを呼び出す権限は、ユーザーの役割の設定で取り消すことができます。詳細はユーザーの役割を参照してください。
(object)
インポートするデータを含むパラメーターと、データの処理方法を規定します。
パラメーター | タイプ | 説明 |
---|---|---|
format (必須) |
string | シリアル化された文字列のフォーマット。 利用可能な値: yaml - YAMLxml - XMLjson - JSON |
source (必須) |
string | 設定データを含むシリアル化された文字列。 |
rules (必須) |
object | 新規および既存のオブジェクトをインポートする方法に関するルール。rules パラメーターについては、以下の表で詳しく説明します。 |
ルールが指定されていない場合、設定は更新されません。
rules
オブジェクトは次のパラメーターをサポートします。
パラメーター | タイプ | 説明 |
---|---|---|
discoveryRules | object | LLDルールをインポートする方法に関するルール。 サポートするパラメーター: createMissing - (boolean) true に設定すると、新しいLLDルールが作成されます。デフォルト: false updateExisting - (boolean) true に設定すると、既存のLLDルールが更新されます。 デフォルト: false deleteMissing - (boolean) true に設定すると、インポートされたデータに存在しないLLDルールはデータベースから削除されます。デフォルト: false |
graphs | object | グラフのインポート方法に関するルール。 サポートするパラメーター: createMissing - (boolean) true に設定すると、新しいグラフが作成されます。デフォルト: false updateExisting - (boolean) true に設定すると、既存のグラフは更新されます。デフォルト: false deleteMissing - (boolean) true に設定すると、インポートされたデータに存在しないグラフはデータベースから削除されます。デフォルト: false |
groups | object | ホストグループをインポートする方法に関するルール。 サポートするパラメーター: createMissing - (boolean) true に設定すると、新しいホストグループが作成されます。デフォルト: false updateExisting - (boolean) true に設定すると、既存のホストグループは更新されます。デフォルト: false |
hosts | object | ホストをインポートする方法に関するルール。 サポートするパラメーター: createMissing - (boolean) true に設定すると、新しいホストが作成されます。デフォルト: false updateExisting - (boolean) true に設定すると、既存のホストは更新されます。デフォルト: false |
httptests | object | Rules on how to import web scenarios. サポートするパラメーター: createMissing - (boolean) true に設定すると、new web scenarios will be created; デフォルト: false updateExisting - (boolean) true に設定すると、existing web scenarios will be updated; デフォルト: false deleteMissing - (boolean) true に設定すると、web scenarios not present in the imported data will be deleted from the database; デフォルト: false |
images | object | Rules on how to import images. サポートするパラメーター: createMissing - (boolean) true に設定すると、new images will be created; デフォルト: false updateExisting - (boolean) true に設定すると、existing images will be updated; デフォルト: false |
items | object | Rules on how to import items. サポートするパラメーター: createMissing - (boolean) true に設定すると、new items will be created; デフォルト: false updateExisting - (boolean) true に設定すると、existing items will be updated; デフォルト: false deleteMissing - (boolean) true に設定すると、items not present in the imported data will be deleted from the database; デフォルト: false |
maps | object | Rules on how to import maps. サポートするパラメーター: createMissing - (boolean) true に設定すると、new maps will be created; デフォルト: false updateExisting - (boolean) true に設定すると、existing maps will be updated; デフォルト: false |
mediaTypes | object | Rules on how to import media types. サポートするパラメーター: createMissing - (boolean) true に設定すると、new media types will be created; デフォルト: false updateExisting - (boolean) true に設定すると、existing media types will be updated; デフォルト: false |
templateLinkage | object | Rules on how to import template links. サポートするパラメーター: createMissing - (boolean) true に設定すると、templates that are not linked to the host or template being imported, but are present in the imported data, will be linked; デフォルト: false deleteMissing - (boolean) true に設定すると、templates that are linked to the host or template being imported, but are not present in the imported data, will be unlinked without removing entities (items, triggers, etc.) inherited from the unlinked templates; デフォルト: false |
templates | object | Rules on how to import templates. サポートするパラメーター: createMissing - (boolean) true に設定すると、new templates will be created; デフォルト: false updateExisting - (boolean) true に設定すると、existing templates will be updated; デフォルト: false |
templateDashboards | object | Rules on how to import template dashboards. サポートするパラメーター: createMissing - (boolean) true に設定すると、new template dashboards will be created; デフォルト: false updateExisting - (boolean) true に設定すると、existing template dashboards will be updated; デフォルト: false deleteMissing - (boolean) true に設定すると、template dashboards not present in the imported data will be deleted from the database; デフォルト: false |
triggers | object | Rules on how to import triggers. サポートするパラメーター: createMissing - (boolean) true に設定すると、new triggers will be created; デフォルト: false updateExisting - (boolean) true に設定すると、existing triggers will be updated; デフォルト: false deleteMissing - (boolean) true に設定すると、triggers not present in the imported data will be deleted from the database; デフォルト: false |
valueMaps | object | Rules on how to import host or template value maps. サポートするパラメーター: createMissing - (boolean) true に設定すると、new value maps will be created; デフォルト: false updateExisting - (boolean) true に設定すると、existing value maps will be updated; デフォルト: false deleteMissing - (boolean) true に設定すると、value maps not present in the imported data will be deleted from the database; デフォルト: false |
(boolean)
インポートに成功した場合は true
を返します。
XML 文字列に含まれるホストと item をインポートします。XML に含まれる item が欠落している場合、その item は
データベースから削除され、それ以外は変更されずに残ります。
Request:
{
"jsonrpc": "2.0",
"method": "configuration.import",
"params": {
"format": "xml",
"rules": {
"valueMaps": {
"createMissing": true,
"updateExisting": false
},
"hosts": {
"createMissing": true,
"updateExisting": true
},
"items": {
"createMissing": true,
"updateExisting": true,
"deleteMissing": true
}
},
"source": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<zabbix_export><version>5.4</version><date>2020-03-13T15:31:45Z</date><groups><group><uuid>6f6799aa69e844b4b3918f779f2abf08</uuid><name>Zabbix servers</name></group></groups><hosts><host><host>Export host</host><name>Export host</name><groups><group><name>Zabbix servers</name></group></groups><interfaces><interface><interface_ref>if1</interface_ref></interface></interfaces><items><item><name>Item</name><key>item.key</key><delay>30s</delay><valuemap><name>Host status</name></valuemap><interface_ref>if1</interface_ref><request_method>POST</request_method></item></items><valuemaps><valuemap><name>Host status</name><mappings><mapping><value>0</value><newvalue>Up</newvalue></mapping><mapping><value>2</value><newvalue>Unreachable</newvalue></mapping></mappings></valuemap></valuemaps></host></hosts></zabbix_export>"
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
Response:
CConfiguration::import() は ui/include/classes/api/services/CConfiguration.php にあります。