Created
September 18, 2017 08:39
-
-
Save akagisho/258c8615084be77e2273892a62575f74 to your computer and use it in GitHub Desktop.
Import Zabbix's Templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'vendor/autoload.php'; | |
use ZabbixApi\ZabbixApi; | |
$url = $argv[1]; | |
$user = $argv[2]; | |
$pass = $argv[3]; | |
$file = $argv[4]; | |
try | |
{ | |
$api = new ZabbixApi($url, $user, $pass); | |
$source = file_get_contents($file); | |
$result = $api->configurationImport(array( | |
'format' => 'xml', | |
'rules' => array( | |
'templates' => array('createMissing' => true, 'updateExisting' => true), | |
'applications' => array('createMissing' => true, 'updateExisting' => true), | |
'discoveryRules' => array('createMissing' => true, 'updateExisting' => true), | |
'graphs' => array('createMissing' => true, 'updateExisting' => true), | |
'groups' => array('createMissing' => true, 'updateExisting' => true), | |
'hosts' => array('createMissing' => true, 'updateExisting' => true), | |
'images' => array('createMissing' => true, 'updateExisting' => true), | |
'items' => array('createMissing' => true, 'updateExisting' => true), | |
'maps' => array('createMissing' => true, 'updateExisting' => true), | |
'screens' => array('createMissing' => true, 'updateExisting' => true), | |
'templateLinkage' => array('createMissing' => true, 'updateExisting' => true), | |
'templateScreens' => array('createMissing' => true, 'updateExisting' => true), | |
'triggers' => array('createMissing' => true, 'updateExisting' => true), | |
'valueMaps' => array('createMissing' => true, 'updateExisting' => true), | |
), | |
'source' => $source | |
)); | |
echo $result; | |
} | |
catch(Exception $e) | |
{ | |
echo $e->getMessage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment