Exemple #1
0
     if ($result) {
         $templateId = reset($result['templateids']);
     } else {
         throw new Exception();
     }
 }
 // full clone
 if ($templateId && $cloneTemplateId && getRequest('form') === 'full_clone') {
     if (!copyApplications($cloneTemplateId, $templateId)) {
         throw new Exception();
     }
     if (!copyItems($cloneTemplateId, $templateId)) {
         throw new Exception();
     }
     // copy web scenarios
     if (!copyHttpTests($cloneTemplateId, $templateId)) {
         throw new Exception();
     }
     // copy triggers
     $dbTriggers = API::Trigger()->get(array('output' => array('triggerid'), 'hostids' => $cloneTemplateId, 'inherited' => false));
     if ($dbTriggers) {
         $result &= copyTriggersToHosts(zbx_objectValues($dbTriggers, 'triggerid'), $templateId, $cloneTemplateId);
         if (!$result) {
             throw new Exception();
         }
     }
     // copy graphs
     $dbGraphs = API::Graph()->get(array('output' => array('graphid'), 'hostids' => $cloneTemplateId, 'inherited' => false));
     foreach ($dbGraphs as $dbGraph) {
         copyGraphToHost($dbGraph['graphid'], $templateId);
     }
Exemple #2
0
     $dbHostNew = reset($dbHostNew);
     add_audit_ext(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_HOST, $dbHostNew['hostid'], $dbHostNew['host'], 'hosts', $dbHost, $dbHostNew);
 }
 // full clone
 if (getRequest('form', '') === 'full_clone' && getRequest('clone_hostid', 0) != 0) {
     $srcHostId = getRequest('clone_hostid');
     // copy applications
     if (!copyApplications($srcHostId, $hostId)) {
         throw new Exception();
     }
     // copy items
     if (!copyItems($srcHostId, $hostId)) {
         throw new Exception();
     }
     // copy web scenarios
     if (!copyHttpTests($srcHostId, $hostId)) {
         throw new Exception();
     }
     // copy triggers
     $dbTriggers = API::Trigger()->get(['output' => ['triggerid'], 'hostids' => $srcHostId, 'inherited' => false]);
     if ($dbTriggers) {
         if (!copyTriggersToHosts(zbx_objectValues($dbTriggers, 'triggerid'), $hostId, $srcHostId)) {
             throw new Exception();
         }
     }
     // copy discovery rules
     $dbDiscoveryRules = API::DiscoveryRule()->get(['output' => ['itemid'], 'hostids' => $srcHostId, 'inherited' => false]);
     if ($dbDiscoveryRules) {
         $copyDiscoveryRules = API::DiscoveryRule()->copy(['discoveryids' => zbx_objectValues($dbDiscoveryRules, 'itemid'), 'hostids' => [$hostId]]);
         if (!$copyDiscoveryRules) {
             throw new Exception();