Skip to content

Instantly share code, notes, and snippets.

@akagisho
Last active September 18, 2017 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akagisho/23d619790aed1455787696b897f90c10 to your computer and use it in GitHub Desktop.
Save akagisho/23d619790aed1455787696b897f90c10 to your computer and use it in GitHub Desktop.
Export Zabbix's Templates
<?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