function make_latest_issues($params = array()) { global $USER_DETAILS; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY); $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array()); $scripts_by_hosts = get_accessible_scripts_by_hosts($available_hosts); $config = select_config(); $sql_select = ''; $sql_from = ''; $sql_where = ''; $limit = 20; if (!empty($params)) { if (isset($params['limit'])) { $limit = $params['limit']; } if (isset($params['groupid']) && $params['groupid'] > 0) { $sql_select .= ',g.name '; $sql_from .= ',groups g '; $sql_where .= ' AND g.groupid=hg.groupid ' . ' AND hg.groupid=' . $params['groupid']; } if (isset($params['hostid']) && $params['hostid'] > 0) { $sql_where .= ' AND h.hostid=' . $params['hostid']; } } $table = new CTableInfo(); $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, isset($params['groupid']) && $params['groupid'] > 0 ? S_GROUP : null, S_HOST, S_ISSUE, S_LAST_CHANGE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS)); $sql = 'SELECT DISTINCT t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.value,h.host,h.hostid ' . $sql_select . ' FROM triggers t,hosts h,items i,functions f,hosts_groups hg ' . $sql_from . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.value=' . TRIGGER_VALUE_TRUE . $sql_where . ' ORDER BY t.lastchange DESC'; $result = DBselect($sql, $limit); while ($row = DBfetch($result)) { // Check for dependencies if (trigger_dependent($row["triggerid"])) { continue; } $host = null; $menus = ''; $host_nodeid = id2nodeid($row['hostid']); foreach ($scripts_by_hosts[$row['hostid']] as $id => $script) { $script_nodeid = id2nodeid($script['scriptid']); if (bccomp($host_nodeid, $script_nodeid) == 0) { $menus .= "['" . $script['name'] . "',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $row['hostid'] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; } } $menus .= "[" . zbx_jsvalue(S_LINKS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],"; $menus .= "['" . S_LATEST_DATA . "',\"javascript: redirect('latest.php?groupid=0&hostid=" . $row['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; $menus = rtrim($menus, ','); $menus = "show_popup_menu(event,[[" . zbx_jsvalue(S_TOOLS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus . "],180);"; $host = new CSpan($row['host'], 'link'); $host->setAttribute('onclick', 'javascript: ' . $menus); $host->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $event_sql = 'SELECT DISTINCT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type, t.url ' . ' FROM events e, triggers t ' . ' WHERE e.object=' . EVENT_SOURCE_TRIGGERS . ' AND e.objectid=' . $row['triggerid'] . ' AND t.triggerid=e.objectid ' . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC'; $res_events = DBSelect($event_sql, 1); while ($row_event = DBfetch($res_events)) { $ack = NULL; if ($config['event_ack_enable']) { if ($row_event['acknowledged'] == 1) { $ack_info = make_acktab_by_eventid($row_event['eventid']); $ack_info->setAttribute('style', 'width: auto;'); $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_event['eventid'], 'action'); $ack->setHint($ack_info); } else { $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_event['eventid'], 'on'); } } // $description = expand_trigger_description($row['triggerid']); $description = expand_trigger_description_by_data(array_merge($row, array('clock' => $row_event['clock'])), ZBX_FLAG_EVENT); //actions $actions = get_event_actions_stat_hints($row_event['eventid']); $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'events.php?triggerid=' . $row['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $row_event['clock'], 'action'); if ($row_event['url']) { $description = new CLink($description, $row_event['url'], 'action', null, true); } else { $description = new CSpan($description, 'pointer'); } $description = new CCol($description, get_severity_style($row["priority"])); $description->setHint(make_popup_eventlist($row_event['eventid'], $row['type'])); $table->addRow(array(get_node_name_by_elid($row['triggerid']), $host, $description, $clock, zbx_date2age($row_event['clock']), $ack, $actions)); } unset($row, $description, $actions, $alerts, $hint); } $table->setFooter(new CCol(S_UPDATED . ': ' . date("H:i:s", time()))); return $table; }
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array("msg" => array(T_ZBX_STR, O_OPT, null, null, NULL), 'favobj' => array(T_ZBX_STR, O_OPT, P_ACT, IN("'hat'"), NULL), 'favref' => array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), 'state' => array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})')); check_fields($fields); /* AJAX */ if (isset($_REQUEST['favobj'])) { if ('hat' == $_REQUEST['favobj']) { CProfile::update('web.services.hats.' . $_REQUEST['favref'] . '.state', $_REQUEST['state'], PROFILE_TYPE_INT); } } if (PAGE_TYPE_JS == $page['type'] || PAGE_TYPE_HTML_BLOCK == $page['type']) { include_once 'include/page_footer.php'; exit; } //-------- //-------------------------------------------------------------------------- $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array()); $sql = 'SELECT DISTINCT s.serviceid, sl.servicedownid, sl_p.serviceupid as serviceupid, s.triggerid, ' . ' s.name as caption, s.algorithm, t.description, t.expression, s.sortorder, sl.linkid, s.showsla, s.goodsla, s.status ' . ' FROM services s ' . ' LEFT JOIN triggers t ON s.triggerid = t.triggerid ' . ' LEFT JOIN services_links sl ON s.serviceid = sl.serviceupid and NOT(sl.soft=0) ' . ' LEFT JOIN services_links sl_p ON s.serviceid = sl_p.servicedownid and sl_p.soft=0 ' . ' WHERE ' . DBin_node('s.serviceid') . ' AND (t.triggerid IS NULL OR ' . DBcondition('t.triggerid', $available_triggers) . ') ' . ' ORDER BY s.sortorder, sl_p.serviceupid, s.serviceid'; $result = DBSelect($sql); $services = array(); $row = array('id' => 0, 'serviceid' => 0, 'serviceupid' => 0, 'caption' => S_ROOT_SMALL, 'status' => SPACE, 'algorithm' => SPACE, 'description' => SPACE, 'soft' => 0, 'linkid' => ''); $services[0] = $row; while ($row = DBFetch($result)) { $row['id'] = $row['serviceid']; empty($row['serviceupid']) ? $row['serviceupid'] = '0' : ''; empty($row['triggerid']) ? $row['description'] = 'None' : ($row['description'] = expand_trigger_description($row['triggerid'])); if (isset($services[$row['serviceid']])) { $services[$row['serviceid']] = zbx_array_merge($services[$row['serviceid']], $row); } else { $services[$row['serviceid']] = $row; } if (isset($row['serviceupid'])) {
function get_triggers_overview($hostids, $view_style = null) { $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $hostids); if (is_null($view_style)) { $view_style = get_profile('web.overview.view.style', STYLE_TOP); } $table = new CTableInfo(S_NO_TRIGGERS_DEFINED); $result = DBselect('SELECT DISTINCT t.triggerid,t.description,t.expression,t.value,t.priority,t.lastchange,h.hostid,h.host' . ' FROM hosts h,items i,triggers t, functions f ' . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid' . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' ORDER BY t.description'); unset($triggers); unset($hosts); $triggers = array(); while ($row = DBfetch($result)) { if (trigger_dependent($row['triggerid'])) { continue; } $row['host'] = get_node_name_by_elid($row['hostid']) . $row['host']; $row['description'] = expand_trigger_description_constants($row['description'], $row); $hosts[strtolower($row['host'])] = $row['host']; // A little tricky check for attempt to overwrite active trigger (value=1) with // inactive or active trigger with lower priority. if (!isset($triggers[$row['description']][$row['host']]) || ($triggers[$row['description']][$row['host']]['value'] == TRIGGER_VALUE_FALSE && $row['value'] == TRIGGER_VALUE_TRUE || ($triggers[$row['description']][$row['host']]['value'] == TRIGGER_VALUE_FALSE || $row['value'] == TRIGGER_VALUE_TRUE) && $row['priority'] > $triggers[$row['description']][$row['host']]['priority'])) { $triggers[$row['description']][$row['host']] = array('hostid' => $row['hostid'], 'triggerid' => $row['triggerid'], 'value' => $row['value'], 'lastchange' => $row['lastchange'], 'priority' => $row['priority']); } } if (!isset($hosts)) { return $table; } ksort($hosts); if ($view_style == STYLE_TOP) { $header = array(new CCol(S_TRIGGERS, 'center')); foreach ($hosts as $hostname) { $header = array_merge($header, array(new CImg('vtext.php?text=' . $hostname))); } $table->setHeader($header, 'vertical_header'); foreach ($triggers as $descr => $trhosts) { $table_row = array(nbsp($descr)); foreach ($hosts as $hostname) { $table_row = get_trigger_overview_cells($table_row, $trhosts, $hostname); } $table->AddRow($table_row); } } else { $header = array(new CCol(S_HOSTS, 'center')); foreach ($triggers as $descr => $trhosts) { $descr = array(new CImg('vtext.php?text=' . $descr)); array_push($header, $descr); } $table->SetHeader($header, 'vertical_header'); foreach ($hosts as $hostname) { $table_row = array(nbsp($hostname)); foreach ($triggers as $descr => $trhosts) { $table_row = get_trigger_overview_cells($table_row, $trhosts, $hostname); } $table->AddRow($table_row); } } return $table; }
$PAGE_HOSTS = get_viewed_hosts(PERM_READ_ONLY, $PAGE_GROUPS['selected'], $params); //SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']); validate_group_with_host($PAGE_GROUPS, $PAGE_HOSTS); //SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']); $mute = get_profile('web.tr_status.mute', 0); if (isset($audio) && !$mute) { play_sound($audio); } $trigg_wdgt = new CWidget(); $r_form = new CForm(); $r_form->setMethod('get'); // $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY); // $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); $available_groups = $PAGE_GROUPS['groupids']; $available_hosts = $PAGE_HOSTS['hostids']; $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $PAGE_HOSTS['hostids']); $scripts_by_hosts = get_accessible_scripts_by_hosts($PAGE_HOSTS['hostids']); $cmbGroups = new CComboBox('groupid', $PAGE_GROUPS['selected'], 'javascript: submit();'); $cmbHosts = new CComboBox('hostid', $PAGE_HOSTS['selected'], 'javascript: submit();'); foreach ($PAGE_GROUPS['groups'] as $groupid => $name) { $cmbGroups->addItem($groupid, get_node_name_by_elid($groupid) . $name); } foreach ($PAGE_HOSTS['hosts'] as $hostid => $name) { $cmbHosts->addItem($hostid, get_node_name_by_elid($hostid) . $name); } $r_form->addItem(array(S_GROUP . SPACE, $cmbGroups)); $r_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts)); $r_form->addVar('fullscreen', $_REQUEST['fullscreen']); $url = 'tr_status.php' . ($_REQUEST['fullscreen'] ? '' : '?fullscreen=1'); $fs_icon = new CDiv(SPACE, 'fullscreen'); $fs_icon->setAttribute('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN);
function get_actions_hint_by_eventid($eventid, $status = NULL) { $hostids = array(); $sql = 'SELECT DISTINCT i.hostid ' . ' FROM events e, functions f, items i ' . ' WHERE e.eventid=' . $eventid . ' AND e.objectid=' . EVENT_SOURCE_TRIGGERS . ' AND f.triggerid=' . $_REQUEST['triggerid'] . ' AND i.itemid=f.itemid'; if ($host = DBfetch(DBselect($sql, 1))) { $hostids[$host['hostid']] = $host['hostid']; } $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $hostids); $tab_hint = new CTableInfo(S_NO_ACTIONS_FOUND); $tab_hint->addOption('style', 'width: 300px;'); $tab_hint->SetHeader(array(is_show_subnodes() ? S_NODES : null, S_USER, S_DETAILS, S_STATUS)); /* $sql = 'SELECT DISTINCT a.alertid,mt.description,a.sendto,a.status,u.alias,a.retries '. ' FROM events e,users u,alerts a'. ' left join media_type mt on mt.mediatypeid=a.mediatypeid'. ' WHERE a.eventid='.$eventid. (is_null($status)?'':' AND a.status='.$status). ' AND e.eventid = a.eventid'. ' AND a.alerttype IN ('.ALERT_TYPE_MESSAGE.','.ALERT_TYPE_COMMAND.')'. ' AND '.DBcondition('e.objectid',$available_triggers). ' AND '.DBin_node('a.alertid'). ' AND u.userid=a.userid '. ' ORDER BY mt.description'; //*/ $sql = 'SELECT DISTINCT a.alertid,mt.description,u.alias,a.subject,a.message,a.sendto,a.status,a.retries,a.alerttype ' . ' FROM events e,alerts a ' . ' LEFT JOIN users u ON u.userid=a.userid ' . ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid' . ' WHERE a.eventid=' . $eventid . (is_null($status) ? '' : ' AND a.status=' . $status) . ' AND e.eventid = a.eventid' . ' AND a.alerttype IN (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND ' . DBcondition('e.objectid', $available_triggers) . ' AND ' . DBin_node('a.alertid') . ' ORDER BY a.alertid'; $result = DBselect($sql, 30); while ($row = DBfetch($result)) { if ($row["status"] == ALERT_STATUS_SENT) { $status = new CSpan(S_SENT, "green"); $retries = new CSpan(SPACE, "green"); } else { if ($row["status"] == ALERT_STATUS_NOT_SENT) { $status = new CSpan(S_IN_PROGRESS, "orange"); $retries = new CSpan(ALERT_MAX_RETRIES - $row["retries"], "orange"); } else { $status = new CSpan(S_NOT_SENT, "red"); $retries = new CSpan(0, "red"); } } switch ($row['alerttype']) { case ALERT_TYPE_MESSAGE: $message = empty($row['description']) ? '-' : $row['description']; break; case ALERT_TYPE_COMMAND: $message = array(bold(S_COMMAND . ':')); $msg = explode("\n", $row['message']); foreach ($msg as $m) { array_push($message, BR(), $m); } break; default: $message = '-'; } $tab_hint->addRow(array(get_node_name_by_elid($row['alertid']), empty($row['alias']) ? ' - ' : $row['alias'], $message, $status)); } return $tab_hint; }
} } else { // $_REQUEST['triggerid'] = 0; } } $params = array(); $options = array('with_items', 'only_current_node'); foreach ($options as $option) { $params[$option] = 1; } $PAGE_GROUPS = get_viewed_groups(PERM_READ_WRITE, $params); $PAGE_HOSTS = get_viewed_hosts(PERM_READ_WRITE, $PAGE_GROUPS['selected'], $params); validate_group_with_host($PAGE_GROUPS, $PAGE_HOSTS); $available_groups = $PAGE_GROUPS['groupids']; $available_hosts = $PAGE_HOSTS['hostids']; $available_triggers = get_accessible_triggers(PERM_READ_WRITE, $PAGE_HOSTS['hostids'], PERM_RES_IDS_ARRAY, null, 0); $form = new CForm(); $form->setMethod('get'); $form->addItem(new CButton('form', S_CREATE_TRIGGER)); show_table_header(S_CONFIGURATION_OF_TRIGGERS_BIG, $form); echo SBR; if (isset($_REQUEST['massupdate']) && isset($_REQUEST['g_triggerid'])) { insert_mass_update_trigger_form(); } else { if (isset($_REQUEST['form'])) { /* FORM */ insert_trigger_form(); } else { if (isset($_REQUEST['form_copy_to']) && isset($_REQUEST['g_triggerid'])) { insert_copy_elements_to_forms('g_triggerid'); } else {
public function bodyToString() { $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY, get_current_nodeid(true)); foreach ($available_triggers as $id => $triggerid) { if (trigger_dependent($triggerid)) { unset($available_triggers[$id]); } } $this->cleanItems(); $ok = $uncn = $info = $warn = $avg = $high = $dis = 0; $sql_from = ''; $sql_where = ''; if ($this->groupid > 0) { $sql_from = ', hosts_groups hg '; $sql_where = ' AND hg.groupid=' . $this->groupid . ' AND h.hostid=hg.hostid '; } $db_priority = DBselect('SELECT t.priority,t.value,count(DISTINCT t.triggerid) as cnt ' . ' FROM triggers t,hosts h,items i,functions f ' . $sql_from . ' WHERE t.status=' . TRIGGER_STATUS_ENABLED . ' AND f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.triggerid=f.triggerid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('t.triggerid', $available_triggers) . $sql_where . ' GROUP BY t.priority,t.value'); while ($row = DBfetch($db_priority)) { switch ($row["value"]) { case TRIGGER_VALUE_TRUE: switch ($row["priority"]) { case TRIGGER_SEVERITY_INFORMATION: $info += $row["cnt"]; break; case TRIGGER_SEVERITY_WARNING: $warn += $row["cnt"]; break; case TRIGGER_SEVERITY_AVERAGE: $avg += $row["cnt"]; break; case TRIGGER_SEVERITY_HIGH: $high += $row["cnt"]; break; case TRIGGER_SEVERITY_DISASTER: $dis += $row["cnt"]; break; default: $uncn += $row["cnt"]; break; } break; case TRIGGER_VALUE_FALSE: $ok += $row["cnt"]; break; default: $uncn += $row["cnt"]; break; } } if ($this->show_header) { $header = new CCol(S_TRIGGERS_INFO, "header"); if ($this->style == STYLE_HORISONTAL) { $header->SetColspan(7); } $this->addRow($header); } $trok = new CCol($ok . SPACE . S_OK, get_severity_style('ok', false)); $uncn = new CCol($uncn . SPACE . S_NOT_CLASSIFIED, get_severity_style(TRIGGER_SEVERITY_NOT_CLASSIFIED, $uncn)); $info = new CCol($info . SPACE . S_INFORMATION, get_severity_style(TRIGGER_SEVERITY_INFORMATION, $info)); $warn = new CCol($warn . SPACE . S_WARNING, get_severity_style(TRIGGER_SEVERITY_WARNING, $warn)); $avg = new CCol($avg . SPACE . S_AVERAGE, get_severity_style(TRIGGER_SEVERITY_AVERAGE, $avg)); $high = new CCol($high . SPACE . S_HIGH, get_severity_style(TRIGGER_SEVERITY_HIGH, $high)); $dis = new CCol($dis . SPACE . S_DISASTER, get_severity_style(TRIGGER_SEVERITY_DISASTER, $dis)); if (STYLE_HORISONTAL == $this->style) { $this->addRow(array($trok, $uncn, $info, $warn, $avg, $high, $dis)); } else { $this->addRow($trok); $this->addRow($uncn); $this->addRow($info); $this->addRow($warn); $this->addRow($avg); $this->addRow($high); $this->addRow($dis); } return parent::BodyToString(); }
include_once "include/page_header.php"; $bulk = isset($_REQUEST['bulkacknowledge']); // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('eventid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'events' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'message' => array(T_ZBX_STR, O_OPT, NULL, $bulk ? NULL : NOT_EMPTY, 'isset({save})||isset({saveandreturn})'), 'bulkacknowledge' => array(T_ZBX_STR, O_OPT, P_ACT | P_SYS, NULL, NULL), "saveandreturn" => array(T_ZBX_STR, O_OPT, P_ACT | P_SYS, NULL, NULL), "save" => array(T_ZBX_STR, O_OPT, P_ACT | P_SYS, NULL, NULL), "cancel" => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null)); check_fields($fields); if (!isset($_REQUEST['events']) && !isset($_REQUEST['eventid'])) { show_message(S_NO_EVENTS_TO_ACKNOWLEDGE); include_once "include/page_footer.php"; } if (isset($_REQUEST['eventid'])) { $events[$_REQUEST['eventid']] = $_REQUEST['eventid']; } else { $events = $_REQUEST['events']; } //$bulk = (count($events) > 1); $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY, get_current_nodeid()); $db_data = DBfetch(DBselect('SELECT COUNT(DISTINCT e.eventid) as cnt' . ' FROM events e' . ' WHERE ' . DBcondition('e.eventid', $events) . ' AND ' . DBcondition('e.objectid', $available_triggers) . ' AND e.object=' . EVENT_OBJECT_TRIGGER . ' AND ' . DBin_node('e.eventid'))); if ($db_data['cnt'] != count($events)) { access_deny(); } $db_data = DBfetch(DBselect('SELECT DISTINCT e.*,t.triggerid,t.expression,t.description,t.expression,h.host,h.hostid ' . ' FROM hosts h, items i, functions f, events e, triggers t' . ' WHERE h.hostid=i.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ' . ' AND ' . DBcondition('e.eventid', $events) . ' AND e.object=' . EVENT_OBJECT_TRIGGER . ' AND e.objectid=t.triggerid ' . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND ' . DBin_node('e.eventid'))); if (isset($_REQUEST['save']) && !$bulk) { $result = add_acknowledge_coment($db_data['eventid'], $USER_DETAILS['userid'], $_REQUEST['message']); show_messages($result, S_COMMENT_ADDED, S_CANNOT_ADD_COMMENT); if ($result) { add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER, S_ACKNOWLEDGE_ADDED . ' [' . expand_trigger_description_by_data($db_data) . ']' . ' [' . $_REQUEST["message"] . ']'); } } else { if (isset($_REQUEST["saveandreturn"])) { $result = true; if ($bulk) {
if (!$ZBX_WITH_ALL_NODES) { array_push($options, 'only_current_node'); } //SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']); $params = array(); foreach ($options as $option) { $params[$option] = 1; } $PAGE_GROUPS = get_viewed_groups(PERM_READ_ONLY, $params); $PAGE_HOSTS = get_viewed_hosts(PERM_READ_ONLY, $PAGE_GROUPS['selected'], $params); //SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']); validate_group_with_host($PAGE_GROUPS, $PAGE_HOSTS); //SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']); $available_groups = $PAGE_GROUPS['groupids']; $available_hosts = $PAGE_HOSTS['hostids']; $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $PAGE_HOSTS['hostids'], PERM_RES_DATA_ARRAY, get_current_nodeid()); if (isset($_REQUEST['triggerid']) && $_REQUEST['triggerid'] > 0 && !isset($available_triggers[$_REQUEST['triggerid']])) { unset($_REQUEST['triggerid']); } $cmbGroups = new CComboBox('groupid', $PAGE_GROUPS['selected'], 'javascript: submit();'); $cmbHosts = new CComboBox('hostid', $PAGE_HOSTS['selected'], 'javascript: submit();'); foreach ($PAGE_GROUPS['groups'] as $groupid => $name) { $cmbGroups->addItem($groupid, get_node_name_by_elid($groupid) . $name); } foreach ($PAGE_HOSTS['hosts'] as $hostid => $name) { $cmbHosts->addItem($hostid, get_node_name_by_elid($hostid) . $name); } $r_form->addItem(array(S_GROUP . SPACE, $cmbGroups)); $r_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts)); } if ($allow_discovery) {
function get_screen($screenid, $editmode, $effectiveperiod = NULL) { global $USER_DETAILS; if ($screenid == 0) { return new CTableInfo(S_NO_SCREENS_DEFINED); } if (!screen_accessible($screenid, $editmode == 1 ? PERM_READ_WRITE : PERM_READ_ONLY)) { access_deny(); } if (is_null($effectiveperiod)) { $effectiveperiod = ZBX_MIN_PERIOD; } $result = DBselect('SELECT name,hsize,vsize FROM screens WHERE screenid=' . $screenid); $row = DBfetch($result); if (!$row) { return new CTableInfo(S_NO_SCREENS_DEFINED); } for ($r = 0; $r < $row['vsize']; $r++) { for ($c = 0; $c < $row['hsize']; $c++) { if (isset($skip_field[$r][$c])) { continue; } $sql = 'SELECT * FROM screens_items WHERE screenid=' . $screenid . ' AND x=' . $c . ' AND y=' . $r; $iresult = DBSelect($sql); $irow = DBfetch($iresult); if ($irow) { $colspan = $irow['colspan']; $rowspan = $irow['rowspan']; } else { $colspan = 0; $rowspan = 0; } for ($i = 0; $i < $rowspan || $i == 0; $i++) { for ($j = 0; $j < $colspan || $j == 0; $j++) { if ($i != 0 || $j != 0) { $skip_field[$r + $i][$c + $j] = 1; } } } } } $table = new CTable(new CLink('No rows in screen ' . $row['name'], 'screenconf.php?config=0&form=update&screenid=' . $screenid), $editmode == 0 || $editmode == 2 ? 'screen_view' : 'screen_edit'); $table->setAttribute('id', 'iframe'); if ($editmode == 1) { $add_col_link = 'screenedit.php?config=1&screenid=' . $screenid . '&add_col='; $new_cols = array(new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1))); for ($c = 0; $c < $row['hsize'] + 1; $c++) { array_push($new_cols, new Ccol(new Clink(new Cimg('images/general/closed.gif'), $add_col_link . $c))); } $table->addRow($new_cols); } $empty_screen_col = array(); for ($r = 0; $r < $row['vsize']; $r++) { $new_cols = array(); $empty_screen_row = true; if ($editmode == 1) { $add_row_link = 'screenedit.php?config=1&screenid=' . $screenid . '&add_row='; array_push($new_cols, new Ccol(new Clink(new Cimg('images/general/closed.gif'), $add_row_link . $r))); } for ($c = 0; $c < $row['hsize']; $c++) { $item = array(); if (isset($skip_field[$r][$c])) { continue; } $item_form = false; $iresult = DBSelect('SELECT * FROM screens_items WHERE screenid=' . $screenid . ' AND x=' . $c . ' AND y=' . $r); $irow = DBfetch($iresult); if ($irow) { $screenitemid = $irow['screenitemid']; $resourcetype = $irow['resourcetype']; $resourceid = $irow['resourceid']; $width = $irow['width']; $height = $irow['height']; $colspan = $irow['colspan']; $rowspan = $irow['rowspan']; $elements = $irow['elements']; $valign = $irow['valign']; $halign = $irow['halign']; $style = $irow['style']; $url = $irow['url']; $dynamic = $irow['dynamic']; } else { $screenitemid = 0; $resourcetype = 0; $resourceid = 0; $width = 0; $height = 0; $colspan = 0; $rowspan = 0; $elements = 0; $valign = VALIGN_DEFAULT; $halign = HALIGN_DEFAULT; $style = 0; $url = ''; $dynamic = 0; } if ($screenitemid > 0) { $empty_screen_row = false; $empty_screen_col[$c] = 1; } if ($editmode == 1 && $screenitemid != 0) { $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&screenitemid=' . $screenitemid . "#form');"; $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitemid . '#form'; } else { if ($editmode == 1 && $screenitemid == 0) { $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&x=' . $c . '&y=' . $r . "#form');"; $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r . '#form'; } else { $action = NULL; } } if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r) { // click on empty field $item = get_screen_item_form(); $item_form = true; } else { if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitemid) == 0) { // click on element $item = get_screen_item_form(); $item_form = true; } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_GRAPH) { if ($editmode == 0) { $action = 'charts.php?graphid=' . $resourceid . url_param('period') . url_param('stime'); } $graphid = null; $graphtype = GRAPH_TYPE_NORMAL; $yaxis = 0; // GRAPH & ZOOM features $sql = 'SELECT MAX(g.graphid) as graphid, MAX(g.graphtype) as graphtype, MIN(gi.yaxisside) as yaxissidel, MAX(gi.yaxisside) as yaxissider,' . ' MAX(g.show_legend) as legend, MAX(g.show_3d) as show3d ' . ' FROM graphs g, graphs_items gi ' . ' WHERE g.graphid=' . $resourceid . ' AND gi.graphid=g.graphid '; $res = DBselect($sql); while ($graph = DBfetch($res)) { $graphid = $graph['graphid']; $graphtype = $graph['graphtype']; $yaxis = $graph['yaxissider']; $yaxis = $graph['yaxissidel'] == $yaxis ? $yaxis : 2; $legend = $graph['legend']; $graph3d = $graph['show3d']; } if ($yaxis == 2) { $shiftXleft = 60; $shiftXright = 60; } else { if ($yaxis == 0) { $shiftXleft = 60; $shiftXright = 20; } else { $shiftXleft = 10; $shiftXright = 60; } } //------------- // Host feature if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) { $def_items = array(); $di_res = get_graphitems_by_graphid($resourceid); while ($gitem = DBfetch($di_res)) { $def_items[] = $gitem; } $url = ''; if ($new_items = get_same_graphitems_for_host($def_items, $_REQUEST['hostid'])) { $url .= make_url_from_gitems($new_items); } $url = make_url_from_graphid($resourceid, false) . $url; } //------------- $default = false; if ($graphtype == GRAPH_TYPE_PIE || $graphtype == GRAPH_TYPE_EXPLODED) { if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) { $url = 'chart6.php?graphid=' . $resourceid; $default = true; } $g_img = new CImg($url . '&width=' . $width . '&height=' . $height . '&period=' . $effectiveperiod . url_param('stime') . '&legend=' . $legend . '&graph3d=' . $graph3d); } else { if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) { $url = 'chart2.php?graphid=' . $resourceid; $default = true; } $dom_graph_id = 'graph_' . $screenitemid . '_' . $resourceid; $g_img = new CImg($url . '&width=' . $width . '&height=' . $height . '&period=' . $effectiveperiod . url_param('stime')); $g_img->setAttribute('id', $dom_graph_id); if (!is_null($graphid) && $editmode != 1) { insert_js(' A_SBOX["' . $dom_graph_id . '"] = new Object;' . 'A_SBOX["' . $dom_graph_id . '"].shiftT = 17;' . 'A_SBOX["' . $dom_graph_id . '"].shiftL = ' . $shiftXleft . ';'); if (isset($_REQUEST['stime'])) { $stime = $_REQUEST['stime']; $stime = mktime(substr($stime, 8, 2), substr($stime, 10, 2), 0, substr($stime, 4, 2), substr($stime, 6, 2), substr($stime, 0, 4)); } else { $stime = 'null'; } global $page; if ($page['type'] == PAGE_TYPE_HTML) { zbx_add_post_js('graph_zoom_init("' . $dom_graph_id . '",' . $stime . ',' . $effectiveperiod . ',' . $width . ',' . $height . ', false);'); } else { $g_img->setAttribute('onload', 'javascript: graph_zoom_init("' . $dom_graph_id . '",' . $stime . ',' . $effectiveperiod . ',' . $width . ',' . $height . ', false);'); // insert_js('graph_zoom_init("'.$dom_graph_id.'",'.$stime.','.$effectiveperiod.','.$width.','.$height.', false);'); } } } if ($default && $editmode == 0) { $item = new CLink($g_img, $action); } else { $item =& $g_img; } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) { if ($editmode == 0) { $action = "history.php?action=showgraph&itemid={$resourceid}" . url_param("period") . url_param("inc") . url_param("dec"); } // Host feature if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) { if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) { $resourceid = $newitemid; } else { $resourceid = ''; } } //------------- $url = empty($resourceid) ? 'chart3.php?' : "chart.php?itemid={$resourceid}&"; $item = new CLink(new CImg($url . "width={$width}&height={$height}" . "&period={$effectiveperiod}" . url_param("stime")), $action); } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_MAP) { $image_map = new CImg("map.php?noedit=1&sysmapid={$resourceid}" . "&width={$width}&height={$height}"); if ($editmode == 0) { $action_map = get_action_map_by_sysmapid($resourceid); $image_map->SetMap($action_map->GetName()); $item = array($action_map, $image_map); } else { $item = $image_map; // $item = new CLink($image_map, $action); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) { // Host feature if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) { if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) { $resourceid = $newitemid; } else { $resourceid = 0; } } //------------- $item = array(get_screen_plaintext($resourceid, $elements, $style)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_STATUS_OF_TRIGGERS) { $params = array(); $params['groupid'] = get_request('tr_groupid', get_profile('web.screens.tr_groupid', 0)); $params['hostid'] = get_request('tr_hostid', get_profile('web.screens.tr_hostid', 0)); $params['limit'] = $elements; update_profile('web.screens.tr_groupid', $params['groupid'], PROFILE_TYPE_ID); update_profile('web.screens.tr_hostid', $params['hostid'], PROFILE_TYPE_ID); $tr_form = new CForm(); $cmbGroup = new CComboBox('tr_groupid', $params['groupid'], 'submit()'); $cmbHosts = new CComboBox('tr_hostid', $params['hostid'], 'submit()'); $cmbGroup->addItem(0, S_ALL_SMALL); $cmbHosts->addItem(0, S_ALL_SMALL); $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY); $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY); $available_triggers = get_accessible_triggers(PERM_READ_ONLY, PERM_RES_IDS_ARRAY); $sql = 'SELECT DISTINCT g.groupid,g.name ' . ' FROM groups g, hosts_groups hg, hosts h ' . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND hg.groupid=g.groupid ' . ' AND h.hostid=hg.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND EXISTS(SELECT i.itemid FROM items i WHERE i.status=' . ITEM_STATUS_ACTIVE . ' AND i.hostid=h.hostid ) ' . ' ORDER BY g.name'; $tresult = DBselect($sql); while ($tr_row = DBfetch($tresult)) { $cmbGroup->addItem($tr_row['groupid'], get_node_name_by_elid($tr_row['groupid']) . $tr_row['name']); } $tr_form->addItem(array(S_GROUP . SPACE, $cmbGroup)); $sql_from = ''; $sql_where = ''; if ($params['groupid'] > 0) { $sql_from .= ',hosts_groups hg '; $sql_where .= ' AND hg.hostid=h.hostid AND hg.groupid=' . $params['groupid']; } $sql = 'SELECT DISTINCT h.hostid,h.host ' . ' FROM hosts h, items i, functions f, triggers t ' . $sql_from . ' WHERE h.status=' . HOST_STATUS_MONITORED . $sql_where . ' AND h.hostid=i.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' ORDER BY h.host'; $tresult = DBselect($sql); while ($tr_row = DBfetch($tresult)) { $cmbHosts->addItem($tr_row['hostid'], get_node_name_by_elid($tr_row['hostid']) . $tr_row['host']); } $tr_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts)); $item = array(get_table_header(array(S_STATUS_OF_TRIGGERS_BIG, SPACE, date('[H:i:s]', time())), $tr_form)); //*/ // $item = array(); $item[] = make_latest_issues($params); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SYSTEM_STATUS) { $item = array(get_table_header(array(S_SYSTEM_STATUSBIG, SPACE, date('[H:i:s]', time())))); $item[] = make_system_summary(); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOSTS_INFO) { $item = array(new CHostsInfo($resourceid, $style)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) { $item = new CTriggersInfo($style); if ($resourceid > 0) { $item->set_host_group($resourceid); } $item = array($item); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SERVER_INFO) { // $item = array(get_table_header(S_STATUS_OF_ZABBIX_BIG),make_status_of_zbx()); $item = array(new CServerInfo()); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_CLOCK) { $item = new CFlashClock($width, $height, $style, $action); } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SCREEN) { $item = array(get_screen($resourceid, 2, $effectiveperiod)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_OVERVIEW) { $hostids = array(); $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid); while ($tmp_host = DBfetch($res)) { $hostids[$tmp_host['hostid']] = $tmp_host['hostid']; } $item = array(get_triggers_overview($hostids, $style)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_DATA_OVERVIEW) { $hostids = array(); $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid); while ($tmp_host = DBfetch($res)) { $hostids[$tmp_host['hostid']] = $tmp_host['hostid']; } $item = array(get_items_data_overview($hostids, $style)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_URL) { $item = array(new CIFrame($url, $width, $height, "auto")); if ($editmode == 1) { array_push($item, BR(), new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_ACTIONS) { $item = array(get_history_of_actions($elements)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_EVENTS) { $item = array(get_history_of_triggers_events(0, $elements)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { $item = array(SPACE); if ($editmode == 1) { array_push($item, BR(), new CLink(S_CHANGE, $action)); } } } } } } } } } } } } } } } } } } } $str_halign = 'def'; if ($halign == HALIGN_CENTER) { $str_halign = 'cntr'; } if ($halign == HALIGN_LEFT) { $str_halign = 'left'; } if ($halign == HALIGN_RIGHT) { $str_halign = 'right'; } $str_valign = 'def'; if ($valign == VALIGN_MIDDLE) { $str_valign = 'mdl'; } if ($valign == VALIGN_TOP) { $str_valign = 'top'; } if ($valign == VALIGN_BOTTOM) { $str_valign = 'bttm'; } if ($editmode == 1 && !$item_form) { $item = new CDiv($item, 'draggable'); $item->setAttribute('id', 'position_' . $r . '_' . $c); if ($editmode == 1) { $item->setAttribute('onclick', 'javascript: ' . $onclick_action); } } $new_col = new CCol($item, $str_halign . '_' . $str_valign); if ($colspan) { $new_col->SetColSpan($colspan); } if ($rowspan) { $new_col->SetRowSpan($rowspan); } array_push($new_cols, $new_col); } if ($editmode == 1) { $rmv_icon = new Cimg('images/general/opened.gif'); if ($empty_screen_row) { $rmv_row_link = 'javascript: location.href = ' . "'screenedit.php?config=1&screenid=" . $screenid . '&rmv_row=' . $r . "';"; } else { $rmv_row_link = "javascript: if(Confirm('This screen-row is not empty. Delete it?')){" . " location.href = 'screenedit.php?config=1&screenid=" . $screenid . "&rmv_row=" . $r . "';}"; } $rmv_icon->addAction('onclick', $rmv_row_link); array_push($new_cols, new Ccol($rmv_icon)); } $table->AddRow(new CRow($new_cols)); } if ($editmode == 1) { $add_row_link = 'screenedit.php?config=1&screenid=' . $screenid . '&add_row='; $new_cols = array(new Ccol(new Clink(new Cimg('images/general/closed.gif'), $add_row_link . $row['vsize']))); for ($c = 0; $c < $row['hsize']; $c++) { $rmv_icon = new Cimg('images/general/opened.gif'); if (isset($empty_screen_col[$c])) { $rmv_col_link = "javascript: if(Confirm('This screen-column is not empty. Delete it?')){" . " location.href = 'screenedit.php?config=1&screenid=" . $screenid . "&rmv_col=" . $c . "';}"; } else { $rmv_col_link = "javascript: location.href = 'screenedit.php?config=1&screenid=" . $screenid . "&rmv_col=" . $c . "';"; } $rmv_icon->addAction('onclick', $rmv_col_link); array_push($new_cols, new Ccol($rmv_icon)); } array_push($new_cols, new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1))); $table->addRow($new_cols); } return $table; }
$table->SetHeader(array(S_KEY, S_DESCRIPTION)); $result = DBselect("select * from help_items where itemtype=" . $itemtype . " ORDER BY key_"); while ($row = DBfetch($result)) { $name = new CLink($row["key_"], "#", "action"); if (isset($_REQUEST['reference']) && $_REQUEST['reference'] == 'dashboard') { $action = get_window_opener($dstfrm, $dstfld1, $srcfld2) . get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) . "window.opener.setTimeout('add2favorites();', 1000);"; } else { $action = get_window_opener($dstfrm, $dstfld1, html_entity_decode($row[$srcfld1])) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''); } $name->SetAction($action . " close_window(); return false;"); $table->addRow(array($name, $row["description"])); } $table->Show(); } else { if ($srctbl == 'triggers') { $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $available_hosts, PERM_RES_IDS_ARRAY, $nodeid); $form = new CForm(); $form->setAttribute('id', S_TRIGGERS); $table = new CTableInfo(S_NO_TRIGGERS_DEFINED); if ($multiselect) { insert_js_function('add_selected_values'); insert_js_function('check_all'); $header = array(new CCol(array(new CCheckBox("check", NULL, 'check_all("' . S_TRIGGERS . '", this.checked);'), S_NAME)), S_SEVERITY, S_STATUS); $button = new CButton('select', S_SELECT, 'add_selected_values("' . S_TRIGGERS . '", "' . $dstfrm . '", "' . $dstfld1 . '", "' . $dstact . '")'); $button->setType('button'); $table->setFooter(new CCol($button, 'right')); } else { insert_js_function('add_value'); $header = array(S_NAME, S_SEVERITY, S_STATUS); } $table->SetHeader($header);
$PAGE_HOSTS = get_viewed_hosts(PERM_READ_ONLY, $PAGE_GROUPS['selected'], $params); //SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']); validate_group_with_host($PAGE_GROUPS, $PAGE_HOSTS); //SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']); if (0 == $config) { $available_groups = $PAGE_GROUPS['groupids']; $available_hosts = $PAGE_HOSTS['hostids']; } else { $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY); if ($PAGE_HOSTS['selected'] != 0) { $PAGE_HOSTS['hostids'] = $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY); } else { $available_hosts = $PAGE_HOSTS['hostids']; } } $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $available_hosts); show_report2_header($config, $PAGE_GROUPS, $PAGE_HOSTS); if (isset($_REQUEST['triggerid'])) { if (isset($available_triggers[$_REQUEST['triggerid']])) { $sql = 'SELECT DISTINCT t.*, h.host, h.hostid ' . ' FROM triggers t, functions f, items i, hosts h ' . ' WHERE t.triggerid=' . $_REQUEST['triggerid'] . ' AND t.triggerid=f.triggerid ' . ' AND f.itemid=i.itemid ' . ' AND i.hostid=h.hostid '; $trigger_data = DBfetch(DBselect($sql)); } else { unset($_REQUEST['triggerid']); } } if (isset($_REQUEST['triggerid'])) { show_table_header(array(new CLink($trigger_data['host'], '?hostid=' . $trigger_data['hostid']), ' : "', expand_trigger_description_by_data($trigger_data), '"')); $table = new CTableInfo(null, 'graph'); $table->addRow(new CImg('chart4.php?triggerid=' . $_REQUEST['triggerid'])); $table->show(); } else {
function sysmap_accessible($sysmapid, $perm) { global $USER_DETAILS; $result = false; $sql = 'SELECT * ' . ' FROM sysmaps_elements ' . ' WHERE sysmapid=' . $sysmapid . ' AND ' . DBin_node('sysmapid', get_current_nodeid(null, $perm)); if ($db_result = DBselect($sql)) { $result = true; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, $perm, PERM_RES_IDS_ARRAY, get_current_nodeid(true)); //SDI($available_hosts); while (($se_data = DBfetch($db_result)) && $result) { switch ($se_data['elementtype']) { case SYSMAP_ELEMENT_TYPE_HOST: if (!isset($available_hosts[$se_data['elementid']])) { $result = false; } break; case SYSMAP_ELEMENT_TYPE_MAP: $result = sysmap_accessible($se_data['elementid'], $perm); break; case SYSMAP_ELEMENT_TYPE_TRIGGER: $available_triggers = get_accessible_triggers($perm, array(), PERM_RES_IDS_ARRAY); if (!isset($available_triggers[$se_data['elementid']])) { $result = false; } break; case SYSMAP_ELEMENT_TYPE_HOST_GROUP: $available_groups = get_accessible_groups_by_user($USER_DETAILS, $perm); if (!isset($available_groups[$se_data['elementid']])) { $result = false; } break; } } //SDI($se_data['elementid']); } else { if (DBselect('SELECT sysmapid FROM sysmaps WHERE sysmapid=' . $sysmapid . ' AND ' . DBin_node('sysmapid', get_current_nodeid($perm)))) { $result = true; } } return $result; }
function get_history_of_triggers_events($start, $num, $groupid = 0, $hostid = 0) { global $USER_DETAILS; $config = select_config(); $show_unknown = get_profile('web.events.filter.show_unknown', 0); $sql_from = $sql_cond = ''; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_LIST); $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_DATA_ARRAY, get_current_nodeid()); if ($hostid > 0) { $sql_cond = ' AND h.hostid=' . $hostid; } else { if ($groupid > 0) { $sql_from = ', hosts_groups hg '; $sql_cond = ' AND h.hostid=hg.hostid AND hg.groupid=' . $groupid; } else { $sql_from = ''; $sql_cond = ' AND ' . DBcondition('h.hostid', $available_hosts); } } //--- $triggers = array(); $trigger_list = array(); $sql = 'SELECT DISTINCT t.triggerid,t.priority,t.description,t.expression,h.host,t.type ' . ' FROM triggers t, functions f, items i, hosts h ' . $sql_from . ' WHERE ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.triggerid=f.triggerid ' . ' AND f.itemid=i.itemid ' . ' AND i.hostid=h.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . $sql_cond; $rez = DBselect($sql); while ($rowz = DBfetch($rez)) { $triggers[$rowz['triggerid']] = $rowz; array_push($trigger_list, $rowz['triggerid']); } $sql_cond = $show_unknown == 0 ? ' AND e.value<>' . TRIGGER_VALUE_UNKNOWN . ' ' : ''; $table = new CTableInfo(S_NO_EVENTS_FOUND); $table->SetHeader(array(S_TIME, is_show_all_nodes() ? S_NODE : null, $hostid == 0 ? S_HOST : null, S_DESCRIPTION, S_VALUE, S_SEVERITY)); if (!empty($triggers)) { $sql = 'SELECT e.eventid, e.objectid as triggerid, e.clock, e.value, e.acknowledged ' . ' FROM events e ' . ' WHERE e.object=' . EVENT_OBJECT_TRIGGER . ' AND ' . DBcondition('e.objectid', $trigger_list) . $sql_cond . ' ORDER BY e.eventid DESC'; $result = DBselect($sql, 10 * ($start + $num)); } $col = 0; $skip = $start; while (!empty($triggers) && $col < $num && ($row = DBfetch($result))) { if ($skip > 0) { if ($show_unknown == 0 && $row['value'] == TRIGGER_VALUE_UNKNOWN) { continue; } $skip--; continue; } $value = new CCol(trigger_value2str($row['value']), get_trigger_value_style($row['value'])); $row = array_merge($triggers[$row['triggerid']], $row); if (0 == $show_unknown && !event_initial_time($row, $show_unknown)) { continue; } $table->AddRow(array(date("Y.M.d H:i:s", $row["clock"]), get_node_name_by_elid($row['triggerid']), $hostid == 0 ? $row['host'] : null, new CLink(expand_trigger_description_by_data($row, ZBX_FLAG_EVENT), 'tr_events.php?triggerid=' . $row['triggerid'] . '&eventid=' . $row['eventid'], 'action'), $value, new CCol(get_severity_description($row["priority"]), get_severity_style($row["priority"])))); $col++; } return $table; }
//---------------------------------- CHECKS ------------------------------------ // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array("msg" => array(T_ZBX_STR, O_OPT, null, null, NULL), 'favobj' => array(T_ZBX_STR, O_OPT, P_ACT, IN("'hat'"), NULL), 'favid' => array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), 'state' => array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})')); check_fields($fields); /* AJAX */ if (isset($_REQUEST['favobj'])) { if ('hat' == $_REQUEST['favobj']) { update_profile('web.services.hats.' . $_REQUEST['favid'] . '.state', $_REQUEST['state'], PROFILE_TYPE_INT); } } if (PAGE_TYPE_JS == $page['type'] || PAGE_TYPE_HTML_BLOCK == $page['type']) { exit; } //-------- //-------------------------------------------------------------------------- $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY); $query = 'SELECT DISTINCT s.serviceid, sl.servicedownid, sl_p.serviceupid as serviceupid, s.triggerid, ' . ' s.name as caption, s.algorithm, t.description, t.expression, s.sortorder, sl.linkid, s.showsla, s.goodsla, s.status ' . ' FROM services s ' . ' LEFT JOIN triggers t ON s.triggerid = t.triggerid ' . ' LEFT JOIN services_links sl ON s.serviceid = sl.serviceupid and NOT(sl.soft=0) ' . ' LEFT JOIN services_links sl_p ON s.serviceid = sl_p.servicedownid and sl_p.soft=0 ' . ' WHERE ' . DBin_node('s.serviceid') . ' AND (t.triggerid IS NULL OR ' . DBcondition('t.triggerid', $available_triggers) . ') ' . ' ORDER BY s.sortorder, sl_p.serviceupid, s.serviceid'; $result = DBSelect($query); $services = array(); $row = array('id' => 0, 'serviceid' => 0, 'serviceupid' => 0, 'caption' => S_ROOT_SMALL, 'status' => SPACE, 'algorithm' => SPACE, 'description' => SPACE, 'soft' => 0, 'linkid' => ''); $services[0] = $row; while ($row = DBFetch($result)) { $row['id'] = $row['serviceid']; empty($row['serviceupid']) ? $row['serviceupid'] = '0' : ''; empty($row['triggerid']) ? $row['description'] = 'None' : ($row['description'] = expand_trigger_description($row['triggerid'])); if (isset($services[$row['serviceid']])) { $services[$row['serviceid']] = array_merge($services[$row['serviceid']], $row); } else { $services[$row['serviceid']] = $row; } if (isset($row['serviceupid'])) {
function insert_map_element_form() { global $USER_DETAILS; $frmEl = new CFormTable('New map element', 'sysmap.php'); $frmEl->SetHelp('web.sysmap.host.php'); $frmEl->addVar('sysmapid', $_REQUEST['sysmapid']); if (isset($_REQUEST['selementid'])) { $frmEl->addVar('selementid', $_REQUEST['selementid']); $element = get_sysmaps_element_by_selementid($_REQUEST['selementid']); $frmEl->SetTitle('Map element "' . $element['label'] . '"'); } if (isset($_REQUEST['selementid']) && !isset($_REQUEST['form_refresh'])) { $elementid = $element['elementid']; $elementtype = $element['elementtype']; $label = $element['label']; $x = $element['x']; $y = $element['y']; $url = $element['url']; $iconid_off = $element['iconid_off']; $iconid_on = $element['iconid_on']; $iconid_unknown = $element['iconid_unknown']; $iconid_disabled = $element['iconid_disabled']; $label_location = $element['label_location']; if (is_null($label_location)) { $label_location = -1; } } else { $elementid = get_request('elementid', 0); $elementtype = get_request('elementtype', SYSMAP_ELEMENT_TYPE_HOST); $label = get_request('label', ''); $x = get_request('x', 0); $y = get_request('y', 0); $url = get_request('url', ''); $iconid_off = get_request('iconid_off', 0); $iconid_on = get_request('iconid_on', 0); $iconid_unknown = get_request('iconid_unknown', 0); $iconid_disabled = get_request('iconid_disabled', 0); $label_location = get_request('label_location', '-1'); } $cmbType = new CComboBox('elementtype', $elementtype, 'submit()'); $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true)); $sql = 'SELECT DISTINCT n.name as node_name,h.hostid,h.host ' . ' FROM hosts h' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('h.hostid') . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' ORDER BY node_name,h.host'; $db_hosts = DBselect($sql); if ($db_hosts) { $cmbType->addItem(SYSMAP_ELEMENT_TYPE_HOST, S_HOST); } $db_maps = DBselect('SELECT sysmapid FROM sysmaps WHERE sysmapid!=' . $_REQUEST['sysmapid']); if (DBfetch($db_maps)) { $cmbType->addItem(SYSMAP_ELEMENT_TYPE_MAP, S_MAP); } $cmbType->addItem(SYSMAP_ELEMENT_TYPE_TRIGGER, S_TRIGGER); $cmbType->addItem(SYSMAP_ELEMENT_TYPE_HOST_GROUP, S_HOST_GROUP); $cmbType->addItem(SYSMAP_ELEMENT_TYPE_IMAGE, S_IMAGE); $frmEl->addRow(S_TYPE, $cmbType); $frmEl->addRow(S_LABEL, new CTextArea('label', $label, 32, 4)); $cmbLocation = new CComboBox('label_location', $label_location); $cmbLocation->addItem(-1, '-'); $cmbLocation->addItem(0, S_BOTTOM); $cmbLocation->addItem(1, S_LEFT); $cmbLocation->addItem(2, S_RIGHT); $cmbLocation->addItem(3, S_TOP); $frmEl->addRow(S_LABEL_LOCATION, $cmbLocation); if ($elementtype == SYSMAP_ELEMENT_TYPE_HOST) { $host = ''; $host_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,h.hostid,h.host ' . ' FROM hosts h ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('h.hostid') . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' AND hostid=' . $elementid . ' ORDER BY node_name,h.host')); if ($host_info) { $host = $host_info['host']; } else { $elementid = 0; } if ($elementid == 0) { $host = ''; $elementid = 0; } $frmEl->addVar('elementid', $elementid); $frmEl->addRow(S_HOST, array(new CTextBox('host', $host, 32, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmEl->GetName() . "&dstfld1=elementid&dstfld2=host&srctbl=hosts&srcfld1=hostid&srcfld2=host',450,450);", 'T'))); } else { if ($elementtype == SYSMAP_ELEMENT_TYPE_MAP) { $cmbMaps = new CComboBox('elementid', $elementid); $db_maps = DBselect('SELECT DISTINCT n.name as node_name,s.sysmapid,s.name ' . ' FROM sysmaps s' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('s.sysmapid') . ' ORDER BY node_name,s.name'); while ($db_map = DBfetch($db_maps)) { if (!sysmap_accessible($db_map['sysmapid'], PERM_READ_ONLY)) { continue; } $node_name = isset($db_map['node_name']) ? '(' . $db_map['node_name'] . ') ' : ''; $cmbMaps->addItem($db_map['sysmapid'], $node_name . $db_map['name']); } $frmEl->addRow(S_MAP, $cmbMaps); } else { if ($elementtype == SYSMAP_ELEMENT_TYPE_TRIGGER) { $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY, get_current_nodeid(true)); $trigger = ''; $trigger_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,h.hostid,h.host,t.*' . ' FROM triggers t ' . ' LEFT JOIN functions f on t.triggerid=f.triggerid ' . ' LEFT JOIN items i on i.itemid=f.itemid ' . ' LEFT JOIN hosts h on h.hostid=i.hostid ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('t.triggerid') . ' WHERE t.triggerid=' . $elementid . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' ORDER BY node_name,h.host,t.description')); if ($trigger_info) { $trigger = expand_trigger_description_by_data($trigger_info); } else { $elementid = 0; } if ($elementid == 0) { $trigger = ''; $elementid = 0; } $frmEl->addVar('elementid', $elementid); $frmEl->addRow(S_TRIGGER, array(new CTextBox('trigger', $trigger, 32, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmEl->GetName() . "&dstfld1=elementid&dstfld2=trigger&srctbl=triggers&srcfld1=triggerid&srcfld2=description');", 'T'))); } else { if ($elementtype == SYSMAP_ELEMENT_TYPE_HOST_GROUP) { $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true)); $group = ''; $group_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM groups g ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=' . $elementid . ' ORDER BY node_name,g.name')); if ($group_info) { $group = $group_info['name']; } else { $elementid = 0; } if ($elementid == 0) { $group = ''; $elementid = 0; } $frmEl->addVar('elementid', $elementid); $frmEl->addRow(S_HOST_GROUP, array(new CTextBox('group', $group, 32, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmEl->GetName() . "&dstfld1=elementid&dstfld2=group&srctbl=host_group&srcfld1=groupid&srcfld2=name',450,450);", 'T'))); } else { if ($elementtype == SYSMAP_ELEMENT_TYPE_IMAGE) { $frmEl->addVar('elementid', 0); } } } } } $cmbIconOff = new CComboBox('iconid_off', $iconid_off); $cmbIconOn = new CComboBox('iconid_on', $iconid_on); if ($elementtype != SYSMAP_ELEMENT_TYPE_MAP) { $cmbIconUnknown = new CComboBox('iconid_unknown', $iconid_unknown); } if ($elementtype != SYSMAP_ELEMENT_TYPE_HOST_GROUP && $elementtype != SYSMAP_ELEMENT_TYPE_MAP) { $cmbIconDisabled = new CComboBox('iconid_disabled', $iconid_disabled); } $result = DBselect('SELECT * FROM images WHERE imagetype=1 AND ' . DBin_node('imageid') . ' order by name'); while ($row = DBfetch($result)) { $row['name'] = get_node_name_by_elid($row['imageid']) . $row['name']; $cmbIconOff->addItem($row['imageid'], $row['name']); $cmbIconOn->addItem($row['imageid'], $row['name']); if ($elementtype != SYSMAP_ELEMENT_TYPE_MAP) { $cmbIconUnknown->addItem($row['imageid'], $row['name']); } if ($elementtype != SYSMAP_ELEMENT_TYPE_HOST_GROUP && $elementtype != SYSMAP_ELEMENT_TYPE_MAP) { $cmbIconDisabled->addItem($row['imageid'], $row['name']); } } $frmEl->addRow(S_ICON_OK, $cmbIconOff); if ($elementtype != SYSMAP_ELEMENT_TYPE_IMAGE) { $frmEl->addRow(S_ICON_PROBLEM, $cmbIconOn); } else { $frmEl->addVar('iconid_on', 0); } if ($elementtype != SYSMAP_ELEMENT_TYPE_MAP && $elementtype != SYSMAP_ELEMENT_TYPE_IMAGE) { $frmEl->addRow(S_ICON_UNKNOWN, $cmbIconUnknown); } else { $frmEl->addVar('iconid_unknown', 0); } if ($elementtype != SYSMAP_ELEMENT_TYPE_HOST_GROUP && $elementtype != SYSMAP_ELEMENT_TYPE_MAP && $elementtype != SYSMAP_ELEMENT_TYPE_IMAGE) { $frmEl->addRow(S_ICON_DISABLED, $cmbIconDisabled); } else { $frmEl->addVar('iconid_disabled', 0); } $frmEl->addRow(S_COORDINATE_X, new CNumericBox('x', $x, 5)); $frmEl->addRow(S_COORDINATE_Y, new CNumericBox('y', $y, 5)); $frmEl->addRow(S_URL, new CTextBox('url', $url, 64)); $frmEl->addItemToBottomRow(new CButton('save', S_SAVE)); if (isset($_REQUEST['selementid'])) { $frmEl->addItemToBottomRow(SPACE); $frmEl->addItemToBottomRow(new CButtonDelete('Delete element?', url_param('form') . url_param('selementid') . url_param('sysmapid'))); } $frmEl->addItemToBottomRow(SPACE); $frmEl->addItemToBottomRow(new CButtonCancel(url_param('sysmapid'))); $frmEl->Show(); }
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ require_once 'include/config.inc.php'; require_once 'include/triggers.inc.php'; $page['file'] = 'chart4.php'; $page['title'] = "S_CHART"; $page['type'] = PAGE_TYPE_IMAGE; include_once 'include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('triggerid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, NULL)); check_fields($fields); $sql = 'SELECT DISTINCT i.hostid ' . ' FROM functions f, items i ' . ' WHERE f.triggerid=' . $_REQUEST['triggerid'] . ' AND i.itemid=f.itemid'; if (!($host = DBfetch(DBselect($sql)))) { fatal_error(S_NO_TRIGGER_DEFINED); } $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array($host['hostid'])); $sql = 'SELECT DISTINCT t.triggerid,t.description,t.expression, h.host,h.hostid ' . ' FROM hosts h, items i, functions f, triggers t' . ' WHERE h.hostid=i.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ' . ' AND t.triggerid=' . $_REQUEST['triggerid'] . ' AND ' . DBcondition('t.triggerid', $available_triggers); if (!($db_data = DBfetch(DBselect($sql)))) { access_deny(); } $start_time = time(NULL); $sizeX = 900; $sizeY = 300; $shiftX = 12; $shiftYup = 17; $shiftYdown = 25 + 15 * 3; $im = imagecreate($sizeX + $shiftX + 61, $sizeY + $shiftYup + $shiftYdown + 10); $red = imagecolorallocate($im, 255, 0, 0); $darkred = imagecolorallocate($im, 150, 0, 0); $green = imagecolorallocate($im, 0, 255, 0); $darkgreen = imagecolorallocate($im, 0, 150, 0);
// <<<--- FULL_CLONE --->>> if (!zbx_empty($templateid) && $templateid && $clone_templateid && $_REQUEST['form'] == 'full_clone') { // Host applications $sql = 'SELECT * FROM applications WHERE hostid=' . $clone_templateid . ' AND templateid=0'; $res = DBselect($sql); while ($db_app = DBfetch($res)) { add_application($db_app['name'], $templateid, 0); } // Host items $sql = 'SELECT DISTINCT i.itemid, i.description ' . ' FROM items i ' . ' WHERE i.hostid=' . $clone_templateid . ' AND i.templateid=0 ' . ' ORDER BY i.description'; $res = DBselect($sql); while ($db_item = DBfetch($res)) { $result &= copy_item_to_host($db_item['itemid'], $templateid, true); } // Host triggers $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array($clone_templateid), PERM_RES_IDS_ARRAY); $sql = 'SELECT DISTINCT t.triggerid, t.description ' . ' FROM triggers t, items i, functions f' . ' WHERE i.hostid=' . $clone_templateid . ' AND f.itemid=i.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.templateid=0 ' . ' ORDER BY t.description'; $res = DBselect($sql); while ($db_trig = DBfetch($res)) { $result &= copy_trigger_to_host($db_trig['triggerid'], $templateid, true); } // Host graphs $available_graphs = get_accessible_graphs(PERM_READ_ONLY, array($clone_templateid), PERM_RES_IDS_ARRAY); $sql = 'SELECT DISTINCT g.graphid, g.name ' . ' FROM graphs g, graphs_items gi,items i ' . ' WHERE ' . DBcondition('g.graphid', $available_graphs) . ' AND gi.graphid=g.graphid ' . ' AND g.templateid=0 ' . ' AND i.itemid=gi.itemid ' . ' AND i.hostid=' . $clone_templateid . ' ORDER BY g.name'; $res = DBselect($sql); while ($db_graph = DBfetch($res)) { $result &= copy_graph_to_host($db_graph['graphid'], $templateid, true); } } // --->>> <<<--- // <<<--- LINK/UNLINK HOSTS --->>>