public function exists($object)
 {
     $keyFields = array(array('dserviceid'));
     $options = array('filter' => zbx_array_mintersect($keyFields, $object), 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => 1, 'limit' => 1);
     if (isset($object['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($object['node']);
     } elseif (isset($object['nodeids'])) {
         $options['nodeids'] = $object['nodeids'];
     }
     $objs = $this->get($options);
     return !empty($objs);
 }
Пример #2
0
 public function exists($object)
 {
     $options = array('filter' => array('name' => $object['name']), 'output' => array('usrgrpid'), 'nopermissions' => 1, 'limit' => 1);
     if (isset($object['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($object['node']);
     } elseif (isset($object['nodeids'])) {
         $options['nodeids'] = $object['nodeids'];
     }
     $objs = $this->get($options);
     return !empty($objs);
 }
Пример #3
0
 public function exists(array $object)
 {
     $options = array('filter' => array(), 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => 1, 'limit' => 1);
     if (isset($object['name'])) {
         $options['filter']['name'] = $object['name'];
     }
     if (isset($object['hostids'])) {
         $options['druleids'] = zbx_toArray($object['druleids']);
     }
     if (isset($object['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($object['node']);
     } elseif (isset($object['nodeids'])) {
         $options['nodeids'] = $object['nodeids'];
     }
     $objs = $this->get($options);
     return !empty($objs);
 }
Пример #4
0
 /**
  * Check if item exists.
  *
  * @param array $object
  *
  * @return bool
  */
 public function exists(array $object)
 {
     $options = array('filter' => array('key_' => $object['key_']), 'webitems' => true, 'output' => array('itemid'), 'nopermissions' => true, 'limit' => 1);
     if (isset($object['hostid'])) {
         $options['hostids'] = $object['hostid'];
     }
     if (isset($object['host'])) {
         $options['filter']['host'] = $object['host'];
     }
     if (isset($object['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($object['node']);
     } elseif (isset($object['nodeids'])) {
         $options['nodeids'] = $object['nodeids'];
     }
     $objs = $this->get($options);
     return !empty($objs);
 }
Пример #5
0
 /**
  * Is interface exist.
  *
  * @param array $object
  *
  * @return bool
  */
 public function exists(array $object)
 {
     $keyFields = array('interfaceid', 'hostid', 'ip', 'dns');
     $options = array('filter' => zbx_array_mintersect($keyFields, $object), 'output' => array('interfaceid'), 'nopermissions' => true, 'limit' => 1);
     if (isset($object['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($object['node']);
     } elseif (isset($object['nodeids'])) {
         $options['nodeids'] = $object['nodeids'];
     }
     $objs = $this->get($options);
     return !empty($objs);
 }
Пример #6
0
 /**
  * @param $object
  *
  * @return bool
  */
 public function exists(array $object)
 {
     $keyFields = array(array('hostid', 'host'), 'description');
     $result = false;
     if (!isset($object['hostid']) && !isset($object['host'])) {
         $expressionData = new CTriggerExpression();
         if (!$expressionData->parse($object['expression'])) {
             return false;
         }
         $expressionHosts = $expressionData->getHosts();
         $object['host'] = reset($expressionHosts);
     }
     $options = array('filter' => array_merge(zbx_array_mintersect($keyFields, $object), array('flags' => null)), 'output' => API_OUTPUT_EXTEND, 'nopermissions' => true);
     if (isset($object['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($object['node']);
     } elseif (isset($object['nodeids'])) {
         $options['nodeids'] = $object['nodeids'];
     }
     $triggers = $this->get($options);
     foreach ($triggers as $trigger) {
         $tmpExp = explode_exp($trigger['expression']);
         if (strcmp($tmpExp, $object['expression']) == 0) {
             $result = true;
             break;
         }
     }
     return $result;
 }
 public function exists($data)
 {
     $keyFields = array(array('screenid', 'name'), 'templateid');
     $options = array('filter' => zbx_array_mintersect($keyFields, $data), 'preservekeys' => true, 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => true, 'limit' => 1);
     if (isset($data['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($data['node']);
     } elseif (isset($data['nodeids'])) {
         $options['nodeids'] = $data['nodeids'];
     }
     $screens = $this->get($options);
     return !empty($screens);
 }
Пример #8
0
 public static function exists($object)
 {
     $keyFields = array('name', 'groupid');
     $options = array('filter' => zbx_array_mintersect($keyFields, $object), 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => 1, 'limit' => 1);
     if (isset($object['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($object['node']);
     } else {
         if (isset($object['nodeids'])) {
             $options['nodeids'] = $object['nodeids'];
         }
     }
     $objs = self::get($options);
     return !empty($objs);
 }
Пример #9
0
 /**
  * Get graphid by graph name.
  *
  * params: hostids, name
  *
  * @param array $graphData
  *
  * @return array
  */
 public function getObjects($graphData)
 {
     $options = array('filter' => $graphData, 'output' => API_OUTPUT_EXTEND);
     if (isset($graphData['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($graphData['node']);
     } elseif (isset($graphData['nodeids'])) {
         $options['nodeids'] = $graphData['nodeids'];
     }
     return $this->get($options);
 }
Пример #10
0
 public static function exists($object)
 {
     $options = array('filter' => array('key_' => $object['key_']), 'webitems' => 1, 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => 1, 'limit' => 1);
     if (isset($object['hostid'])) {
         $options['hostids'] = $object['hostid'];
     }
     if (isset($object['host'])) {
         $options['filter']['host'] = $object['host'];
     }
     if (isset($object['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($object['node']);
     } else {
         if (isset($object['nodeids'])) {
             $options['nodeids'] = $object['nodeids'];
         }
     }
     $objs = self::get($options);
     return !empty($objs);
 }
Пример #11
0
 public static function exists($data)
 {
     $keyFields = array(array('screenid', 'name'));
     $options = array('filter' => zbx_array_mintersect($keyFields, $data), 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => 1, 'limit' => 1);
     if (isset($data['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($data['node']);
     } else {
         if (isset($data['nodeids'])) {
             $options['nodeids'] = $data['nodeids'];
         }
     }
     $sysmaps = self::get($options);
     return !empty($sysmaps);
 }
Пример #12
0
 public static function exists($object)
 {
     $keyFields = array(array('hostid', 'host'), 'description');
     $result = false;
     if (!isset($object['hostid']) && !isset($object['host'])) {
         $expr = new CTriggerExpression($object);
         $expression = $object['expression'];
         if (!empty($expr->errors)) {
             return false;
         }
         if (empty($expr->data['hosts'])) {
             return false;
         }
         $object['host'] = reset($expr->data['hosts']);
     }
     $options = array('filter' => zbx_array_mintersect($keyFields, $object), 'output' => API_OUTPUT_EXTEND, 'nopermissions' => 1);
     if (isset($object['node'])) {
         $options['nodeids'] = getNodeIdByNodeName($object['node']);
     } else {
         if (isset($object['nodeids'])) {
             $options['nodeids'] = $object['nodeids'];
         }
     }
     $triggers = self::get($options);
     foreach ($triggers as $tnum => $trigger) {
         $tmp_exp = explode_exp($trigger['expression'], false);
         if (strcmp($tmp_exp, $object['expression']) == 0) {
             $result = true;
             break;
         }
     }
     return $result;
 }