Last active
September 18, 2017 00:07
-
-
Save akagisho/23d619790aed1455787696b897f90c10 to your computer and use it in GitHub Desktop.
Export Zabbix's Templates
This file contains 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]; | |
$search = $argv[4]; | |
try | |
{ | |
$api = new ZabbixApi($url, $user, $pass); | |
$results = $api->templateGet(array( | |
'search' => array('host' => $search), | |
)); | |
$templateids = array(); | |
foreach ($results as $result) { | |
$templateids[] = $result->templateid; | |
} | |
$result = $api->configurationExport(array( | |
format => 'xml', | |
options => array( | |
'templates' => $templateids | |
) | |
)); | |
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