function get_events_unacknowledged($db_element, $value_trigger = null, $value_event = null, $ack = false) { $elements = array('hosts' => array(), 'hosts_groups' => array(), 'triggers' => array()); get_map_elements($db_element, $elements); if (empty($elements['hosts_groups']) && empty($elements['hosts']) && empty($elements['triggers'])) { return 0; } $config = select_config(); $options = array('nodeids' => get_current_nodeid(), 'output' => API_OUTPUT_SHORTEN, 'monitored' => 1, 'skipDependent' => 1, 'limit' => $config['search_limit'] + 1); if (!is_null($value_trigger)) { $options['filter'] = array('value' => $value_trigger); } if (!empty($elements['hosts_groups'])) { $options['groupids'] = array_unique($elements['hosts_groups']); } if (!empty($elements['hosts'])) { $options['hostids'] = array_unique($elements['hosts']); } if (!empty($elements['triggers'])) { $options['triggerids'] = array_unique($elements['triggers']); } $triggerids = CTrigger::get($options); $options = array('countOutput' => 1, 'triggerids' => zbx_objectValues($triggerids, 'triggerid'), 'object' => EVENT_OBJECT_TRIGGER, 'acknowledged' => $ack ? 1 : 0, 'value' => is_null($value_event) ? array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE) : $value_event, 'nopermissions' => 1); $event_count = CEvent::get($options); return $event_count; }
function get_events_unacknowledged($db_element, $value_trigger = null, $value_event = null, $ack = false) { $elements = array('hosts' => array(), 'hosts_groups' => array(), 'triggers' => array()); get_map_elements($db_element, $elements); if (empty($elements['hosts_groups']) && empty($elements['hosts']) && empty($elements['triggers'])) { return 0; } $config = select_config(); $options = array('nodeids' => get_current_nodeid(), 'output' => array('triggerid'), 'monitored' => 1, 'skipDependent' => 1, 'limit' => $config['search_limit'] + 1); if (!is_null($value_trigger)) { $options['filter'] = array('value' => $value_trigger); } if (!empty($elements['hosts_groups'])) { $options['groupids'] = array_unique($elements['hosts_groups']); } if (!empty($elements['hosts'])) { $options['hostids'] = array_unique($elements['hosts']); } if (!empty($elements['triggers'])) { $options['triggerids'] = array_unique($elements['triggers']); } $triggerids = API::Trigger()->get($options); return API::Event()->get(array('source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'countOutput' => true, 'objectids' => zbx_objectValues($triggerids, 'triggerid'), 'filter' => array('value' => $value_event, 'acknowledged' => $ack ? 1 : 0))); }
function get_map_elements($db_element, &$elements) { switch ($db_element['elementtype']) { case SYSMAP_ELEMENT_TYPE_HOST_GROUP: $elements['hosts_groups'][] = $db_element['elementid']; break; case SYSMAP_ELEMENT_TYPE_HOST: $elements['hosts'][] = $db_element['elementid']; break; case SYSMAP_ELEMENT_TYPE_TRIGGER: $elements['triggers'][] = $db_element['elementid']; break; case SYSMAP_ELEMENT_TYPE_MAP: $db_mapselements = DBselect('SELECT DISTINCT se.elementtype,se.elementid' . ' FROM sysmaps_elements se' . ' WHERE se.sysmapid=' . zbx_dbstr($db_element['elementid'])); while ($db_mapelement = DBfetch($db_mapselements)) { get_map_elements($db_mapelement, $elements); } break; } }
function get_triggers_unacknowledged($db_element, $count_problems = null, $ack = false) { $elements = array('hosts' => array(), 'hosts_groups' => array(), 'triggers' => array()); get_map_elements($db_element, $elements); if (empty($elements['hosts_groups']) && empty($elements['hosts']) && empty($elements['triggers'])) { return 0; } $config = select_config(); $options = array('nodeids' => get_current_nodeid(), 'monitored' => true, 'countOutput' => true, 'filter' => array(), 'limit' => $config['search_limit'] + 1); if ($ack) { $options['withAcknowledgedEvents'] = 1; } else { $options['withUnacknowledgedEvents'] = 1; } if ($count_problems) { $options['filter']['value'] = TRIGGER_VALUE_TRUE; } if (!empty($elements['hosts_groups'])) { $options['groupids'] = array_unique($elements['hosts_groups']); } if (!empty($elements['hosts'])) { $options['hostids'] = array_unique($elements['hosts']); } if (!empty($elements['triggers'])) { $options['triggerids'] = array_unique($elements['triggers']); } return API::Trigger()->get($options); }