public function addItem($itemid, $calc_fnc = CALC_FNC_AVG, $color = null, $type = null, $periods_cnt = null) { $this->items[$this->num] = get_item_by_itemid($itemid); $this->items[$this->num]['description'] = item_description($this->items[$this->num]); $host = get_host_by_hostid($this->items[$this->num]['hostid']); $this->items[$this->num]['host'] = $host['host']; $this->items[$this->num]['color'] = is_null($color) ? 'Dark Green' : $color; $this->items[$this->num]['calc_fnc'] = is_null($calc_fnc) ? CALC_FNC_AVG : $calc_fnc; $this->items[$this->num]['calc_type'] = is_null($type) ? GRAPH_ITEM_SIMPLE : $type; $this->items[$this->num]['periods_cnt'] = is_null($periods_cnt) ? 0 : $periods_cnt; $this->num++; }
public function addItem($itemid, $axis = GRAPH_YAXIS_SIDE_RIGHT, $calc_fnc = CALC_FNC_AVG, $color = null, $drawtype = null, $type = null, $periods_cnt = null) { if ($this->type == GRAPH_TYPE_STACKED) { $drawtype = GRAPH_ITEM_DRAWTYPE_FILLED_REGION; } $this->items[$this->num] = get_item_by_itemid($itemid); $this->items[$this->num]['description'] = item_description($this->items[$this->num]); $host = get_host_by_hostid($this->items[$this->num]['hostid']); $this->items[$this->num]['host'] = $host['host']; $this->items[$this->num]['color'] = is_null($color) ? 'Dark Green' : $color; $this->items[$this->num]['drawtype'] = is_null($drawtype) ? GRAPH_ITEM_DRAWTYPE_LINE : $drawtype; $this->items[$this->num]['axisside'] = is_null($axis) ? GRAPH_YAXIS_SIDE_RIGHT : $axis; $this->items[$this->num]['calc_fnc'] = is_null($calc_fnc) ? CALC_FNC_AVG : $calc_fnc; $this->items[$this->num]['calc_type'] = is_null($type) ? GRAPH_ITEM_SIMPLE : $type; $this->items[$this->num]['periods_cnt'] = is_null($periods_cnt) ? 0 : $periods_cnt; if ($this->items[$this->num]['axisside'] == GRAPH_YAXIS_SIDE_LEFT) { $this->yaxisleft = 1; } if ($this->items[$this->num]['axisside'] == GRAPH_YAXIS_SIDE_RIGHT) { $this->yaxisright = 1; } // SDI($this->items); $this->num++; }
$priority = get_request('priority', 0); $comments = get_request('comments', ''); $url = get_request('url', ''); $status = get_request('status', 0); } $keys = get_request('keys', array()); //sdi('<pre>'.print_r($expressions, true).'</pre>'); $frmTRLog->addRow(S_DESCRIPTION, new CTextBox('description', $description, 80)); $item = ''; $db_items = DBselect('SELECT DISTINCT * FROM items WHERE itemid=' . $itemid); while ($db_item = DBfetch($db_items)) { if ($db_item['templateid']) { $template_host = get_realhost_by_itemid($db_item['templateid']); $item = $template_host['host'] . ':'; } $item .= item_description($db_item, $db_item['key_']); } $ctb = new CTextBox('item', $item, 80); $ctb->setAttribute('id', 'item'); $ctb->setAttribute('disabled', 'disabled'); $script = "javascript: return PopUp('popup.php?dstfrm=" . $frmTRLog->getName() . "&dstfld1=itemid&dstfld2=item&srctbl=items&srcfld1=itemid&srcfld2=description',800,450);"; $cbtn = new CButton('select_item', S_SELECT, $script); $frmTRLog->addRow(S_ITEM, array($ctb, $cbtn)); $frmTRLog->addVar('itemid', $itemid); $exp_select = new CComboBox('expr_type'); $exp_select->setAttribute('id', 'expr_type'); $exp_select->addItem(REGEXP_INCLUDE, S_INCLUDE_S); $exp_select->addItem(REGEXP_EXCLUDE, S_EXCLUDE); $ctb = new CTextBox('expression', '', 80); $ctb->setAttribute('id', 'logexpr'); $cb = new CButton('add_exp', S_ADD, 'javascript: add_logexpr();');
public function addItem($itemid, $axis = GRAPH_YAXIS_SIDE_DEFAULT, $calc_fnc = CALC_FNC_AVG, $color = null, $drawtype = null, $type = null, $periods_cnt = null) { if ($this->type == GRAPH_TYPE_STACKED) { $drawtype = GRAPH_ITEM_DRAWTYPE_FILLED_REGION; } $item = get_item_by_itemid($itemid); $this->items[$this->num] = $item; $this->items[$this->num]['description'] = item_description($item); $this->items[$this->num]['delay'] = getItemDelay($item['delay'], $item['delay_flex']); if (strpos($item['units'], ',') !== false) { list($this->items[$this->num]['units'], $this->items[$this->num]['unitsLong']) = explode(',', $item['units']); } else { $this->items[$this->num]['unitsLong'] = ''; } $host = get_host_by_hostid($item['hostid']); $this->items[$this->num]['host'] = $host['host']; $this->items[$this->num]['color'] = is_null($color) ? 'Dark Green' : $color; $this->items[$this->num]['drawtype'] = is_null($drawtype) ? GRAPH_ITEM_DRAWTYPE_LINE : $drawtype; $this->items[$this->num]['axisside'] = is_null($axis) ? GRAPH_YAXIS_SIDE_DEFAULT : $axis; $this->items[$this->num]['calc_fnc'] = is_null($calc_fnc) ? CALC_FNC_AVG : $calc_fnc; $this->items[$this->num]['calc_type'] = is_null($type) ? GRAPH_ITEM_SIMPLE : $type; $this->items[$this->num]['periods_cnt'] = is_null($periods_cnt) ? 0 : $periods_cnt; if ($this->items[$this->num]['axisside'] == GRAPH_YAXIS_SIDE_LEFT) { $this->yaxisleft = 1; } if ($this->items[$this->num]['axisside'] == GRAPH_YAXIS_SIDE_RIGHT) { $this->yaxisright = 1; } $this->num++; }
function make_graph_submenu() { $graphids = array(); $fav_graphs = get_favorites('web.favorite.graphids'); foreach ($fav_graphs as $key => $favorite) { $source = $favorite['source']; $sourceid = $favorite['value']; if ('itemid' == $source) { if (!($item = get_item_by_itemid($sourceid))) { continue; } $item_added = true; $host = get_host_by_itemid($sourceid); $item["description"] = item_description($item); $graphids[] = array('name' => $host['host'] . ':' . $item['description'], 'favobj' => 'itemid', 'favid' => $sourceid, 'action' => 'remove'); } else { if (!($graph = get_graph_by_graphid($sourceid))) { continue; } $graph_added = true; $result = get_hosts_by_graphid($sourceid); $ghost = DBFetch($result); $graphids[] = array('name' => $ghost['host'] . ':' . $graph['name'], 'favobj' => 'graphid', 'favid' => $sourceid, 'action' => 'remove'); } } if (isset($graph_added)) { $graphids[] = array('name' => S_REMOVE . SPACE . S_ALL_S . SPACE . S_GRAPHS, 'favobj' => 'graphid', 'favid' => 0, 'action' => 'remove'); } if (isset($item_added)) { $graphids[] = array('name' => S_REMOVE . SPACE . S_ALL_S . SPACE . S_SIMPLE_GRAPHS, 'favobj' => 'itemid', 'favid' => 0, 'action' => 'remove'); } return $graphids; }
function delete_application($applicationids) { $applicationids = zbx_toHash($applicationids); $apps = array(); $sql = 'SELECT a.applicationid, h.host, a.name, a.templateid ' . ' FROM applications a, hosts h ' . ' WHERE ' . DBcondition('a.applicationid', $applicationids) . ' AND h.hostid=a.hostid'; $res = DBselect($sql); while ($db_app = DBfetch($res)) { $apps[$db_app['applicationid']] = $db_app; } // first delete child applications $tmp_appids = array(); $sql = 'SELECT a.applicationid ' . ' FROM applications a ' . ' WHERE ' . DBcondition('a.templateid', $applicationids); $db_applications = DBselect($sql); while ($db_app = DBfetch($db_applications)) { $tmp_appids[$db_app['applicationid']] = $db_app['applicationid']; } if (!empty($tmp_appids)) { // recursion!!! if (!delete_application($tmp_appids)) { return false; } } $unlink_apps = array(); //check if app is used by web scenario $sql = 'SELECT ht.name, ht.applicationid ' . ' FROM httptest ht ' . ' WHERE ' . DBcondition('ht.applicationid', $applicationids); $res = DBselect($sql); while ($info = DBfetch($res)) { if ($apps[$info['applicationid']]['templateid'] > 0) { $unlink_apps[$info['applicationid']] = $info['applicationid']; unset($applicationids[$info['applicationid']]); } else { error(S_APPLICATION . ' [' . $apps[$info['applicationid']]['host'] . ':' . $apps[$info['applicationid']]['name'] . '] ' . S_USED_IN_WEB_SCENARIO); return false; } } $sql = 'SELECT i.itemid, i.key_, i.description, ia.applicationid ' . ' FROM items_applications ia, items i ' . ' WHERE i.type=' . ITEM_TYPE_HTTPTEST . ' AND i.itemid=ia.itemid ' . ' AND ' . DBcondition('ia.applicationid', $applicationids); $res = DBselect($sql); if ($info = DBfetch($res)) { error(S_APPLICATION . ' [' . $apps[$info['applicationid']]['host'] . ':' . $apps[$info['applicationid']]['name'] . '] ' . S_USED_BY_ITEM_SMALL . ' [' . item_description($info) . ']'); return false; } $result = DBexecute('UPDATE applications SET templateid=0 WHERE ' . DBcondition('applicationid', $unlink_apps)); $result &= DBexecute('DELETE FROM items_applications WHERE ' . DBcondition('applicationid', $applicationids)); $result &= DBexecute('DELETE FROM applications WHERE ' . DBcondition('applicationid', $applicationids)); if ($result) { foreach ($apps as $appid => $app) { if (isset($unlink_apps[$appid])) { info(S_APPLICATION . ' [' . $app['host'] . ':' . $app['name'] . '] ' . S_USED_IN_WEB_SCENARIO . ' (' . S_UNLINKED_SMALL . ')'); } else { info(S_APPLICATION . ' [' . $app['host'] . ':' . $app['name'] . '] ' . S_DELETED_SMALL); } } } return $result; }
} // OTHER ITEMS (which doesn't linked to application) $db_hosts = array(); $db_hostids = array(); $sql = 'SELECT DISTINCT h.host,h.hostid ' . ' FROM hosts h' . $sql_from . ', items i ' . ' LEFT JOIN items_applications ia ON ia.itemid=i.itemid' . ' WHERE ia.itemid is NULL ' . $sql_where . ' AND h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' ORDER BY h.host'; $db_host_res = DBselect($sql); while ($db_host = DBfetch($db_host_res)) { $db_host['item_cnt'] = 0; $db_hosts[$db_host['hostid']] = $db_host; $db_hostids[$db_host['hostid']] = $db_host['hostid']; } $tab_rows = array(); $sql = 'SELECT DISTINCT h.host,h.hostid,i.* ' . ' FROM hosts h' . $sql_from . ', items i ' . ' LEFT JOIN items_applications ia ON ia.itemid=i.itemid' . ' WHERE ia.itemid is NULL ' . $sql_where . ' AND h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('h.hostid', $db_hostids) . ' ORDER BY i.description,i.itemid'; $db_items = DBselect($sql); while ($db_item = DBfetch($db_items)) { $description = item_description($db_item); if (!empty($_REQUEST['select']) && !zbx_stristr($description, $_REQUEST['select'])) { continue; } $db_host =& $db_hosts[$db_item['hostid']]; if (!isset($tab_rows[$db_host['hostid']])) { $tab_rows[$db_host['hostid']] = array(); } $app_rows =& $tab_rows[$db_host['hostid']]; $db_host['item_cnt']++; if (!uint_in_array(0, $_REQUEST['applications']) && !isset($show_all_apps)) { continue; } if (isset($db_item['lastclock'])) { $lastclock = zbx_date2str(S_DATE_FORMAT_YMDHMS, $db_item['lastclock']); } else {
$_REQUEST['param'] = ltrim($_REQUEST['param'], '#'); } $operator = $expr_res[count($expr_res) - 2]; $_REQUEST['expr_type'] = $expr_res[ZBX_SIMPLE_EXPRESSION_FUNCTION_NAME_ID] . '[' . $operator . ']'; $_REQUEST['value'] = $expr_res[count($expr_res) - 1]; } } unset($expr_res); $dstfrm = get_request("dstfrm", 0); // destination form $dstfld1 = get_request("dstfld1", ''); // destination field $itemid = get_request("itemid", 0); $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY); if ($item_data = DBfetch(DBselect('SELECT DISTINCT h.host,i.* ' . ' FROM hosts h,items i ' . ' WHERE h.hostid=i.hostid ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND i.itemid=' . $itemid))) { $description = $item_data['host'] . ':' . item_description($item_data); } else { $itemid = 0; $description = ''; } $expr_type = get_request("expr_type", 'last[=]'); if (eregi('^([a-z]{1,})\\[([' . implode('', array_keys($operators)) . '])\\]$', $expr_type, $expr_res)) { $function = $expr_res[1]; $operator = $expr_res[2]; if (!str_in_array($function, array_keys($functions))) { unset($function); } } unset($expr_res); if (!isset($function)) { $function = 'last';
if (!($row = get_row_for_nofalseforb($row, $event_sql))) { continue; } } $triggers_num++; $row['events'] = array(); $row['items'] = array(); $triggers[$row['triggerid']] = $row; $triggerids[$row['triggerid']] = $row['triggerid']; } $sql = 'SELECT f.triggerid, i.* ' . ' FROM functions f, items i ' . ' WHERE ' . DBcondition('f.triggerid', $triggerids) . ' AND i.itemid=f.itemid'; $result = DBselect($sql); while ($row = DBfetch($result)) { $item['itemid'] = $row['itemid']; $item['action'] = str_in_array($row['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues'; $item['description'] = item_description($row); $triggers[$row['triggerid']]['items'][$row['itemid']] = $item; } $event_sql = 'SELECT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type ' . ' FROM events e, triggers t ' . ' WHERE e.object=0 ' . ' AND ' . DBcondition('e.objectid', $triggerids) . ' AND t.triggerid=e.objectid ' . $event_cond . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC'; $res_events = DBSelect($event_sql, $config['event_show_max'] * 100); while ($row_event = DBfetch($res_events)) { if ($show_events == EVENTS_OPTION_NOFALSEFORB) { if (EVENTS_NOFALSEFORB_STATUS_FALSE == $show_events_status && $row_event['value'] != TRIGGER_VALUE_FALSE) { continue; } if (EVENTS_NOFALSEFORB_STATUS_TRUE == $show_events_status && $row_event['value'] != TRIGGER_VALUE_TRUE) { continue; } if ($row_event['value'] == TRIGGER_VALUE_FALSE && !event_initial_time($row_event)) { continue; }
function get_items_data_overview($hostids, $view_style = null) { if (is_null($view_style)) { $view_style = get_profile('web.overview.view.style', STYLE_TOP); } $table = new CTableInfo(S_NO_ITEMS_DEFINED); COpt::profiling_start('prepare data'); $result = DBselect('SELECT DISTINCT h.hostid, h.host,i.itemid, i.key_, i.value_type, i.lastvalue, i.units, ' . ' i.description, t.priority, i.valuemapid, t.value as tr_value, t.triggerid ' . ' FROM hosts h, items i ' . ' LEFT JOIN functions f on f.itemid=i.itemid ' . ' LEFT JOIN triggers t on t.triggerid=f.triggerid ' . ' WHERE ' . DBcondition('h.hostid', $hostids) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' ORDER BY i.description,i.itemid'); unset($items); unset($hosts); // get rid of warnings about $triggers undefined $items = array(); while ($row = DBfetch($result)) { $descr = item_description($row); $row['host'] = get_node_name_by_elid($row['hostid']) . $row['host']; $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($items[$descr][$row['host']]) || ($items[$descr][$row['host']]['tr_value'] == TRIGGER_VALUE_FALSE && $row['tr_value'] == TRIGGER_VALUE_TRUE || ($items[$descr][$row['host']]['tr_value'] == TRIGGER_VALUE_FALSE || $row['tr_value'] == TRIGGER_VALUE_TRUE) && $row['priority'] > $items[$descr][$row['host']]['severity'])) { $items[$descr][$row['host']] = array('itemid' => $row['itemid'], 'value_type' => $row['value_type'], 'lastvalue' => $row['lastvalue'], 'units' => $row['units'], 'description' => $row['description'], 'valuemapid' => $row['valuemapid'], 'severity' => $row['priority'], 'tr_value' => $row['tr_value'], 'triggerid' => $row['triggerid']); } } if (!isset($hosts)) { return $table; } ksort($hosts); COpt::profiling_stop('prepare data'); COpt::profiling_start('prepare table'); if ($view_style == STYLE_TOP) { $header = array(new CCol(S_ITEMS, 'center')); foreach ($hosts as $hostname) { $header = array_merge($header, array(new CImg('vtext.php?text=' . $hostname))); } $table->SetHeader($header, 'vertical_header'); $curr_rime = time(); foreach ($items as $descr => $ithosts) { $table_row = array(nbsp($descr)); foreach ($hosts as $hostname) { $table_row = get_item_data_overview_cells($table_row, $ithosts, $hostname); } $table->AddRow($table_row); } } else { $header = array(new CCol(S_HOSTS, 'center')); foreach ($items as $descr => $ithosts) { $header = array_merge($header, array(new CImg('vtext.php?text=' . $descr))); } $table->SetHeader($header, 'vertical_header'); $curr_rime = time(); foreach ($hosts as $hostname) { $table_row = array(nbsp($hostname)); foreach ($items as $descr => $ithosts) { $table_row = get_item_data_overview_cells($table_row, $ithosts, $hostname); } $table->AddRow($table_row); } } COpt::profiling_stop('prepare table'); return $table; }
function insert_template_form() { global $USER_DETAILS; $groups = get_request('groups', array()); $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_WRITE); $newgroup = get_request('newgroup', ''); $host = get_request('host', ''); $port = get_request('port', get_profile('HOST_PORT', 10050)); $status = get_request('status', HOST_STATUS_MONITORED); $useip = get_request('useip', 0); $dns = get_request('dns', ''); $ip = get_request('ip', '0.0.0.0'); $proxy_hostid = get_request('proxy_hostid', ''); $useipmi = get_request('useipmi', 'no'); $ipmi_ip = get_request('ipmi_ip', ''); $ipmi_port = get_request('ipmi_port', 623); $ipmi_authtype = get_request('ipmi_authtype', -1); $ipmi_privilege = get_request('ipmi_privilege', 2); $ipmi_username = get_request('ipmi_username', ''); $ipmi_password = get_request('ipmi_password', ''); $useprofile = get_request('useprofile', 'no'); $devicetype = get_request('devicetype', ''); $name = get_request('name', ''); $os = get_request('os', ''); $serialno = get_request('serialno', ''); $tag = get_request('tag', ''); $macaddress = get_request('macaddress', ''); $hardware = get_request('hardware', ''); $software = get_request('software', ''); $contact = get_request('contact', ''); $location = get_request('location', ''); $notes = get_request('notes', ''); $templates = get_request('templates', array()); $clear_templates = get_request('clear_templates', array()); $frm_title = S_TEMPLATE; if ($_REQUEST['hostid'] > 0) { $db_host = get_host_by_hostid($_REQUEST['hostid']); $frm_title .= SPACE . ' [' . $db_host['host'] . ']'; $original_templates = get_templates_by_hostid($_REQUEST['hostid']); } else { $original_templates = array(); } if ($_REQUEST['hostid'] > 0 && !isset($_REQUEST['form_refresh'])) { $proxy_hostid = $db_host['proxy_hostid']; $host = $db_host['host']; $port = $db_host['port']; $status = $db_host['status']; $useip = $db_host['useip']; $useipmi = $db_host['useipmi'] ? 'yes' : 'no'; $ip = $db_host['ip']; $dns = $db_host['dns']; $ipmi_ip = $db_host['ipmi_ip']; $ipmi_port = $db_host['ipmi_port']; $ipmi_authtype = $db_host['ipmi_authtype']; $ipmi_privilege = $db_host['ipmi_privilege']; $ipmi_username = $db_host['ipmi_username']; $ipmi_password = $db_host['ipmi_password']; // add groups $db_groups = DBselect('SELECT DISTINCT groupid ' . ' FROM hosts_groups ' . ' WHERE hostid=' . $_REQUEST['hostid'] . ' AND ' . DBcondition('groupid', $available_groups)); while ($db_group = DBfetch($db_groups)) { if (uint_in_array($db_group['groupid'], $groups)) { continue; } $groups[$db_group['groupid']] = $db_group['groupid']; } $templates = $original_templates; } $clear_templates = array_intersect($clear_templates, array_keys($original_templates)); $clear_templates = array_diff($clear_templates, array_keys($templates)); asort($templates); $frmHost = new CFormTable($frm_title, 'hosts.php'); $frmHost->setHelp('web.hosts.host.php'); $frmHost->addVar('config', get_request('config', 0)); $frmHost->addVar('clear_templates', $clear_templates); if ($_REQUEST['hostid'] > 0) { $frmHost->addVar('hostid', $_REQUEST['hostid']); } if ($_REQUEST['groupid'] > 0) { $frmHost->addVar('groupid', $_REQUEST['groupid']); } $frmHost->addRow(S_NAME, new CTextBox('host', $host, 54)); $grp_tb = new CTweenBox($frmHost, 'groups', $groups, 10); $db_groups = DBselect('SELECT DISTINCT groupid,name ' . ' FROM groups ' . ' WHERE ' . DBcondition('groupid', $available_groups) . ' ORDER BY name'); while ($db_group = DBfetch($db_groups)) { $grp_tb->addItem($db_group['groupid'], $db_group['name']); } $frmHost->addRow(S_GROUPS, $grp_tb->get(S_IN . SPACE . S_GROUPS, S_OTHER . SPACE . S_GROUPS)); $frmHost->addRow(S_NEW_GROUP, new CTextBox('newgroup', $newgroup), 'new'); // onchange does not work on some browsers: MacOS, KDE browser $frmHost->addVar('useip', 0); $frmHost->addVar('ip', '0.0.0.0'); $frmHost->addVar('dns', ''); $port = '10050'; $status = HOST_STATUS_TEMPLATE; $frmHost->addVar('port', $port); $frmHost->addVar('status', $status); $template_table = new CTable(); $template_table->SetCellPadding(0); $template_table->SetCellSpacing(0); foreach ($templates as $id => $temp_name) { $frmHost->addVar('templates[' . $id . ']', $temp_name); $template_table->addRow(array($temp_name, new CButton('unlink[' . $id . ']', S_UNLINK), isset($original_templates[$id]) ? new CButton('unlink_and_clear[' . $id . ']', S_UNLINK_AND_CLEAR) : SPACE)); } $frmHost->addRow(S_LINK_WITH_TEMPLATE, array($template_table, new CButton('add_template', S_ADD, "return PopUp('popup.php?dstfrm=" . $frmHost->GetName() . "&dstfld1=new_template&srctbl=templates&srcfld1=hostid&srcfld2=host" . url_param($templates, false, 'existed_templates') . "',450,450)", 'T'))); $frmHost->addVar('useipmi', $useipmi); $frmHost->addVar('ipmi_ip', $ipmi_ip); $frmHost->addVar('ipmi_port', $ipmi_port); $frmHost->addVar('ipmi_authtype', $ipmi_authtype); $frmHost->addVar('ipmi_privilege', $ipmi_privilege); $frmHost->addVar('ipmi_username', $ipmi_username); $frmHost->addVar('ipmi_password', $ipmi_password); $useprofile = 'no'; $frmHost->addVar('useprofile', $useprofile); $useprofile_ext = 'no'; $frmHost->addVar('useprofile_ext', $useprofile_ext); if ($_REQUEST['form'] == 'full_clone') { // Host items $items_lbx = new CListBox('items', null, 8); $items_lbx->setAttribute('disabled', 'disabled'); $sql = 'SELECT * ' . ' FROM items ' . ' WHERE hostid=' . $_REQUEST['hostid'] . ' AND templateid=0 ' . ' ORDER BY description'; $host_items_res = DBselect($sql); while ($host_item = DBfetch($host_items_res)) { $item_description = item_description($host_item); $items_lbx->addItem($host_item['itemid'], $item_description); } if ($items_lbx->ItemsCount() < 1) { $items_lbx->setAttribute('style', 'width: 200px;'); } $frmHost->addRow(S_ITEMS, $items_lbx); // Host triggers $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array($_REQUEST['hostid']), PERM_RES_IDS_ARRAY); $trig_lbx = new CListBox('triggers', null, 8); $trig_lbx->setAttribute('disabled', 'disabled'); $sql = 'SELECT DISTINCT t.* ' . ' FROM triggers t, items i, functions f' . ' WHERE i.hostid=' . $_REQUEST['hostid'] . ' AND f.itemid=i.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.templateid=0 ' . ' ORDER BY t.description'; $host_trig_res = DBselect($sql); while ($host_trig = DBfetch($host_trig_res)) { $trig_description = expand_trigger_description($host_trig["triggerid"]); $trig_lbx->addItem($host_trig['triggerid'], $trig_description); } if ($trig_lbx->ItemsCount() < 1) { $trig_lbx->setAttribute('style', 'width: 200px;'); } $frmHost->addRow(S_TRIGGERS, $trig_lbx); // Host graphs $available_graphs = get_accessible_graphs(PERM_READ_ONLY, array($_REQUEST['hostid']), PERM_RES_IDS_ARRAY); $graphs_lbx = new CListBox('graphs', null, 8); $graphs_lbx->setAttribute('disabled', 'disabled'); $def_items = array(); $sql = 'SELECT DISTINCT g.* ' . ' 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=' . $_REQUEST['hostid'] . ' ORDER BY g.name'; $host_graph_res = DBselect($sql); while ($host_graph = DBfetch($host_graph_res)) { $graphs_lbx->addItem($host_graph['graphid'], $host_graph['name']); } if ($graphs_lbx->ItemsCount() < 1) { $graphs_lbx->setAttribute('style', 'width: 200px;'); } $frmHost->addRow(S_GRAPHS, $graphs_lbx); } $frmHost->addItemToBottomRow(new CButton("save", S_SAVE)); if ($_REQUEST['hostid'] > 0 && $_REQUEST['form'] != 'full_clone') { $frmHost->addItemToBottomRow(SPACE); $frmHost->addItemToBottomRow(new CButton("clone", S_CLONE)); $frmHost->addItemToBottomRow(SPACE); $frmHost->addItemToBottomRow(new CButton("full_clone", S_FULL_CLONE)); $frmHost->addItemToBottomRow(SPACE); $frmHost->addItemToBottomRow(new CButtonDelete(S_DELETE_SELECTED_HOST_Q, url_param("form") . url_param("config") . url_param("hostid") . url_param('groupid'))); $frmHost->addItemToBottomRow(SPACE); $frmHost->addItemToBottomRow(new CButtonQMessage('delete_and_clear', 'Delete AND clear', S_DELETE_SELECTED_HOSTS_Q, url_param("form") . url_param("config") . url_param("hostid") . url_param('groupid'))); } $frmHost->addItemToBottomRow(SPACE); $frmHost->addItemToBottomRow(new CButtonCancel(url_param("config") . url_param('groupid'))); $frmHost->show(); }
$paramtype = get_request('paramtype'); if (!isset($function)) { $function = 'last'; } if (!isset($functions[$function]['operators'][$operator])) { $operator = '='; } $expr_type = $function . '[' . $operator . ']'; if ($itemid) { $options = array('output' => API_OUTPUT_EXTEND, 'itemids' => $itemid, 'webitems' => 1, 'select_hosts' => API_OUTPUT_EXTEND); $item_data = CItem::get($options); $item_data = reset($item_data); $item_key = $item_data['key_']; $item_host = reset($item_data['hosts']); $item_host = $item_host['host']; $description = $item_host . ':' . item_description($item_data); } else { $item_key = $item_host = $description = ''; } if (is_null($paramtype) && isset($functions[$function]['params']['M'])) { $paramtype = is_array($functions[$function]['params']['M']) ? reset($functions[$function]['params']['M']) : $functions[$function]['params']['M']; } else { if (is_null($paramtype)) { $paramtype = PARAM_TYPE_SECONDS; } } if (!is_array($param)) { if (isset($functions[$function]['params'])) { $param = explode(',', $param, count($functions[$function]['params'])); } else { $param = array($param);
function insert_host_form() { global $USER_DETAILS; $host_groups = get_request('groups', array()); if (isset($_REQUEST['groupid']) && $_REQUEST['groupid'] > 0 && empty($host_groups)) { array_push($host_groups, $_REQUEST['groupid']); } $newgroup = get_request('newgroup', ''); $host = get_request('host', ''); $port = get_request('port', CProfile::get('HOST_PORT', 10050)); $status = get_request('status', HOST_STATUS_MONITORED); $useip = get_request('useip', 1); $dns = get_request('dns', ''); $ip = get_request('ip', '0.0.0.0'); $proxy_hostid = get_request('proxy_hostid', ''); $useipmi = get_request('useipmi', 'no'); $ipmi_ip = get_request('ipmi_ip', ''); $ipmi_port = get_request('ipmi_port', 623); $ipmi_authtype = get_request('ipmi_authtype', -1); $ipmi_privilege = get_request('ipmi_privilege', 2); $ipmi_username = get_request('ipmi_username', ''); $ipmi_password = get_request('ipmi_password', ''); $useprofile = get_request('useprofile', 'no'); $devicetype = get_request('devicetype', ''); $name = get_request('name', ''); $os = get_request('os', ''); $serialno = get_request('serialno', ''); $tag = get_request('tag', ''); $macaddress = get_request('macaddress', ''); $hardware = get_request('hardware', ''); $software = get_request('software', ''); $contact = get_request('contact', ''); $location = get_request('location', ''); $notes = get_request('notes', ''); $_REQUEST['hostid'] = get_request('hostid', 0); // BEGIN: HOSTS PROFILE EXTENDED Section $useprofile_ext = get_request('useprofile_ext', 'no'); $ext_host_profiles = get_request('ext_host_profiles', array()); // END: HOSTS PROFILE EXTENDED Section $templates = get_request('templates', array()); $clear_templates = get_request('clear_templates', array()); $frm_title = S_HOST; if ($_REQUEST['hostid'] > 0) { $db_host = get_host_by_hostid($_REQUEST['hostid']); $frm_title .= SPACE . ' [' . $db_host['host'] . ']'; $original_templates = get_templates_by_hostid($_REQUEST['hostid']); } else { $original_templates = array(); } if ($_REQUEST['hostid'] > 0 && !isset($_REQUEST['form_refresh'])) { $proxy_hostid = $db_host['proxy_hostid']; $host = $db_host['host']; $port = $db_host['port']; $status = $db_host['status']; $useip = $db_host['useip']; $useipmi = $db_host['useipmi'] ? 'yes' : 'no'; $ip = $db_host['ip']; $dns = $db_host['dns']; $ipmi_ip = $db_host['ipmi_ip']; $ipmi_port = $db_host['ipmi_port']; $ipmi_authtype = $db_host['ipmi_authtype']; $ipmi_privilege = $db_host['ipmi_privilege']; $ipmi_username = $db_host['ipmi_username']; $ipmi_password = $db_host['ipmi_password']; // add groups $options = array('hostids' => $_REQUEST['hostid']); $host_groups = CHostGroup::get($options); $host_groups = zbx_objectValues($host_groups, 'groupid'); // read profile $db_profiles = DBselect('SELECT * FROM hosts_profiles WHERE hostid=' . $_REQUEST['hostid']); $useprofile = 'no'; $db_profile = DBfetch($db_profiles); if ($db_profile) { $useprofile = 'yes'; $devicetype = $db_profile['devicetype']; $name = $db_profile['name']; $os = $db_profile['os']; $serialno = $db_profile['serialno']; $tag = $db_profile['tag']; $macaddress = $db_profile['macaddress']; $hardware = $db_profile['hardware']; $software = $db_profile['software']; $contact = $db_profile['contact']; $location = $db_profile['location']; $notes = $db_profile['notes']; } // BEGIN: HOSTS PROFILE EXTENDED Section $useprofile_ext = 'no'; $db_profiles_alt = DBselect('SELECT * FROM hosts_profiles_ext WHERE hostid=' . $_REQUEST['hostid']); if ($ext_host_profiles = DBfetch($db_profiles_alt)) { $useprofile_ext = 'yes'; } else { $ext_host_profiles = array(); } // END: HOSTS PROFILE EXTENDED Section $templates = $original_templates; } $ext_profiles_fields = array('device_alias' => S_DEVICE_ALIAS, 'device_type' => S_DEVICE_TYPE, 'device_chassis' => S_DEVICE_CHASSIS, 'device_os' => S_DEVICE_OS, 'device_os_short' => S_DEVICE_OS_SHORT, 'device_hw_arch' => S_DEVICE_HW_ARCH, 'device_serial' => S_DEVICE_SERIAL, 'device_model' => S_DEVICE_MODEL, 'device_tag' => S_DEVICE_TAG, 'device_vendor' => S_DEVICE_VENDOR, 'device_contract' => S_DEVICE_CONTRACT, 'device_who' => S_DEVICE_WHO, 'device_status' => S_DEVICE_STATUS, 'device_app_01' => S_DEVICE_APP_01, 'device_app_02' => S_DEVICE_APP_02, 'device_app_03' => S_DEVICE_APP_03, 'device_app_04' => S_DEVICE_APP_04, 'device_app_05' => S_DEVICE_APP_05, 'device_url_1' => S_DEVICE_URL_1, 'device_url_2' => S_DEVICE_URL_2, 'device_url_3' => S_DEVICE_URL_3, 'device_networks' => S_DEVICE_NETWORKS, 'device_notes' => S_DEVICE_NOTES, 'device_hardware' => S_DEVICE_HARDWARE, 'device_software' => S_DEVICE_SOFTWARE, 'ip_subnet_mask' => S_IP_SUBNET_MASK, 'ip_router' => S_IP_ROUTER, 'ip_macaddress' => S_IP_MACADDRESS, 'oob_ip' => S_OOB_IP, 'oob_subnet_mask' => S_OOB_SUBNET_MASK, 'oob_router' => S_OOB_ROUTER, 'date_hw_buy' => S_DATE_HW_BUY, 'date_hw_install' => S_DATE_HW_INSTALL, 'date_hw_expiry' => S_DATE_HW_EXPIRY, 'date_hw_decomm' => S_DATE_HW_DECOMM, 'site_street_1' => S_SITE_STREET_1, 'site_street_2' => S_SITE_STREET_2, 'site_street_3' => S_SITE_STREET_3, 'site_city' => S_SITE_CITY, 'site_state' => S_SITE_STATE, 'site_country' => S_SITE_COUNTRY, 'site_zip' => S_SITE_ZIP, 'site_rack' => S_SITE_RACK, 'site_notes' => S_SITE_NOTES, 'poc_1_name' => S_POC_1_NAME, 'poc_1_email' => S_POC_1_EMAIL, 'poc_1_phone_1' => S_POC_1_PHONE_1, 'poc_1_phone_2' => S_POC_1_PHONE_2, 'poc_1_cell' => S_POC_1_CELL, 'poc_1_screen' => S_POC_1_SCREEN, 'poc_1_notes' => S_POC_1_NOTES, 'poc_2_name' => S_POC_2_NAME, 'poc_2_email' => S_POC_2_EMAIL, 'poc_2_phone_1' => S_POC_2_PHONE_1, 'poc_2_phone_2' => S_POC_2_PHONE_2, 'poc_2_cell' => S_POC_2_CELL, 'poc_2_screen' => S_POC_2_SCREEN, 'poc_2_notes' => S_POC_2_NOTES); foreach ($ext_profiles_fields as $field => $caption) { if (!isset($ext_host_profiles[$field])) { $ext_host_profiles[$field] = ''; } } $clear_templates = array_intersect($clear_templates, array_keys($original_templates)); $clear_templates = array_diff($clear_templates, array_keys($templates)); natcasesort($templates); $frmHost = new CForm('hosts.php', 'post'); $frmHost->setName('web.hosts.host.php.'); // $frmHost->setHelp('web.hosts.host.php'); // $frmHost->addVar('config',get_request('config',0)); $frmHost->addVar('form', get_request('form', 1)); $from_rfr = get_request('form_refresh', 0); $frmHost->addVar('form_refresh', $from_rfr + 1); $frmHost->addVar('clear_templates', $clear_templates); // HOST WIDGET { $host_tbl = new CTable('', 'tablestripped'); $host_tbl->setOddRowClass('form_odd_row'); $host_tbl->setEvenRowClass('form_even_row'); if ($_REQUEST['hostid'] > 0) { $frmHost->addVar('hostid', $_REQUEST['hostid']); } if ($_REQUEST['groupid'] > 0) { $frmHost->addVar('groupid', $_REQUEST['groupid']); } $host_tbl->addRow(array(S_NAME, new CTextBox('host', $host, 54))); $grp_tb = new CTweenBox($frmHost, 'groups', $host_groups, 10); $all_groups = CHostGroup::get(array('editable' => 1, 'extendoutput' => 1)); order_result($all_groups, 'name'); foreach ($all_groups as $group) { $grp_tb->addItem($group['groupid'], $group['name']); } $host_tbl->addRow(array(S_GROUPS, $grp_tb->get(S_IN_GROUPS, S_OTHER_GROUPS))); $host_tbl->addRow(array(S_NEW_GROUP, new CTextBox('newgroup', $newgroup))); // onchange does not work on some browsers: MacOS, KDE browser $host_tbl->addRow(array(S_DNS_NAME, new CTextBox('dns', $dns, '40'))); if (defined('ZBX_HAVE_IPV6')) { $host_tbl->addRow(array(S_IP_ADDRESS, new CTextBox('ip', $ip, '39'))); } else { $host_tbl->addRow(array(S_IP_ADDRESS, new CTextBox('ip', $ip, '15'))); } $cmbConnectBy = new CComboBox('useip', $useip); $cmbConnectBy->addItem(0, S_DNS_NAME); $cmbConnectBy->addItem(1, S_IP_ADDRESS); $host_tbl->addRow(array(S_CONNECT_TO, $cmbConnectBy)); $host_tbl->addRow(array(S_AGENT_PORT, new CNumericBox('port', $port, 5))); //Proxy $cmbProxy = new CComboBox('proxy_hostid', $proxy_hostid); $cmbProxy->addItem(0, S_NO_PROXY); $options = array('extendoutput' => 1); $db_proxies = CProxy::get($options); order_result($db_proxies, 'host'); foreach ($db_proxies as $proxy) { $cmbProxy->addItem($proxy['proxyid'], $proxy['host']); } $host_tbl->addRow(array(S_MONITORED_BY_PROXY, $cmbProxy)); //---------- $cmbStatus = new CComboBox('status', $status); $cmbStatus->addItem(HOST_STATUS_MONITORED, S_MONITORED); $cmbStatus->addItem(HOST_STATUS_NOT_MONITORED, S_NOT_MONITORED); $host_tbl->addRow(array(S_STATUS, $cmbStatus)); $host_tbl->addRow(array(S_USEIPMI, new CCheckBox('useipmi', $useipmi, 'submit()'))); if ($useipmi == 'yes') { $host_tbl->addRow(array(S_IPMI_IP_ADDRESS, new CTextBox('ipmi_ip', $ipmi_ip, defined('ZBX_HAVE_IPV6') ? 39 : 15))); $host_tbl->addRow(array(S_IPMI_PORT, new CNumericBox('ipmi_port', $ipmi_port, 5))); $cmbIPMIAuthtype = new CComboBox('ipmi_authtype', $ipmi_authtype); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_DEFAULT, S_AUTHTYPE_DEFAULT); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_NONE, S_AUTHTYPE_NONE); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD2, S_AUTHTYPE_MD2); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD5, S_AUTHTYPE_MD5); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_STRAIGHT, S_AUTHTYPE_STRAIGHT); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_OEM, S_AUTHTYPE_OEM); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_RMCP_PLUS, S_AUTHTYPE_RMCP_PLUS); $host_tbl->addRow(array(S_IPMI_AUTHTYPE, $cmbIPMIAuthtype)); $cmbIPMIPrivilege = new CComboBox('ipmi_privilege', $ipmi_privilege); $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_CALLBACK, S_PRIVILEGE_CALLBACK); $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_USER, S_PRIVILEGE_USER); $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OPERATOR, S_PRIVILEGE_OPERATOR); $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_ADMIN, S_PRIVILEGE_ADMIN); $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OEM, S_PRIVILEGE_OEM); $host_tbl->addRow(array(S_IPMI_PRIVILEGE, $cmbIPMIPrivilege)); $host_tbl->addRow(array(S_IPMI_USERNAME, new CTextBox('ipmi_username', $ipmi_username, 16))); $host_tbl->addRow(array(S_IPMI_PASSWORD, new CTextBox('ipmi_password', $ipmi_password, 20))); } else { $frmHost->addVar('ipmi_ip', $ipmi_ip); $frmHost->addVar('ipmi_port', $ipmi_port); $frmHost->addVar('ipmi_authtype', $ipmi_authtype); $frmHost->addVar('ipmi_privilege', $ipmi_privilege); $frmHost->addVar('ipmi_username', $ipmi_username); $frmHost->addVar('ipmi_password', $ipmi_password); } if ($_REQUEST['form'] == 'full_clone') { // Host items $options = array('inherited' => 0, 'hostids' => $_REQUEST['hostid'], 'output' => API_OUTPUT_EXTEND, 'webitems' => 1); $host_items = CItem::get($options); if (!empty($host_items)) { $items_lbx = new CListBox('items', null, 8); $items_lbx->setAttribute('disabled', 'disabled'); order_result($host_items, 'description'); foreach ($host_items as $hitem) { $items_lbx->addItem($hitem['itemid'], item_description($hitem)); } $host_tbl->addRow(array(S_ITEMS, $items_lbx)); } // Host triggers $options = array('inherited' => 0, 'hostids' => $_REQUEST['hostid'], 'output' => API_OUTPUT_EXTEND, 'expandDescription' => true); $host_triggers = CTrigger::get($options); if (!empty($host_triggers)) { $trig_lbx = new CListBox('triggers', null, 8); $trig_lbx->setAttribute('disabled', 'disabled'); order_result($host_triggers, 'description'); foreach ($host_triggers as $htrigger) { $trig_lbx->addItem($htrigger['triggerid'], $htrigger['description']); } $host_tbl->addRow(array(S_TRIGGERS, $trig_lbx)); } // Host graphs $options = array('inherited' => 0, 'hostids' => $_REQUEST['hostid'], 'select_hosts' => API_OUTPUT_REFER, 'output' => API_OUTPUT_EXTEND); $host_graphs = CGraph::get($options); if (!empty($host_graphs)) { $graphs_lbx = new CListBox('graphs', null, 8); $graphs_lbx->setAttribute('disabled', 'disabled'); order_result($host_graphs, 'name'); foreach ($host_graphs as $hgraph) { if (count($hgraph['hosts']) > 1) { continue; } $graphs_lbx->addItem($hgraph['graphid'], $hgraph['name']); } if ($graphs_lbx->ItemsCount() > 1) { $host_tbl->addRow(array(S_GRAPHS, $graphs_lbx)); } } } $host_footer = array(); $host_footer[] = new CButton('save', S_SAVE); if ($_REQUEST['hostid'] > 0 && $_REQUEST['form'] != 'full_clone') { array_push($host_footer, SPACE, new CButton('clone', S_CLONE), SPACE, new CButton('full_clone', S_FULL_CLONE), SPACE, new CButtonDelete(S_DELETE_SELECTED_HOST_Q, url_param('form') . url_param('hostid') . url_param('groupid'))); } array_push($host_footer, SPACE, new CButtonCancel(url_param('groupid'))); $host_footer = new CCol($host_footer); $host_footer->setColSpan(2); $host_tbl->setFooter($host_footer); $host_wdgt = new CWidget(); $host_wdgt->setClass('header'); $host_wdgt->addHeader($frm_title); $host_wdgt->addItem($host_tbl); // } HOST WIDGET // TEMPLATES{ $template_tbl = new CTableInfo(S_NO_TEMPLATES_LINKED, 'tablestripped'); $template_tbl->setOddRowClass('form_odd_row'); $template_tbl->setEvenRowClass('form_even_row'); foreach ($templates as $id => $temp_name) { $frmHost->addVar('templates[' . $id . ']', $temp_name); $template_tbl->addRow(new CCol(array(new CCheckBox('templates_rem[' . $id . ']', 'no', null, $id), $temp_name))); } $footer = new CCol(array(new CButton('add_template', S_ADD, "return PopUp('popup.php?dstfrm=" . $frmHost->getName() . "&dstfld1=new_template&srctbl=templates&srcfld1=hostid&srcfld2=host" . url_param($templates, false, 'existed_templates') . "',450,450)", 'T'), SPACE, new CButton('unlink', S_UNLINK), SPACE, new CButton('unlink_and_clear', S_UNLINK_AND_CLEAR))); //$footer->setColSpan(2); $template_tbl->setFooter($footer); $template_wdgt = new CWidget(); $template_wdgt->setClass('header'); $template_wdgt->addHeader(S_LINKED_TEMPLATES); $template_wdgt->addItem($template_tbl); // } TEMPLATES // MACROS WIDGET { $macros_wdgt = get_macros_widget($_REQUEST['hostid']); // } MACROS WIDGET // PROFILE WIDGET { $profile_tbl = new CTable('', 'tablestripped'); $profile_tbl->setOddRowClass('form_odd_row'); $profile_tbl->setEvenRowClass('form_even_row'); $profile_tbl->addRow(array(S_USE_PROFILE, new CCheckBox('useprofile', $useprofile, 'submit()'))); if ($useprofile == 'yes') { $profile_tbl->addRow(array(S_DEVICE_TYPE, new CTextBox('devicetype', $devicetype, 61))); $profile_tbl->addRow(array(S_NAME, new CTextBox('name', $name, 61))); $profile_tbl->addRow(array(S_OS, new CTextBox('os', $os, 61))); $profile_tbl->addRow(array(S_SERIALNO, new CTextBox('serialno', $serialno, 61))); $profile_tbl->addRow(array(S_TAG, new CTextBox('tag', $tag, 61))); $profile_tbl->addRow(array(S_MACADDRESS, new CTextBox('macaddress', $macaddress, 61))); $profile_tbl->addRow(array(S_HARDWARE, new CTextArea('hardware', $hardware, 60, 4))); $profile_tbl->addRow(array(S_SOFTWARE, new CTextArea('software', $software, 60, 4))); $profile_tbl->addRow(array(S_CONTACT, new CTextArea('contact', $contact, 60, 4))); $profile_tbl->addRow(array(S_LOCATION, new CTextArea('location', $location, 60, 4))); $profile_tbl->addRow(array(S_NOTES, new CTextArea('notes', $notes, 60, 4))); } else { $frmHost->addVar('devicetype', $devicetype); $frmHost->addVar('name', $name); $frmHost->addVar('os', $os); $frmHost->addVar('serialno', $serialno); $frmHost->addVar('tag', $tag); $frmHost->addVar('macaddress', $macaddress); $frmHost->addVar('hardware', $hardware); $frmHost->addVar('software', $software); $frmHost->addVar('contact', $contact); $frmHost->addVar('location', $location); $frmHost->addVar('notes', $notes); } $profile_wdgt = new CWidget(); $profile_wdgt->setClass('header'); $profile_wdgt->addHeader(S_PROFILE); $profile_wdgt->addItem($profile_tbl); // } PROFILE WIDGET // EXT PROFILE WIDGET { $ext_profile_tbl = new CTable('', 'tablestripped'); $ext_profile_tbl->setOddRowClass('form_odd_row'); $ext_profile_tbl->setEvenRowClass('form_even_row'); $ext_profile_tbl->addRow(array(S_USE_EXTENDED_PROFILE, new CCheckBox('useprofile_ext', $useprofile_ext, 'submit()', 'yes'))); foreach ($ext_profiles_fields as $prof_field => $caption) { if ($useprofile_ext == 'yes') { $ext_profile_tbl->addRow(array($caption, new CTextBox('ext_host_profiles[' . $prof_field . ']', $ext_host_profiles[$prof_field], 40))); } else { $frmHost->addVar('ext_host_profiles[' . $prof_field . ']', $ext_host_profiles[$prof_field]); } } $ext_profile_wdgt = new CWidget(); $ext_profile_wdgt->setClass('header'); $ext_profile_wdgt->addHeader(S_EXTENDED_HOST_PROFILE); $ext_profile_wdgt->addItem($ext_profile_tbl); // } EXT PROFILE WIDGET $left_table = new CTable(); $left_table->setCellPadding(4); $left_table->setCellSpacing(4); $left_table->addRow($host_wdgt); $right_table = new CTable(); $right_table->setCellPadding(4); $right_table->setCellSpacing(4); $right_table->addRow($template_wdgt); $right_table->addRow($macros_wdgt); $right_table->addRow($profile_wdgt); $right_table->addRow($ext_profile_wdgt); $td_l = new CCol($left_table); $td_l->setAttribute('valign', 'top'); $td_r = new CCol($right_table); $td_r->setAttribute('valign', 'top'); $outer_table = new CTable(); $outer_table->addRow(array($td_l, $td_r)); $frmHost->addItem($outer_table); return $frmHost; }
//*/ //* $sql = 'SELECT DISTINCT th.host as template_host,th.hostid as template_hostid, h.host, h.hostid, i.* ' . ' FROM ' . implode(',', $from_tables) . ' LEFT JOIN items ti ON i.templateid=ti.itemid ' . ' LEFT JOIN hosts th ON ti.hostid=th.hostid ' . ' WHERE ' . implode(' and ', $where_case) . order_by('h.host,i.description,i.key_,i.delay,i.history,i.trends,i.type,i.status', 'i.itemid'); //*/ $db_items = DBselect($sql); while ($db_item = DBfetch($db_items)) { $description = array(); $item_description = item_description($db_item); if (isset($_REQUEST['filter_description']) && !zbx_stristr($item_description, $_REQUEST['filter_description'])) { continue; } if ($db_item['templateid']) { $template_host = get_realhost_by_itemid($db_item['templateid']); array_push($description, new CLink($template_host['host'], '?' . 'hostid=' . $template_host['hostid'], 'unknown'), ':'); } array_push($description, new CLink(item_description($db_item), '?form=update&itemid=' . $db_item['itemid'] . '&hostid=' . $db_item['hostid'])); $status = new CCol(new CLink(item_status2str($db_item['status']), '?group_itemid%5B%5D=' . $db_item['itemid'] . '&go=' . ($db_item['status'] ? 'activate' : 'disable'), item_status2style($db_item['status']))); if (!zbx_empty($db_item['error'])) { $error = new CDiv(SPACE, 'error_icon'); $error->setHint($db_item['error'], '', 'on'); } else { $error = new CDiv(SPACE, 'ok_icon'); } $applications = $show_applications ? implode(', ', get_applications_by_itemid($db_item['itemid'], 'name')) : null; if (!is_null($applications) && empty($applications)) { $applications = ' - '; } $applications = new CCol($applications, 'wraptext'); $table->addRow(array(new CCheckBox('group_itemid[' . $db_item['itemid'] . ']', null, null, $db_item['itemid']), $show_host ? $db_item['host'] : null, $description, $db_item['key_'], $db_item['delay'], $db_item['history'], $db_item['trends'], item_type2str($db_item['type']), $status, $applications, $error)); $row_count++; }
} switch ($color_style) { case MARK_COLOR_RED: $color_style = "mark_as_red"; break; case MARK_COLOR_GREEN: $color_style = "mark_as_green"; break; case MARK_COLOR_BLUE: $color_style = "mark_as_blue"; break; } } $new_row = array(nbsp(date("[Y.M.d H:i:s]", $row["clock"]))); if ($item_cout > 1) { array_push($new_row, $row["host"] . ":" . item_description($row)); } if ($row["timestamp"] == 0) { array_push($new_row, new CCol("-", "center")); } else { array_push($new_row, date("Y.M.d H:i:s", $row["timestamp"])); } if ($row["source"] == "") { array_push($new_row, new CCol("-", "center")); } else { array_push($new_row, $row["source"]); } array_push($new_row, new CCol(get_severity_description($row["severity"]), get_severity_style($row["severity"]))); $row["value"] = trim($row["value"], "\r\n"); // array_push($new_row,htmlspecialchars($row["value"])); array_push($new_row, encode_log($row["value"]));
} switch ($color_style) { case MARK_COLOR_RED: $color_style = 'mark_as_red'; break; case MARK_COLOR_GREEN: $color_style = 'mark_as_green'; break; case MARK_COLOR_BLUE: $color_style = 'mark_as_blue'; break; } } $new_row = array(nbsp(date('[Y.M.d H:i:s]', $row['clock']))); if ($item_cout > 1) { array_push($new_row, $row['host'] . ':' . item_description($row)); } if ($row['timestamp'] == 0) { array_push($new_row, new CCol(' - ')); } else { array_push($new_row, date('Y.M.d H:i:s', $row['timestamp'])); } if ($row['source'] == '') { array_push($new_row, new CCol(' - ')); } else { array_push($new_row, $row['source']); } array_push($new_row, new CCol(get_severity_description($row['severity']), get_severity_style($row['severity']))); if ($row['source'] == '' && $row['logeventid'] == '0') { array_push($new_row, new CCol(' - ')); } else {
function insert_host_form($show_only_tmp = 0) { global $USER_DETAILS; $groups = get_request('groups', array()); $newgroup = get_request('newgroup', ''); $host = get_request('host', ''); $port = get_request('port', get_profile('HOST_PORT', 10050)); $status = get_request('status', HOST_STATUS_MONITORED); $useip = get_request('useip', 0); $dns = get_request('dns', ''); $ip = get_request('ip', '0.0.0.0'); $proxy_hostid = get_request('proxy_hostid', ''); $useipmi = get_request('useipmi', 'no'); $ipmi_ip = get_request('ipmi_ip', ''); $ipmi_port = get_request('ipmi_port', 623); $ipmi_authtype = get_request('ipmi_authtype', -1); $ipmi_privilege = get_request('ipmi_privilege', 2); $ipmi_username = get_request('ipmi_username', ''); $ipmi_password = get_request('ipmi_password', ''); $useprofile = get_request('useprofile', 'no'); $devicetype = get_request('devicetype', ''); $name = get_request('name', ''); $os = get_request('os', ''); $serialno = get_request('serialno', ''); $tag = get_request('tag', ''); $macaddress = get_request('macaddress', ''); $hardware = get_request('hardware', ''); $software = get_request('software', ''); $contact = get_request('contact', ''); $location = get_request('location', ''); $notes = get_request('notes', ''); // BEGIN: HOSTS PROFILE EXTENDED Section $useprofile_ext = get_request('useprofile_ext', 'no'); $ext_host_profiles = get_request('ext_host_profiles', array()); // END: HOSTS PROFILE EXTENDED Section $templates = get_request('templates', array()); $clear_templates = get_request('clear_templates', array()); $frm_title = $show_only_tmp ? S_TEMPLATE : S_HOST; if ($_REQUEST['hostid'] > 0) { $db_host = get_host_by_hostid($_REQUEST['hostid']); $frm_title .= SPACE . ' [' . $db_host['host'] . ']'; $original_templates = get_templates_by_hostid($_REQUEST['hostid']); } else { $original_templates = array(); } if ($_REQUEST['hostid'] > 0 && !isset($_REQUEST['form_refresh'])) { $proxy_hostid = $db_host['proxy_hostid']; $host = $db_host['host']; $port = $db_host['port']; $status = $db_host['status']; $useip = $db_host['useip']; $useipmi = $db_host['useipmi'] ? 'yes' : 'no'; $ip = $db_host['ip']; $dns = $db_host['dns']; $ipmi_ip = $db_host['ipmi_ip']; $ipmi_port = $db_host['ipmi_port']; $ipmi_authtype = $db_host['ipmi_authtype']; $ipmi_privilege = $db_host['ipmi_privilege']; $ipmi_username = $db_host['ipmi_username']; $ipmi_password = $db_host['ipmi_password']; // add groups $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_LIST); $db_groups = DBselect('SELECT DISTINCT groupid ' . ' FROM hosts_groups ' . ' WHERE hostid=' . $_REQUEST['hostid'] . ' AND ' . DBcondition('groupid', $available_groups)); while ($db_group = DBfetch($db_groups)) { if (uint_in_array($db_group['groupid'], $groups)) { continue; } $groups[$db_group['groupid']] = $db_group['groupid']; } // read profile $db_profiles = DBselect('SELECT * FROM hosts_profiles WHERE hostid=' . $_REQUEST['hostid']); $useprofile = 'no'; $db_profile = DBfetch($db_profiles); if ($db_profile) { $useprofile = 'yes'; $devicetype = $db_profile['devicetype']; $name = $db_profile['name']; $os = $db_profile['os']; $serialno = $db_profile['serialno']; $tag = $db_profile['tag']; $macaddress = $db_profile['macaddress']; $hardware = $db_profile['hardware']; $software = $db_profile['software']; $contact = $db_profile['contact']; $location = $db_profile['location']; $notes = $db_profile['notes']; } // BEGIN: HOSTS PROFILE EXTENDED Section $useprofile_ext = 'no'; $db_profiles_alt = DBselect('SELECT * FROM hosts_profiles_ext WHERE hostid=' . $_REQUEST['hostid']); if ($ext_host_profiles = DBfetch($db_profiles_alt)) { $useprofile_ext = 'yes'; } else { $ext_host_profiles = array(); } // END: HOSTS PROFILE EXTENDED Section $templates = $original_templates; } $ext_profiles_fields = array('device_alias', 'device_type', 'device_chassis', 'device_os', 'device_os_short', 'device_hw_arch', 'device_serial', 'device_model', 'device_tag', 'device_vendor', 'device_contract', 'device_who', 'device_status', 'device_app_01', 'device_app_02', 'device_app_03', 'device_app_04', 'device_app_05', 'device_url_1', 'device_url_2', 'device_url_3', 'device_networks', 'device_notes', 'device_hardware', 'device_software', 'ip_subnet_mask', 'ip_router', 'ip_macaddress', 'oob_ip', 'oob_subnet_mask', 'oob_router', 'date_hw_buy', 'date_hw_install', 'date_hw_expiry', 'date_hw_decomm', 'site_street_1', 'site_street_2', 'site_street_3', 'site_city', 'site_state', 'site_country', 'site_zip', 'site_rack', 'site_notes', 'poc_1_name', 'poc_1_email', 'poc_1_phone_1', 'poc_1_phone_2', 'poc_1_cell', 'poc_1_screen', 'poc_1_notes', 'poc_2_name', 'poc_2_email', 'poc_2_phone_1', 'poc_2_phone_2', 'poc_2_cell', 'poc_2_screen', 'poc_2_notes'); foreach ($ext_profiles_fields as $id => $field) { if (!isset($ext_host_profiles[$field])) { $ext_host_profiles[$field] = ''; } } $clear_templates = array_intersect($clear_templates, array_keys($original_templates)); $clear_templates = array_diff($clear_templates, array_keys($templates)); asort($templates); $frmHost = new CFormTable($frm_title, 'hosts.php'); $frmHost->setHelp('web.hosts.host.php'); $frmHost->addVar('config', get_request('config', 0)); $frmHost->addVar('clear_templates', $clear_templates); if ($_REQUEST['hostid'] > 0) { $frmHost->addVar('hostid', $_REQUEST['hostid']); } if ($_REQUEST['groupid'] > 0) { $frmHost->addVar('groupid', $_REQUEST['groupid']); } $frmHost->addRow(S_NAME, new CTextBox('host', $host, 54)); $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_LIST); $grp_tb = new CTweenBox($frmHost, 'groups', $groups, 10); $db_groups = DBselect('SELECT DISTINCT groupid,name ' . ' FROM groups ' . ' WHERE ' . DBcondition('groupid', $available_groups) . ' ORDER BY name'); while ($db_group = DBfetch($db_groups)) { $grp_tb->addItem($db_group['groupid'], $db_group['name']); } $frmHost->addRow(S_GROUPS, $grp_tb->get(S_IN . SPACE . S_GROUPS, S_OTHER . SPACE . S_GROUPS)); $frmHost->addRow(S_NEW_GROUP, new CTextBox('newgroup', $newgroup), 'new'); // onchange does not work on some browsers: MacOS, KDE browser if ($show_only_tmp) { $frmHost->addVar('useip', 0); $frmHost->addVar('ip', '0.0.0.0'); $frmHost->addVar('dns', ''); } else { $frmHost->addRow(S_DNS_NAME, new CTextBox('dns', $dns, '40')); if (defined('ZBX_HAVE_IPV6')) { $frmHost->addRow(S_IP_ADDRESS, new CTextBox('ip', $ip, '39')); } else { $frmHost->addRow(S_IP_ADDRESS, new CTextBox('ip', $ip, '15')); } $cmbConnectBy = new CComboBox('useip', $useip); $cmbConnectBy->addItem(0, S_DNS_NAME); $cmbConnectBy->addItem(1, S_IP_ADDRESS); $frmHost->addRow(S_CONNECT_TO, $cmbConnectBy); } if ($show_only_tmp) { $port = '10050'; $status = HOST_STATUS_TEMPLATE; $frmHost->addVar('port', $port); $frmHost->addVar('status', $status); } else { $frmHost->AddRow(S_AGENT_PORT, new CNumericBox('port', $port, 5)); //Proxy $cmbProxy = new CComboBox('proxy_hostid', $proxy_hostid); $cmbProxy->addItem(0, S_NO_PROXY); $db_proxies = DBselect('SELECT hostid,host FROM hosts' . ' where status in (' . HOST_STATUS_PROXY . ') and ' . DBin_node('hostid')); while ($db_proxy = DBfetch($db_proxies)) { $cmbProxy->addItem($db_proxy['hostid'], $db_proxy['host']); } $frmHost->addRow(S_MONITORED_BY_PROXY, $cmbProxy); //---------- $cmbStatus = new CComboBox('status', $status); $cmbStatus->addItem(HOST_STATUS_MONITORED, S_MONITORED); $cmbStatus->addItem(HOST_STATUS_NOT_MONITORED, S_NOT_MONITORED); $frmHost->addRow(S_STATUS, $cmbStatus); } $template_table = new CTable(); $template_table->SetCellPadding(0); $template_table->SetCellSpacing(0); foreach ($templates as $id => $temp_name) { $frmHost->addVar('templates[' . $id . ']', $temp_name); $template_table->addRow(array($temp_name, new CButton('unlink[' . $id . ']', S_UNLINK), isset($original_templates[$id]) ? new CButton('unlink_and_clear[' . $id . ']', S_UNLINK_AND_CLEAR) : SPACE)); } $frmHost->addRow(S_LINK_WITH_TEMPLATE, array($template_table, new CButton('add_template', S_ADD, "return PopUp('popup.php?dstfrm=" . $frmHost->GetName() . "&dstfld1=new_template&srctbl=templates&srcfld1=hostid&srcfld2=host" . url_param($templates, false, 'existed_templates') . "',450,450)", 'T'))); if ($show_only_tmp) { $frmHost->addVar('useipmi', $useipmi); } else { $frmHost->addRow(S_USEIPMI, new CCheckBox('useipmi', $useipmi, 'submit()')); } if ($useipmi == 'yes') { $frmHost->addRow(S_IPMI_IP_ADDRESS, new CTextBox('ipmi_ip', $ipmi_ip, defined('ZBX_HAVE_IPV6') ? 39 : 15)); $frmHost->addRow(S_IPMI_PORT, new CNumericBox('ipmi_port', $ipmi_port, 5)); $cmbIPMIAuthtype = new CComboBox('ipmi_authtype', $ipmi_authtype); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_DEFAULT, S_AUTHTYPE_DEFAULT); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_NONE, S_AUTHTYPE_NONE); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD2, S_AUTHTYPE_MD2); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD5, S_AUTHTYPE_MD5); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_STRAIGHT, S_AUTHTYPE_STRAIGHT); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_OEM, S_AUTHTYPE_OEM); $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_RMCP_PLUS, S_AUTHTYPE_RMCP_PLUS); $frmHost->addRow(S_IPMI_AUTHTYPE, $cmbIPMIAuthtype); $cmbIPMIPrivilege = new CComboBox('ipmi_privilege', $ipmi_privilege); $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_CALLBACK, S_PRIVILEGE_CALLBACK); $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_USER, S_PRIVILEGE_USER); $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OPERATOR, S_PRIVILEGE_OPERATOR); $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_ADMIN, S_PRIVILEGE_ADMIN); $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OEM, S_PRIVILEGE_OEM); $frmHost->addRow(S_IPMI_PRIVILEGE, $cmbIPMIPrivilege); $frmHost->addRow(S_IPMI_USERNAME, new CTextBox('ipmi_username', $ipmi_username, 16)); $frmHost->addRow(S_IPMI_PASSWORD, new CTextBox('ipmi_password', $ipmi_password, 20)); } else { $frmHost->addVar('ipmi_ip', $ipmi_ip); $frmHost->addVar('ipmi_port', $ipmi_port); $frmHost->addVar('ipmi_authtype', $ipmi_authtype); $frmHost->addVar('ipmi_privilege', $ipmi_privilege); $frmHost->addVar('ipmi_username', $ipmi_username); $frmHost->addVar('ipmi_password', $ipmi_password); } if ($show_only_tmp) { $useprofile = 'no'; $frmHost->addVar('useprofile', $useprofile); $useprofile_ext = 'no'; $frmHost->addVar('useprofile_ext', $useprofile_ext); } else { $frmHost->addRow(S_USE_PROFILE, new CCheckBox('useprofile', $useprofile, 'submit()')); $frmHost->addRow(S_USE_EXTENDED_PROFILE, new CCheckBox('useprofile_ext', $useprofile_ext, 'submit()', 'yes')); } if ($useprofile == 'yes') { $frmHost->addRow(S_DEVICE_TYPE, new CTextBox("devicetype", $devicetype, 61)); $frmHost->addRow(S_NAME, new CTextBox("name", $name, 61)); $frmHost->addRow(S_OS, new CTextBox("os", $os, 61)); $frmHost->addRow(S_SERIALNO, new CTextBox("serialno", $serialno, 61)); $frmHost->addRow(S_TAG, new CTextBox("tag", $tag, 61)); $frmHost->addRow(S_MACADDRESS, new CTextBox("macaddress", $macaddress, 61)); $frmHost->addRow(S_HARDWARE, new CTextArea("hardware", $hardware, 60, 4)); $frmHost->addRow(S_SOFTWARE, new CTextArea("software", $software, 60, 4)); $frmHost->addRow(S_CONTACT, new CTextArea("contact", $contact, 60, 4)); $frmHost->addRow(S_LOCATION, new CTextArea("location", $location, 60, 4)); $frmHost->addRow(S_NOTES, new CTextArea("notes", $notes, 60, 4)); } else { $frmHost->addVar("devicetype", $devicetype); $frmHost->addVar("name", $name); $frmHost->addVar("os", $os); $frmHost->addVar("serialno", $serialno); $frmHost->addVar("tag", $tag); $frmHost->addVar("macaddress", $macaddress); $frmHost->addVar("hardware", $hardware); $frmHost->addVar("software", $software); $frmHost->addVar("contact", $contact); $frmHost->addVar("location", $location); $frmHost->addVar("notes", $notes); } // BEGIN: HOSTS PROFILE EXTENDED Section if ($useprofile_ext == "yes") { $frmHost->addRow(S_DEVICE_ALIAS, new CTextBox('ext_host_profiles[device_alias]', $ext_host_profiles['device_alias'], 61)); $frmHost->addRow(S_DEVICE_TYPE, new CTextBox('ext_host_profiles[device_type]', $ext_host_profiles['device_type'], 61)); $frmHost->addRow(S_DEVICE_CHASSIS, new CTextBox('ext_host_profiles[device_chassis]', $ext_host_profiles['device_chassis'], 61)); $frmHost->addRow(S_DEVICE_OS, new CTextBox('ext_host_profiles[device_os]', $ext_host_profiles['device_os'], 61)); $frmHost->addRow(S_DEVICE_OS_SHORT, new CTextBox('ext_host_profiles[device_os_short]', $ext_host_profiles['device_os_short'], 61)); $frmHost->addRow(S_DEVICE_HW_ARCH, new CTextBox('ext_host_profiles[device_hw_arch]', $ext_host_profiles['device_hw_arch'], 61)); $frmHost->addRow(S_DEVICE_SERIAL, new CTextBox('ext_host_profiles[device_serial]', $ext_host_profiles['device_serial'], 61)); $frmHost->addRow(S_DEVICE_MODEL, new CTextBox('ext_host_profiles[device_model]', $ext_host_profiles['device_model'], 61)); $frmHost->addRow(S_DEVICE_TAG, new CTextBox('ext_host_profiles[device_tag]', $ext_host_profiles['device_tag'], 61)); $frmHost->addRow(S_DEVICE_VENDOR, new CTextBox('ext_host_profiles[device_vendor]', $ext_host_profiles['device_vendor'], 61)); $frmHost->addRow(S_DEVICE_CONTRACT, new CTextBox('ext_host_profiles[device_contract]', $ext_host_profiles['device_contract'], 61)); $frmHost->addRow(S_DEVICE_WHO, new CTextBox('ext_host_profiles[device_who]', $ext_host_profiles['device_who'], 61)); $frmHost->addRow(S_DEVICE_STATUS, new CTextBox('ext_host_profiles[device_status]', $ext_host_profiles['device_status'], 61)); $frmHost->addRow(S_DEVICE_APP_01, new CTextBox('ext_host_profiles[device_app_01]', $ext_host_profiles['device_app_01'], 61)); $frmHost->addRow(S_DEVICE_APP_02, new CTextBox('ext_host_profiles[device_app_02]', $ext_host_profiles['device_app_02'], 61)); $frmHost->addRow(S_DEVICE_APP_03, new CTextBox('ext_host_profiles[device_app_03]', $ext_host_profiles['device_app_03'], 61)); $frmHost->addRow(S_DEVICE_APP_04, new CTextBox('ext_host_profiles[device_app_04]', $ext_host_profiles['device_app_04'], 61)); $frmHost->addRow(S_DEVICE_APP_05, new CTextBox('ext_host_profiles[device_app_05]', $ext_host_profiles['device_app_05'], 61)); $frmHost->addRow(S_DEVICE_URL_1, new CTextBox('ext_host_profiles[device_url_1]', $ext_host_profiles['device_url_1'], 61)); $frmHost->addRow(S_DEVICE_URL_2, new CTextBox('ext_host_profiles[device_url_2]', $ext_host_profiles['device_url_2'], 61)); $frmHost->addRow(S_DEVICE_URL_3, new CTextBox('ext_host_profiles[device_url_3]', $ext_host_profiles['device_url_3'], 61)); $frmHost->addRow(S_DEVICE_NETWORKS, new CTextArea('ext_host_profiles[device_networks]', $ext_host_profiles['device_networks'], 50, 5)); $frmHost->addRow(S_DEVICE_NOTES, new CTextArea('ext_host_profiles[device_notes]', $ext_host_profiles['device_notes'], 50, 5)); $frmHost->addRow(S_DEVICE_HARDWARE, new CTextArea('ext_host_profiles[device_hardware]', $ext_host_profiles['device_hardware'], 50, 5)); $frmHost->addRow(S_DEVICE_SOFTWARE, new CTextArea('ext_host_profiles[device_software]', $ext_host_profiles['device_software'], 50, 5)); $frmHost->addRow(S_IP_SUBNET_MASK, new CTextBox('ext_host_profiles[ip_subnet_mask]', $ext_host_profiles['ip_subnet_mask'], 61)); $frmHost->addRow(S_IP_ROUTER, new CTextBox('ext_host_profiles[ip_router]', $ext_host_profiles['ip_router'], 61)); $frmHost->addRow(S_IP_MACADDRESS, new CTextBox('ext_host_profiles[ip_macaddress]', $ext_host_profiles['ip_macaddress'], 61)); $frmHost->addRow(S_OOB_IP, new CTextBox('ext_host_profiles[oob_ip]', $ext_host_profiles['oob_ip'], 61)); $frmHost->addRow(S_OOB_SUBNET_MASK, new CTextBox('ext_host_profiles[oob_subnet_mask]', $ext_host_profiles['oob_subnet_mask'], 61)); $frmHost->addRow(S_OOB_ROUTER, new CTextBox('ext_host_profiles[oob_router]', $ext_host_profiles['oob_router'], 61)); $frmHost->addRow(S_DATE_HW_BUY, new CTextBox('ext_host_profiles[date_hw_buy]', $ext_host_profiles['date_hw_buy'], 15)); $frmHost->addRow(S_DATE_HW_INSTALL, new CTextBox('ext_host_profiles[date_hw_install]', $ext_host_profiles['date_hw_install'], 15)); $frmHost->addRow(S_DATE_HW_EXPIRY, new CTextBox('ext_host_profiles[date_hw_expiry]', $ext_host_profiles['date_hw_expiry'], 15)); $frmHost->addRow(S_DATE_HW_DECOMM, new CTextBox('ext_host_profiles[date_hw_decomm]', $ext_host_profiles['date_hw_decomm'], 15)); $frmHost->addRow(S_SITE_STREET_1, new CTextBox('ext_host_profiles[site_street_1]', $ext_host_profiles['site_street_1'], 61)); $frmHost->addRow(S_SITE_STREET_2, new CTextBox('ext_host_profiles[site_street_2]', $ext_host_profiles['site_street_2'], 61)); $frmHost->addRow(S_SITE_STREET_3, new CTextBox('ext_host_profiles[site_street_3]', $ext_host_profiles['site_street_3'], 61)); $frmHost->addRow(S_SITE_CITY, new CTextBox('ext_host_profiles[site_city]', $ext_host_profiles['site_city'], 61)); $frmHost->addRow(S_SITE_STATE, new CTextBox('ext_host_profiles[site_state]', $ext_host_profiles['site_state'], 61)); $frmHost->addRow(S_SITE_COUNTRY, new CTextBox('ext_host_profiles[site_country]', $ext_host_profiles['site_country'], 61)); $frmHost->addRow(S_SITE_ZIP, new CTextBox('ext_host_profiles[site_zip]', $ext_host_profiles['site_zip'], 61)); $frmHost->addRow(S_SITE_RACK, new CTextBox('ext_host_profiles[site_rack]', $ext_host_profiles['site_rack'], 61)); $frmHost->addRow(S_SITE_NOTES, new CTextArea('ext_host_profiles[site_notes]', $ext_host_profiles['site_notes'], 50, 5)); $frmHost->addRow(S_POC_1_NAME, new CTextBox('ext_host_profiles[poc_1_name]', $ext_host_profiles['poc_1_name'], 61)); $frmHost->addRow(S_POC_1_EMAIL, new CTextBox('ext_host_profiles[poc_1_email]', $ext_host_profiles['poc_1_email'], 61)); $frmHost->addRow(S_POC_1_PHONE_1, new CTextBox('ext_host_profiles[poc_1_phone_1]', $ext_host_profiles['poc_1_phone_1'], 61)); $frmHost->addRow(S_POC_1_PHONE_2, new CTextBox('ext_host_profiles[poc_1_phone_2]', $ext_host_profiles['poc_1_phone_2'], 61)); $frmHost->addRow(S_POC_1_CELL, new CTextBox('ext_host_profiles[poc_1_cell]', $ext_host_profiles['poc_1_cell'], 61)); $frmHost->addRow(S_POC_1_SCREEN, new CTextBox('ext_host_profiles[poc_1_screen]', $ext_host_profiles['poc_1_screen'], 61)); $frmHost->addRow(S_POC_1_NOTES, new CTextArea('ext_host_profiles[poc_1_notes]', $ext_host_profiles['poc_1_notes'], 50, 5)); $frmHost->addRow(S_POC_2_NAME, new CTextBox('ext_host_profiles[poc_2_name]', $ext_host_profiles['poc_2_name'], 61)); $frmHost->addRow(S_POC_2_EMAIL, new CTextBox('ext_host_profiles[poc_2_email]', $ext_host_profiles['poc_2_email'], 61)); $frmHost->addRow(S_POC_2_PHONE_1, new CTextBox('ext_host_profiles[poc_2_phone_1]', $ext_host_profiles['poc_2_phone_1'], 61)); $frmHost->addRow(S_POC_2_PHONE_2, new CTextBox('ext_host_profiles[poc_2_phone_2]', $ext_host_profiles['poc_2_phone_2'], 61)); $frmHost->addRow(S_POC_2_CELL, new CTextBox('ext_host_profiles[poc_2_cell]', $ext_host_profiles['poc_2_cell'], 61)); $frmHost->addRow(S_POC_2_SCREEN, new CTextBox('ext_host_profiles[poc_2_screen]', $ext_host_profiles['poc_2_screen'], 61)); $frmHost->addRow(S_POC_2_NOTES, new CTextArea('ext_host_profiles[poc_2_notes]', $ext_host_profiles['poc_2_notes'], 50, 5)); } else { $frmHost->addVar('ext_host_profiles[device_alias]', $ext_host_profiles['device_alias']); $frmHost->addVar('ext_host_profiles[device_type]', $ext_host_profiles['device_type']); $frmHost->addVar('ext_host_profiles[device_chassis]', $ext_host_profiles['device_chassis']); $frmHost->addVar('ext_host_profiles[device_os]', $ext_host_profiles['device_os']); $frmHost->addVar('ext_host_profiles[device_os_short]', $ext_host_profiles['device_os_short']); $frmHost->addVar('ext_host_profiles[device_hw_arch]', $ext_host_profiles['device_hw_arch']); $frmHost->addVar('ext_host_profiles[device_serial]', $ext_host_profiles['device_serial']); $frmHost->addVar('ext_host_profiles[device_model]', $ext_host_profiles['device_model']); $frmHost->addVar('ext_host_profiles[device_tag]', $ext_host_profiles['device_tag']); $frmHost->addVar('ext_host_profiles[device_vendor]', $ext_host_profiles['device_vendor']); $frmHost->addVar('ext_host_profiles[device_contract]', $ext_host_profiles['device_contract']); $frmHost->addVar('ext_host_profiles[device_who]', $ext_host_profiles['device_who']); $frmHost->addVar('ext_host_profiles[device_status]', $ext_host_profiles['device_status']); $frmHost->addVar('ext_host_profiles[device_app_01]', $ext_host_profiles['device_app_01']); $frmHost->addVar('ext_host_profiles[device_app_02]', $ext_host_profiles['device_app_02']); $frmHost->addVar('ext_host_profiles[device_app_03]', $ext_host_profiles['device_app_03']); $frmHost->addVar('ext_host_profiles[device_app_04]', $ext_host_profiles['device_app_04']); $frmHost->addVar('ext_host_profiles[device_app_05]', $ext_host_profiles['device_app_05']); $frmHost->addVar('ext_host_profiles[device_url_1]', $ext_host_profiles['device_url_1']); $frmHost->addVar('ext_host_profiles[device_url_2]', $ext_host_profiles['device_url_2']); $frmHost->addVar('ext_host_profiles[device_url_3]', $ext_host_profiles['device_url_3']); $frmHost->addVar('ext_host_profiles[device_networks]', $ext_host_profiles['device_networks']); $frmHost->addVar('ext_host_profiles[device_notes]', $ext_host_profiles['device_notes']); $frmHost->addVar('ext_host_profiles[device_hardware]', $ext_host_profiles['device_hardware']); $frmHost->addVar('ext_host_profiles[device_software]', $ext_host_profiles['device_software']); $frmHost->addVar('ext_host_profiles[ip_subnet_mask]', $ext_host_profiles['ip_subnet_mask']); $frmHost->addVar('ext_host_profiles[ip_router]', $ext_host_profiles['ip_router']); $frmHost->addVar('ext_host_profiles[ip_macaddress]', $ext_host_profiles['ip_macaddress']); $frmHost->addVar('ext_host_profiles[oob_ip]', $ext_host_profiles['oob_ip']); $frmHost->addVar('ext_host_profiles[oob_subnet_mask]', $ext_host_profiles['oob_subnet_mask']); $frmHost->addVar('ext_host_profiles[oob_router]', $ext_host_profiles['oob_router']); $frmHost->addVar('ext_host_profiles[date_hw_buy]', $ext_host_profiles['date_hw_buy']); $frmHost->addVar('ext_host_profiles[date_hw_install]', $ext_host_profiles['date_hw_install']); $frmHost->addVar('ext_host_profiles[date_hw_expiry]', $ext_host_profiles['date_hw_expiry']); $frmHost->addVar('ext_host_profiles[date_hw_decomm]', $ext_host_profiles['date_hw_decomm']); $frmHost->addVar('ext_host_profiles[site_street_1]', $ext_host_profiles['site_street_1']); $frmHost->addVar('ext_host_profiles[site_street_2]', $ext_host_profiles['site_street_2']); $frmHost->addVar('ext_host_profiles[site_street_3]', $ext_host_profiles['site_street_3']); $frmHost->addVar('ext_host_profiles[site_city]', $ext_host_profiles['site_city']); $frmHost->addVar('ext_host_profiles[site_state]', $ext_host_profiles['site_state']); $frmHost->addVar('ext_host_profiles[site_country]', $ext_host_profiles['site_country']); $frmHost->addVar('ext_host_profiles[site_zip]', $ext_host_profiles['site_zip']); $frmHost->addVar('ext_host_profiles[site_rack]', $ext_host_profiles['site_rack']); $frmHost->addVar('ext_host_profiles[site_notes]', $ext_host_profiles['site_notes']); $frmHost->addVar('ext_host_profiles[poc_1_name]', $ext_host_profiles['poc_1_name']); $frmHost->addVar('ext_host_profiles[poc_1_email]', $ext_host_profiles['poc_1_email']); $frmHost->addVar('ext_host_profiles[poc_1_phone_1]', $ext_host_profiles['poc_1_phone_1']); $frmHost->addVar('ext_host_profiles[poc_1_phone_2]', $ext_host_profiles['poc_1_phone_2']); $frmHost->addVar('ext_host_profiles[poc_1_cell]', $ext_host_profiles['poc_1_cell']); $frmHost->addVar('ext_host_profiles[poc_1_screen]', $ext_host_profiles['poc_1_screen']); $frmHost->addVar('ext_host_profiles[poc_1_notes]', $ext_host_profiles['poc_1_notes']); $frmHost->addVar('ext_host_profiles[poc_2_name]', $ext_host_profiles['poc_2_name']); $frmHost->addVar('ext_host_profiles[poc_2_email]', $ext_host_profiles['poc_2_email']); $frmHost->addVar('ext_host_profiles[poc_2_phone_1]', $ext_host_profiles['poc_2_phone_1']); $frmHost->addVar('ext_host_profiles[poc_2_phone_2]', $ext_host_profiles['poc_2_phone_2']); $frmHost->addVar('ext_host_profiles[poc_2_cell]', $ext_host_profiles['poc_2_cell']); $frmHost->addVar('ext_host_profiles[poc_2_screen]', $ext_host_profiles['poc_2_screen']); $frmHost->addVar('ext_host_profiles[poc_2_notes]', $ext_host_profiles['poc_2_notes']); } // END: HOSTS PROFILE EXTENDED Section if ($_REQUEST['form'] == 'full_clone') { // Host items $items_lbx = new CListBox('items', null, 8); $items_lbx->addOption('disabled', 'disabled'); $sql = 'SELECT * ' . ' FROM items ' . ' WHERE hostid=' . $_REQUEST['hostid'] . ' AND templateid=0 ' . ' ORDER BY description'; $host_items_res = DBselect($sql); while ($host_item = DBfetch($host_items_res)) { $item_description = item_description($host_item); $items_lbx->addItem($host_item['itemid'], $item_description); } if ($items_lbx->ItemsCount() < 1) { $items_lbx->addOption('style', 'width: 200px;'); } $frmHost->addRow(S_ITEMS, $items_lbx); // Host triggers $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array($_REQUEST['hostid']), PERM_RES_IDS_ARRAY); $trig_lbx = new CListBox('triggers', null, 8); $trig_lbx->addOption('disabled', 'disabled'); $sql = 'SELECT DISTINCT t.* ' . ' FROM triggers t, items i, functions f' . ' WHERE i.hostid=' . $_REQUEST['hostid'] . ' AND f.itemid=i.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.templateid=0 ' . ' ORDER BY t.description'; $host_trig_res = DBselect($sql); while ($host_trig = DBfetch($host_trig_res)) { $trig_description = expand_trigger_description($host_trig["triggerid"]); $trig_lbx->addItem($host_trig['triggerid'], $trig_description); } if ($trig_lbx->ItemsCount() < 1) { $trig_lbx->addOption('style', 'width: 200px;'); } $frmHost->addRow(S_TRIGGERS, $trig_lbx); // Host graphs $available_graphs = get_accessible_graphs(PERM_READ_ONLY, array($_REQUEST['hostid']), PERM_RES_IDS_ARRAY); $graphs_lbx = new CListBox('graphs', null, 8); $graphs_lbx->addOption('disabled', 'disabled'); $def_items = array(); $sql = 'SELECT DISTINCT g.* ' . ' 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=' . $_REQUEST['hostid'] . ' ORDER BY g.name'; $host_graph_res = DBselect($sql); while ($host_graph = DBfetch($host_graph_res)) { $graphs_lbx->addItem($host_graph['graphid'], $host_graph['name']); } if ($graphs_lbx->ItemsCount() < 1) { $graphs_lbx->addOption('style', 'width: 200px;'); } $frmHost->addRow(S_GRAPHS, $graphs_lbx); } $frmHost->addItemToBottomRow(new CButton("save", S_SAVE)); if ($_REQUEST['hostid'] > 0 && $_REQUEST['form'] != 'full_clone') { $frmHost->addItemToBottomRow(SPACE); $frmHost->addItemToBottomRow(new CButton("clone", S_CLONE)); $frmHost->addItemToBottomRow(SPACE); $frmHost->addItemToBottomRow(new CButton("full_clone", S_FULL_CLONE)); $frmHost->addItemToBottomRow(SPACE); $frmHost->addItemToBottomRow(new CButtonDelete(S_DELETE_SELECTED_HOST_Q, url_param("form") . url_param("config") . url_param("hostid") . url_param('groupid'))); if ($show_only_tmp) { $frmHost->addItemToBottomRow(SPACE); $frmHost->addItemToBottomRow(new CButtonQMessage('delete_and_clear', 'Delete AND clear', S_DELETE_SELECTED_HOSTS_Q, url_param("form") . url_param("config") . url_param("hostid") . url_param('groupid'))); } } $frmHost->addItemToBottomRow(SPACE); $frmHost->addItemToBottomRow(new CButtonCancel(url_param("config") . url_param('groupid'))); $frmHost->Show(); }
function get_screen_item_form() { global $USER_DETAILS; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true)); $form = new CFormTable(S_SCREEN_CELL_CONFIGURATION, 'screenedit.php#form'); $form->SetHelp('web.screenedit.cell.php'); if (isset($_REQUEST['screenitemid'])) { $iresult = DBSelect('SELECT * FROM screens_items' . ' WHERE screenid=' . $_REQUEST['screenid'] . ' AND screenitemid=' . $_REQUEST['screenitemid']); $form->AddVar('screenitemid', $_REQUEST['screenitemid']); } else { $form->AddVar('x', $_REQUEST['x']); $form->AddVar('y', $_REQUEST['y']); } if (isset($_REQUEST['screenitemid']) && !isset($_REQUEST['form_refresh'])) { $irow = DBfetch($iresult); $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 { $resourcetype = get_request('resourcetype', 0); $resourceid = get_request('resourceid', 0); $width = get_request('width', 500); $height = get_request('height', 100); $colspan = get_request('colspan', 0); $rowspan = get_request('rowspan', 0); $elements = get_request('elements', 25); $valign = get_request('valign', VALIGN_DEFAULT); $halign = get_request('halign', HALIGN_DEFAULT); $style = get_request('style', 0); $url = get_request('url', ''); $dynamic = get_request('dynamic', SCREEN_SIMPLE_ITEM); } $form->addVar('screenid', $_REQUEST['screenid']); $cmbRes = new CCombobox('resourcetype', $resourcetype, 'submit()'); $cmbRes->addItem(SCREEN_RESOURCE_GRAPH, S_GRAPH); $cmbRes->addItem(SCREEN_RESOURCE_SIMPLE_GRAPH, S_SIMPLE_GRAPH); $cmbRes->addItem(SCREEN_RESOURCE_PLAIN_TEXT, S_PLAIN_TEXT); $cmbRes->addItem(SCREEN_RESOURCE_MAP, S_MAP); $cmbRes->addItem(SCREEN_RESOURCE_SCREEN, S_SCREEN); $cmbRes->addItem(SCREEN_RESOURCE_SERVER_INFO, S_SERVER_INFO); $cmbRes->addItem(SCREEN_RESOURCE_HOSTS_INFO, S_HOSTS_INFO); $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_INFO, S_TRIGGERS_INFO); $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, S_TRIGGERS_OVERVIEW); $cmbRes->addItem(SCREEN_RESOURCE_STATUS_OF_TRIGGERS, S_STATUS_OF_TRIGGERS); $cmbRes->addItem(SCREEN_RESOURCE_DATA_OVERVIEW, S_DATA_OVERVIEW); $cmbRes->addItem(SCREEN_RESOURCE_CLOCK, S_CLOCK); $cmbRes->addItem(SCREEN_RESOURCE_URL, S_URL); $cmbRes->addItem(SCREEN_RESOURCE_ACTIONS, S_HISTORY_OF_ACTIONS); $cmbRes->addItem(SCREEN_RESOURCE_EVENTS, S_HISTORY_OF_EVENTS); $form->addRow(S_RESOURCE, $cmbRes); if ($resourcetype == SCREEN_RESOURCE_GRAPH) { // User-defined graph $resourceid = graph_accessible($resourceid) ? $resourceid : 0; $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT DISTINCT g.graphid,g.name,n.name as node_name, h.host' . ' FROM graphs g ' . ' LEFT JOIN graphs_items gi ON g.graphid=gi.graphid ' . ' LEFT JOIN items i ON gi.itemid=i.itemid ' . ' LEFT JOIN hosts h ON h.hostid=i.hostid ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.graphid') . ' WHERE g.graphid=' . $resourceid); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['host'] . ':' . $row['name']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 75, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=graphs&srcfld1=graphid&srcfld2=name',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_GRAPH_NAME, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) { // Simple graph $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT n.name as node_name,h.host,i.description,i.itemid,i.key_ ' . ' FROM hosts h,items i ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('i.itemid') . ' WHERE h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('i.hostid', $available_hosts) . ' AND i.itemid=' . $resourceid); while ($row = DBfetch($result)) { $description_ = item_description($row); $row["node_name"] = isset($row["node_name"]) ? "(" . $row["node_name"] . ") " : ''; $caption = $row['node_name'] . $row['host'] . ': ' . $description_; $id = $resourceid; } } $form->AddVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 75, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=simple_graph&srcfld1=itemid&srcfld2=description',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_MAP) { // Map $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT n.name as node_name, s.sysmapid,s.name ' . ' FROM sysmaps s' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.sysmapid') . ' WHERE s.sysmapid=' . $resourceid); while ($row = DBfetch($result)) { if (!sysmap_accessible($row['sysmapid'], PERM_READ_ONLY)) { continue; } $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } $form->AddVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=sysmaps&srcfld1=sysmapid&srcfld2=name',400,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) { // Plain text $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT n.name as node_name,h.host,i.description,i.itemid,i.key_ ' . ' FROM hosts h,items i ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('i.itemid') . ' WHERE h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('i.hostid', $available_hosts) . ' AND i.itemid=' . $resourceid); while ($row = DBfetch($result)) { $description_ = item_description($row); $row["node_name"] = isset($row["node_name"]) ? '(' . $row["node_name"] . ') ' : ''; $caption = $row['node_name'] . $row['host'] . ': ' . $description_; $id = $resourceid; } } $form->AddVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 75, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=plain_text&srcfld1=itemid&srcfld2=description',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2)); $form->addRow(S_SHOW_TEXT_AS_HTML, new CCheckBox('style', $style, null, 1)); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_EVENTS, SCREEN_RESOURCE_STATUS_OF_TRIGGERS, SCREEN_RESOURCE_ACTIONS))) { // History of actions // History of events // Status of triggers $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2)); $form->addVar('resourceid', 0); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) { // Overviews $caption = ''; $id = 0; if ($resourceid > 0) { $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY); $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg,hosts h,groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=hg.groupid ' . ' AND hg.hostid=h.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND g.groupid=' . $resourceid); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } $form->AddVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 75, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=overview&srcfld1=groupid&srcfld2=name',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_GROUP, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_SCREEN) { // Screens $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT DISTINCT n.name as node_name,s.screenid,s.name ' . ' FROM screens s ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.screenid') . ' WHERE s.screenid=' . $resourceid); while ($row = DBfetch($result)) { if (!screen_accessible($row['screenid'], PERM_READ_ONLY)) { continue; } if (check_screen_recursion($_REQUEST['screenid'], $row['screenid'])) { continue; } $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=screens2&srcfld1=screenid&srcfld2=name&screenid=" . $_REQUEST['screenid'] . "',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_HOSTS_INFO || $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) { // HOSTS info $caption = ''; $id = 0; $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY); if (remove_nodes_from_id($resourceid) > 0) { $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg, groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=' . $resourceid); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } else { if (remove_nodes_from_id($resourceid) == 0) { $result = DBselect('SELECT DISTINCT n.name as node_name ' . ' FROM nodes n ' . ' WHERE n.nodeid=' . id2nodeid($resourceid)); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . S_MINUS_ALL_GROUPS_MINUS; $id = $resourceid; } } } $form->AddVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=host_group_scr&srcfld1=groupid&srcfld2=name',480,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->AddRow(S_GROUP, array($textfield, SPACE, $selectbtn)); } else { // SCREEN_RESOURCE_CLOCK $form->addVar('resourceid', 0); } } } } } } } } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO))) { $cmbStyle = new CComboBox("style", $style); $cmbStyle->AddItem(STYLE_HORISONTAL, S_HORIZONTAL); $cmbStyle->AddItem(STYLE_VERTICAL, S_VERTICAL); $form->AddRow(S_STYLE, $cmbStyle); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) { $cmbStyle = new CComboBox('style', $style); $cmbStyle->AddItem(STYLE_LEFT, S_LEFT); $cmbStyle->AddItem(STYLE_TOP, S_TOP); $form->AddRow(S_HOSTS_LOCATION, $cmbStyle); } else { if ($resourcetype == SCREEN_RESOURCE_CLOCK) { $cmbStyle = new CComboBox('style', $style); $cmbStyle->AddItem(TIME_TYPE_LOCAL, S_LOCAL_TIME); $cmbStyle->AddItem(TIME_TYPE_SERVER, S_SERVER_TIME); $form->AddRow(S_TIME_TYPE, $cmbStyle); } else { $form->AddVar('style', 0); } } } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_URL))) { $form->AddRow(S_URL, new CTextBox('url', $url, 60)); } else { $form->AddVar('url', ''); } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) { $form->AddRow(S_WIDTH, new CNumericBox('width', $width, 5)); $form->AddRow(S_HEIGHT, new CNumericBox('height', $height, 5)); } else { $form->AddVar('width', 500); $form->AddVar('height', 100); } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) { $cmbHalign = new CComboBox('halign', $halign); $cmbHalign->AddItem(HALIGN_CENTER, S_CENTRE); $cmbHalign->AddItem(HALIGN_LEFT, S_LEFT); $cmbHalign->AddItem(HALIGN_RIGHT, S_RIGHT); $form->AddRow(S_HORIZONTAL_ALIGN, $cmbHalign); } else { $form->AddVar('halign', 0); } $cmbValign = new CComboBox('valign', $valign); $cmbValign->AddItem(VALIGN_MIDDLE, S_MIDDLE); $cmbValign->AddItem(VALIGN_TOP, S_TOP); $cmbValign->AddItem(VALIGN_BOTTOM, S_BOTTOM); $form->AddRow(S_VERTICAL_ALIGN, $cmbValign); $form->AddRow(S_COLUMN_SPAN, new CNumericBox('colspan', $colspan, 2)); $form->AddRow(S_ROW_SPAN, new CNumericBox('rowspan', $rowspan, 2)); // dynamic AddOn if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT))) { $form->AddRow(S_DYNAMIC_ITEM, new CCheckBox('dynamic', $dynamic, null, 1)); } $form->AddItemToBottomRow(new CButton('save', S_SAVE)); if (isset($_REQUEST['screenitemid'])) { $form->addItemToBottomRow(SPACE); $form->addItemToBottomRow(new CButtonDelete(null, url_param('form') . url_param('screenid') . url_param('screenitemid'))); } $form->addItemToBottomRow(SPACE); $form->addItemToBottomRow(new CButtonCancel(url_param('screenid'))); return $form; }
function bar_report_form3() { global $USER_DETAILS; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY); $config = get_request('config', 1); $title = get_request('title', S_REPORT . ' 3'); $xlabel = get_request('xlabel', ''); $ylabel = get_request('ylabel', ''); $sorttype = get_request('sorttype', 0); $scaletype = get_request('scaletype', TIMEPERIOD_TYPE_WEEKLY); $avgperiod = get_request('avgperiod', TIMEPERIOD_TYPE_DAILY); $report_timesince = get_request('report_timesince', date('YmdHis', time() - 86400)); $report_timetill = get_request('report_timetill', date('YmdHis')); $captions = get_request('captions', array()); $items = get_request('items', array()); $hostids = get_request('hostids', array()); $hostids = zbx_toHash($hostids); $showlegend = get_request('showlegend', 0); $palette = get_request('palette', 0); $palettetype = get_request('palettetype', 0); $reportForm = new CFormTable(null, null, 'get'); //,'events.php?report_set=1','POST',null,'sform'); $reportForm->setAttribute('name', 'zbx_report'); $reportForm->setAttribute('id', 'zbx_report'); // $reportForm->setMethod('post'); if (isset($_REQUEST['report_show']) && !empty($items)) { $reportForm->addVar('report_show', 'show'); } $reportForm->addVar('config', $config); $reportForm->addVar('report_timesince', date('YmdHis', $report_timesince)); $reportForm->addVar('report_timetill', date('YmdHis', $report_timetill)); // $reportForm->addVar('items',$items); //params are set later!! // $reportForm->addVar('periods',$periods); $reportForm->addRow(S_TITLE, new CTextBox('title', $title, 40)); $reportForm->addRow(S_X . SPACE . S_LABEL, new CTextBox('xlabel', $xlabel, 40)); $reportForm->addRow(S_Y . SPACE . S_LABEL, new CTextBox('ylabel', $ylabel, 40)); $reportForm->addRow(S_LEGEND, new CCheckBox('showlegend', $showlegend, null, 1)); $reportForm->addVar('sortorder', 0); // GROUPS $groupids = get_request('groupids', array()); $group_tb = new CTweenBox($reportForm, 'groupids', $groupids, 10); $options = array('real_hosts' => 1, 'output' => 'extend'); $db_groups = CHostGroup::get($options); order_result($db_groups, 'name'); foreach ($db_groups as $gnum => $group) { $groupids[$group['groupid']] = $group['groupid']; $group_tb->addItem($group['groupid'], $group['name']); } $reportForm->addRow(S_GROUPS, $group_tb->Get(S_SELECTED_GROUPS, S_OTHER . SPACE . S_GROUPS)); // ---------- // HOSTS // validate_group(PERM_READ_ONLY,array('real_hosts'),'web.last.conf.groupid'); $groupid = get_request('groupid', 0); $cmbGroups = new CComboBox('groupid', $groupid, 'submit()'); $cmbGroups->addItem(0, S_ALL_S); foreach ($db_groups as $gnum => $group) { $cmbGroups->addItem($group['groupid'], $group['name']); } $td_groups = new CCol(array(S_GROUP, SPACE, $cmbGroups)); $td_groups->setAttribute('style', 'text-align: right;'); $host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10); $options = array('real_hosts' => 1, 'output' => array('hostid', 'host')); if ($groupid > 0) { $options['groupids'] = $groupid; } $db_hosts = CHost::get($options); $db_hosts = zbx_toHash($db_hosts, 'hostid'); order_result($db_hosts, 'host'); foreach ($db_hosts as $hnum => $host) { $host_tb->addItem($host['hostid'], $host['host']); } $options = array('real_hosts' => 1, 'output' => array('hostid', 'host'), 'hostids' => $hostids); $db_hosts2 = CHost::get($options); order_result($db_hosts2, 'host'); foreach ($db_hosts2 as $hnum => $host) { if (!isset($db_hosts[$host['hostid']])) { $host_tb->addItem($host['hostid'], $host['host']); } } $reportForm->addRow(S_HOSTS, $host_tb->Get(S_SELECTED_HOSTS, array(S_OTHER . SPACE . S_HOSTS . SPACE . '|' . SPACE . S_GROUP . SPACE, $cmbGroups))); // ---------- //*/ // PERIOD $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer'); $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);"); $reporttimetab = new CTable(null, 'calendar'); $reporttimetab->setAttribute('width', '10%'); $reporttimetab->setCellPadding(0); $reporttimetab->setCellSpacing(0); $reporttimetab->addRow(array(S_FROM, new CNumericBox('report_since_day', $report_timesince > 0 ? date('d', $report_timesince) : '', 2), '/', new CNumericBox('report_since_month', $report_timesince > 0 ? date('m', $report_timesince) : '', 2), '/', new CNumericBox('report_since_year', $report_timesince > 0 ? date('Y', $report_timesince) : '', 4), SPACE, new CNumericBox('report_since_hour', $report_timesince > 0 ? date('H', $report_timesince) : '', 2), ':', new CNumericBox('report_since_minute', $report_timesince > 0 ? date('i', $report_timesince) : '', 2), $clndr_icon)); zbx_add_post_js('create_calendar(null,' . '["report_since_day","report_since_month","report_since_year","report_since_hour","report_since_minute"],' . '"avail_report_since",' . '"report_timesince");'); $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_till'].clndr.clndrshow(pos.top,pos.left);"); $reporttimetab->addRow(array(S_TILL, new CNumericBox('report_till_day', $report_timetill > 0 ? date('d', $report_timetill) : '', 2), '/', new CNumericBox('report_till_month', $report_timetill > 0 ? date('m', $report_timetill) : '', 2), '/', new CNumericBox('report_till_year', $report_timetill > 0 ? date('Y', $report_timetill) : '', 4), SPACE, new CNumericBox('report_till_hour', $report_timetill > 0 ? date('H', $report_timetill) : '', 2), ':', new CNumericBox('report_till_minute', $report_timetill > 0 ? date('i', $report_timetill) : '', 2), $clndr_icon)); zbx_add_post_js('create_calendar(null,' . '["report_till_day","report_till_month","report_till_year","report_till_hour","report_till_minute"],' . '"avail_report_till",' . '"report_timetill");'); zbx_add_post_js('addListener($("filter_icon"),' . '"click",' . 'CLNDR[\'avail_report_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_since\'].clndr));' . 'addListener($("filter_icon"),' . '"click",' . 'CLNDR[\'avail_report_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_till\'].clndr));'); $reportForm->addRow(S_PERIOD, $reporttimetab); //----------- $scale = new CComboBox('scaletype', $scaletype); $scale->addItem(TIMEPERIOD_TYPE_HOURLY, S_HOURLY); $scale->addItem(TIMEPERIOD_TYPE_DAILY, S_DAILY); $scale->addItem(TIMEPERIOD_TYPE_WEEKLY, S_WEEKLY); $scale->addItem(TIMEPERIOD_TYPE_MONTHLY, S_MONTHLY); $scale->addItem(TIMEPERIOD_TYPE_YEARLY, S_YEARLY); $reportForm->addRow(S_SCALE, $scale); $avgcmb = new CComboBox('avgperiod', $avgperiod); $avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, S_HOURLY); $avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, S_DAILY); $avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, S_WEEKLY); $avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, S_MONTHLY); $avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, S_YEARLY); $reportForm->addRow(S_AVERAGE_BY, $avgcmb); // ITEMS $itemid = 0; $description = ''; if (count($items) && $items[0]['itemid'] > 0) { $itemid = $items[0]['itemid']; $description = get_item_by_itemid($itemid); $description = item_description($description); } $reportForm->addVar('items[0][itemid]', $itemid); $txtCondVal = new CTextBox('items[0][description]', $description, 50, 'yes'); $btnSelect = new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $reportForm->GetName() . "&dstfld1=items[0][itemid]&dstfld2=items[0][description]&" . "srctbl=items&srcfld1=itemid&srcfld2=description&monitored_hosts=1');", 'T'); $reportForm->addRow(S_ITEM, array($txtCondVal, $btnSelect)); $paletteCmb = new CComboBox('palette', $palette); $paletteCmb->addItem(0, S_PALETTE . ' #1'); $paletteCmb->addItem(1, S_PALETTE . ' #2'); $paletteCmb->addItem(2, S_PALETTE . ' #3'); $paletteCmb->addItem(3, S_PALETTE . ' #4'); $paletteTypeCmb = new CComboBox('palettetype', $palettetype); $paletteTypeCmb->addItem(0, S_MIDDLE); $paletteTypeCmb->addItem(1, S_DARKEN); $paletteTypeCmb->addItem(2, S_BRIGHTEN); $reportForm->addRow(S_PALETTE, array($paletteCmb, $paletteTypeCmb)); //-------------- $reportForm->addItemToBottomRow(new CButton('report_show', S_SHOW)); $reset = new CButton('reset', S_RESET); $reset->setType('reset'); $reportForm->addItemToBottomRow($reset); return $reportForm; }
} switch ($color_style) { case MARK_COLOR_RED: $color_style = 'red'; break; case MARK_COLOR_GREEN: $color_style = 'green'; break; case MARK_COLOR_BLUE: $color_style = 'blue'; break; } } $row = array(nbsp(zbx_date2str(S_HISTORY_LOG_ITEM_DATE_FORMAT, $data['clock']))); if ($fewItems) { $row[] = $host['host'] . ':' . item_description($item); } if ($logItem) { $row[] = $data['timestamp'] == 0 ? '-' : zbx_date2str(S_HISTORY_LOG_LOCALTIME_DATE_FORMAT, $data['timestamp']); // if this is a eventLog item, showing additional info if ($eventLogItem) { $row[] = zbx_empty($data['source']) ? '-' : $data['source']; $row[] = $data['severity'] == 0 ? '-' : new CCol(get_item_logtype_description($data['severity']), get_item_logtype_style($data['severity'])); $row[] = $data['logeventid'] == 0 ? '-' : $data['logeventid']; } } $data['value'] = encode_log(trim($data['value'], "\r\n")); $row[] = new CCol($data['value'], 'pre'); $crow = new CRow($row); if (is_null($color_style)) { $min_color = 0x98;
$events = CEvent::get($options); order_result($events, 'clock', ZBX_SORT_DOWN); $triggersOptions = array('triggerids' => zbx_objectValues($events, 'objectid'), 'select_hosts' => API_OUTPUT_EXTEND, 'select_triggers' => API_OUTPUT_EXTEND, 'select_items' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND); $triggers = CTrigger::get($triggersOptions); $triggers = zbx_toHash($triggers, 'triggerid'); foreach ($events as $enum => $event) { $trigger = $triggers[$event['objectid']]; $host = reset($trigger['hosts']); $items = array(); foreach ($trigger['items'] as $inum => $item) { $i = array(); $i['itemid'] = $item['itemid']; $i['value_type'] = $item['value_type']; //ZBX-3059: So it would be possible to show different caption for history for chars and numbers (KB) $i['action'] = str_in_array($item['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues'; $i['description'] = item_description($item); $items[] = $i; } // Actions $actions = get_event_actions_status($event['eventid']); if ($config['event_ack_enable']) { if ($event['acknowledged'] == 1) { $ack = new CLink(S_YES, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file']); } else { $ack = new CLink(S_NO, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file'], 'on'); } } $description = expand_trigger_description_by_data(zbx_array_merge($trigger, array('clock' => $event['clock'])), ZBX_FLAG_EVENT); $tr_desc = new CSpan($description, 'pointer'); $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " new Array({'triggerid': '" . $trigger['triggerid'] . "', 'lastchange': '" . $event['clock'] . "'})," . zbx_jsvalue($items, true) . ");"); // Duration
$elements = array(new CCol(S_SERVER, 'bold'), new CCol($sec_10[0], $sec_10[0] ? 'unknown_trigger' : 'normal'), new CCol($sec_30[0], $sec_30[0] ? 'information' : 'normal'), new CCol($sec_60[0], $sec_60[0] ? 'warning' : 'normal'), new CCol($sec_300[0], $sec_300[0] ? 'average' : 'normal'), new CCol($sec_600[0], $sec_600[0] ? 'high' : 'normal'), new CCol($sec_rest[0], $sec_rest[0] ? 'disaster' : 'normal')); $table->addRow($elements); } else { if ($_REQUEST["config"] == 2) { $arr = array(); $table->SetHeader(array(S_NEXT_CHECK, S_DELAYED_BY, is_show_all_nodes() ? S_NODE : null, S_HOST, S_DESCRIPTION)); while ($row = DBfetch($result)) { $res = calculate_item_nextcheck($row['itemid'], $row['type'], $row['delay'], $row['delay_flex'], $row['lastclock']); if (0 != $row['proxy_hostid']) { $res['nextcheck'] = $row['lastclock'] + $res['delay']; } $diff = $now - $res['nextcheck']; if ($diff <= 5) { continue; } array_push($arr, array($res['nextcheck'], $row['hostid'], $row['host'], item_description($row))); } $rows = 0; sort($arr); foreach ($arr as $r) { $rows++; if ($rows > 500) { $truncated = 1; break; } $table->AddRow(array(date(S_DATE_FORMAT_YMDHMS, $r[0]), zbx_date2age($r[0]), get_node_name_by_elid($r[1]), $r[2], $r[3])); } } } } $table->Show();
function get_trigger_overview_cells(&$table_row, &$trhosts, &$hostname) { $css_class = NULL; unset($tr_ov_menu); $ack = null; if (isset($trhosts[$hostname])) { unset($ack_menu); switch ($trhosts[$hostname]['value']) { case TRIGGER_VALUE_TRUE: $css_class = get_severity_style($trhosts[$hostname]['priority']); if ($ack = get_last_event_by_triggerid($trhosts[$hostname]['triggerid'])) { $ack_menu = array(S_ACKNOWLEDGE, 'acknow.php?eventid=' . $ack['eventid'], array('tw' => '_blank')); } if (1 == $ack['acknowledged']) { $ack = new CImg('images/general/tick.png', 'ack'); } else { $ack = null; } break; case TRIGGER_VALUE_FALSE: $css_class = 'normal'; break; default: $css_class = 'unknown_trigger'; } $style = 'cursor: pointer; '; if (time(NULL) - $trhosts[$hostname]['lastchange'] < 300) { $style .= 'background-image: url(images/gradients/blink1.gif); ' . 'background-position: top left; ' . 'background-repeat: repeat;'; } else { if (time(NULL) - $trhosts[$hostname]['lastchange'] < 900) { $style .= 'background-image: url(images/gradients/blink2.gif); ' . 'background-position: top left; ' . 'background-repeat: repeat;'; } } unset($item_menu); $tr_ov_menu = array(array(S_TRIGGER, null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader'))), array(S_EVENTS, 'events.php?triggerid=' . $trhosts[$hostname]['triggerid'], array('tw' => '_blank'))); if (isset($ack_menu)) { $tr_ov_menu[] = $ack_menu; } $db_items = DBselect('select distinct i.itemid, i.description, i.key_, i.value_type ' . ' from items i, functions f ' . ' where f.itemid=i.itemid and f.triggerid=' . $trhosts[$hostname]['triggerid']); while ($item_data = DBfetch($db_items)) { $description = item_description($item_data); switch ($item_data['value_type']) { case ITEM_VALUE_TYPE_UINT64: case ITEM_VALUE_TYPE_FLOAT: $action = 'showgraph'; $status_bar = S_SHOW_GRAPH_OF_ITEM . ' \'' . $description . '\''; break; case ITEM_VALUE_TYPE_LOG: case ITEM_VALUE_TYPE_STR: case ITEM_VALUE_TYPE_TEXT: default: $action = 'showlatest'; $status_bar = S_SHOW_VALUES_OF_ITEM . ' \'' . $description . '\''; break; } if (strlen($description) > 25) { $description = substr($description, 0, 22) . '...'; } $item_menu[$action][] = array($description, 'history.php?action=' . $action . '&itemid=' . $item_data['itemid'] . '&period=3600', array('tw' => '', 'sb' => $status_bar)); } if (isset($item_menu['showgraph'])) { $tr_ov_menu[] = array(S_GRAPHS, null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader'))); $tr_ov_menu = array_merge($tr_ov_menu, $item_menu['showgraph']); } if (isset($item_menu['showlatest'])) { $tr_ov_menu[] = array(S_VALUES, null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader'))); $tr_ov_menu = array_merge($tr_ov_menu, $item_menu['showlatest']); } unset($item_menu); } // dependency // TRIGGERS ON WHICH DEPENDS THIS $desc = array(); if (isset($trhosts[$hostname])) { $triggerid = $trhosts[$hostname]['triggerid']; $dependency = false; $dep_table = new CTableInfo(); $dep_table->AddOption('style', 'width: 200px;'); $dep_table->addRow(bold(S_DEPENDS_ON . ':')); $sql_dep = 'SELECT * FROM trigger_depends WHERE triggerid_down=' . $triggerid; $dep_res = DBselect($sql_dep); while ($dep_row = DBfetch($dep_res)) { $dep_table->addRow(SPACE . '-' . SPACE . expand_trigger_description($dep_row['triggerid_up'])); $dependency = true; } if ($dependency) { $img = new Cimg('images/general/down_icon.png', 'DEP_DOWN'); $img->AddOption('style', 'vertical-align: middle; border: 0px;'); $img->SetHint($dep_table); array_push($desc, $img); } unset($img, $dep_table, $dependency); // TRIGGERS THAT DEPEND ON THIS $dependency = false; $dep_table = new CTableInfo(); $dep_table->AddOption('style', 'width: 200px;'); $dep_table->addRow(bold(S_DEPENDENT . ':')); $sql_dep = 'SELECT * FROM trigger_depends WHERE triggerid_up=' . $triggerid; $dep_res = DBselect($sql_dep); while ($dep_row = DBfetch($dep_res)) { $dep_table->addRow(SPACE . '-' . SPACE . expand_trigger_description($dep_row['triggerid_down'])); $dependency = true; } if ($dependency) { $img = new Cimg('images/general/up_icon.png', 'DEP_UP'); $img->AddOption('style', 'vertical-align: middle; border: 0px;'); $img->SetHint($dep_table); array_push($desc, $img); } unset($img, $dep_table, $dependency); } //------------------------ $status_col = new CCol(array($desc, $ack), $css_class); if (isset($style)) { $status_col->AddOption('style', $style); } if (isset($tr_ov_menu)) { $tr_ov_menu = new CPUMenu($tr_ov_menu, 170); $status_col->OnClick($tr_ov_menu->GetOnActionJS()); $status_col->AddAction('onmouseover', 'this.old_border=this.style.border; this.style.border=\'1px dotted #0C0CF0\''); $status_col->AddAction('onmouseout', 'this.style.border=this.old_border;'); } array_push($table_row, $status_col); return $table_row; }
function delete_application($applicationid) { $app = get_application_by_applicationid($applicationid); $host = get_host_by_hostid($app["hostid"]); // first delete child applications $db_applications = DBselect("select applicationid from applications where templateid={$applicationid}"); while ($db_app = DBfetch($db_applications)) { // recursion $result = delete_application($db_app["applicationid"]); if (!$result) { return $result; } } if ($info = DBfetch(DBselect('select name from httptest where applicationid=' . $applicationid))) { info("Application '" . $host["host"] . ":" . $app["name"] . "' used by scenario '" . $info['name'] . "'"); return false; } if ($info = DBfetch(DBselect('select i.itemid,i.key_,i.description from items_applications ia, items i ' . ' where i.type=' . ITEM_TYPE_HTTPTEST . ' and i.itemid=ia.itemid and ia.applicationid=' . $applicationid))) { info("Application '" . $host["host"] . ":" . $app["name"] . "' used by item '" . item_description($info) . "'"); return false; } $result = DBexecute("delete from items_applications where applicationid={$applicationid}"); $result = DBexecute("delete from applications where applicationid={$applicationid}"); if ($result) { info("Application '" . $host["host"] . ":" . $app["name"] . "' deleted"); } return $result; }
$events = CEvent::get($ev_options); order_result($events, 'clock', ZBX_SORT_DOWN); foreach ($events as $enum => $event) { $triggers[$event['objectid']]['events'][] = $event; } } foreach ($triggers as $tnum => $trigger) { $trigger['desc'] = $description = expand_trigger_description($trigger['triggerid']); $items = array(); $used_hosts = array(); foreach ($trigger['hosts'] as $th) { $used_hosts[$th['hostid']] = $th['host']; } $used_host_count = count($used_hosts); foreach ($trigger['items'] as $inum => $item) { $item_description = item_description($item); //if we have items from different hosts, we must prefix a host name if ($used_host_count > 1) { $item_description = $used_hosts[$item['hostid']] . ':' . $item_description; } $items[$inum]['itemid'] = $item['itemid']; $items[$inum]['value_type'] = $item['value_type']; //ZBX-3059: So it would be possible to show different caption for history for chars and numbers (KB) $items[$inum]['action'] = str_in_array($item['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues'; $items[$inum]['description'] = $item_description; } $trigger['items'] = $items; //---- $description = new CSpan($description, 'link_menu'); // trigger description js menu {{{ $hosts = reset($trigger['hosts']);
function make_graph_submenu() { $graphids = array(); $itemids = array(); $fav_graphs = get_favorites('web.favorite.graphids'); foreach ($fav_graphs as $key => $favorite) { if ('itemid' == $favorite['source']) { $itemids[$favorite['value']] = $favorite['value']; } else { $graphids[$favorite['value']] = $favorite['value']; } } $options = array('graphids' => $graphids, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND); $graphs = CGraph::get($options); $graphs = zbx_toHash($graphs, 'graphid'); $options = array('itemids' => $itemids, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND, 'webitems' => 1); $items = CItem::get($options); $items = zbx_toHash($items, 'itemid'); $favGraphs = array(); foreach ($fav_graphs as $key => $favorite) { $source = $favorite['source']; $sourceid = $favorite['value']; if ('itemid' == $source) { if (!isset($items[$sourceid])) { continue; } $item_added = true; $item = $items[$sourceid]; $host = reset($item['hosts']); $item['description'] = item_description($item); $favGraphs[] = array('name' => $host['host'] . ':' . $item['description'], 'favobj' => 'itemid', 'favid' => $sourceid, 'action' => 'remove'); } else { if (!isset($graphs[$sourceid])) { continue; } $graph_added = true; $graph = $graphs[$sourceid]; $ghost = reset($graph['hosts']); $favGraphs[] = array('name' => $ghost['host'] . ':' . $graph['name'], 'favobj' => 'graphid', 'favid' => $sourceid, 'action' => 'remove'); } } if (isset($graph_added)) { $favGraphs[] = array('name' => S_REMOVE . SPACE . S_ALL_S . SPACE . S_GRAPHS, 'favobj' => 'graphid', 'favid' => 0, 'action' => 'remove'); } if (isset($item_added)) { $favGraphs[] = array('name' => S_REMOVE . SPACE . S_ALL_S . SPACE . S_SIMPLE_GRAPHS, 'favobj' => 'itemid', 'favid' => 0, 'action' => 'remove'); } return $favGraphs; }
$sec_600[$row['proxy_hostid']]++; } else { $sec_rest[$row['proxy_hostid']]++; } } } } } } $table->setHeader(array(S_PROXY, S_5_SECONDS, S_10_SECONDS, S_30_SECONDS, S_1_MINUTE, S_5_MINUTES, S_MORE_THAN_10_MINUTES)); $db_proxies = DBselect('select hostid,host from hosts where status=' . HOST_STATUS_PROXY . ' order by host'); while (null != ($db_proxy = DBfetch($db_proxies))) { $elements = array($db_proxy['host'], new CCol($sec_10[$db_proxy['hostid']], $sec_10[$db_proxy['hostid']] ? "unknown_trigger" : "normal"), new CCol($sec_30[$db_proxy['hostid']], $sec_30[$db_proxy['hostid']] ? "information" : "normal"), new CCol($sec_60[$db_proxy['hostid']], $sec_60[$db_proxy['hostid']] ? "warning" : "normal"), new CCol($sec_300[$db_proxy['hostid']], $sec_300[$db_proxy['hostid']] ? "average" : "normal"), new CCol($sec_600[$db_proxy['hostid']], $sec_600[$db_proxy['hostid']] ? "high" : "normal"), new CCol($sec_rest[$db_proxy['hostid']], $sec_rest[$db_proxy['hostid']] ? "disaster" : "normal")); $table->addRow($elements); } $elements = array(new CCol(S_SERVER, 'bold'), new CCol($sec_10[0], $sec_10[0] ? 'unknown_trigger' : 'normal'), new CCol($sec_30[0], $sec_30[0] ? 'information' : 'normal'), new CCol($sec_60[0], $sec_60[0] ? 'warning' : 'normal'), new CCol($sec_300[0], $sec_300[0] ? 'average' : 'normal'), new CCol($sec_600[0], $sec_600[0] ? 'high' : 'normal'), new CCol($sec_rest[0], $sec_rest[0] ? 'disaster' : 'normal')); $table->addRow($elements); } else { if ($_REQUEST["show"] == 2) { $table->SetHeader(array(S_NEXT_CHECK, is_show_subnodes() ? S_NODE : null, S_HOST, S_DESCRIPTION)); while ($row = DBfetch($result)) { $table->AddRow(array(date("m.d.Y H:i:s", $row["nextcheck"]), get_node_name_by_elid($row['hostid']), $row['host'], item_description($row))); } } } } $table->Show(); if ($_REQUEST["show"] != 0) { show_table_header(S_TOTAL . ": " . $table->GetNumRows()); } include_once "include/page_footer.php";
function get_screen_item_form() { global $USER_DETAILS; $form = new CFormTable(S_SCREEN_CELL_CONFIGURATION, 'screenedit.php?screenid=' . $_REQUEST['screenid']); $form->SetHelp('web.screenedit.cell.php'); if (isset($_REQUEST['screenitemid'])) { $sql = 'SELECT * ' . ' FROM screens_items' . ' WHERE screenid=' . $_REQUEST['screenid'] . ' AND screenitemid=' . $_REQUEST['screenitemid']; $iresult = DBSelect($sql); $form->addVar('screenitemid', $_REQUEST['screenitemid']); } else { $form->addVar('x', $_REQUEST['x']); $form->addVar('y', $_REQUEST['y']); } if (isset($_REQUEST['screenitemid']) && !isset($_REQUEST['form_refresh'])) { $irow = DBfetch($iresult); $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 { $resourcetype = get_request('resourcetype', 0); $resourceid = get_request('resourceid', 0); $width = get_request('width', 500); $height = get_request('height', 100); $colspan = get_request('colspan', 0); $rowspan = get_request('rowspan', 0); $elements = get_request('elements', 25); $valign = get_request('valign', VALIGN_DEFAULT); $halign = get_request('halign', HALIGN_DEFAULT); $style = get_request('style', 0); $url = get_request('url', ''); $dynamic = get_request('dynamic', SCREEN_SIMPLE_ITEM); } $form->addVar('screenid', $_REQUEST['screenid']); // a-z order!!! $cmbRes = new CCombobox('resourcetype', $resourcetype, 'submit()'); $cmbRes->addItem(SCREEN_RESOURCE_CLOCK, S_CLOCK); $cmbRes->addItem(SCREEN_RESOURCE_DATA_OVERVIEW, S_DATA_OVERVIEW); $cmbRes->addItem(SCREEN_RESOURCE_GRAPH, S_GRAPH); $cmbRes->addItem(SCREEN_RESOURCE_ACTIONS, S_HISTORY_OF_ACTIONS); $cmbRes->addItem(SCREEN_RESOURCE_EVENTS, S_HISTORY_OF_EVENTS); $cmbRes->addItem(SCREEN_RESOURCE_HOSTS_INFO, S_HOSTS_INFO); $cmbRes->addItem(SCREEN_RESOURCE_MAP, S_MAP); $cmbRes->addItem(SCREEN_RESOURCE_PLAIN_TEXT, S_PLAIN_TEXT); $cmbRes->addItem(SCREEN_RESOURCE_SCREEN, S_SCREEN); $cmbRes->addItem(SCREEN_RESOURCE_SERVER_INFO, S_SERVER_INFO); $cmbRes->addItem(SCREEN_RESOURCE_SIMPLE_GRAPH, S_SIMPLE_GRAPH); $cmbRes->addItem(SCREEN_RESOURCE_HOSTGROUP_TRIGGERS, S_STATUS_OF_HOSTGROUP_TRIGGERS); $cmbRes->addItem(SCREEN_RESOURCE_HOST_TRIGGERS, S_STATUS_OF_HOST_TRIGGERS); $cmbRes->addItem(SCREEN_RESOURCE_SYSTEM_STATUS, S_SYSTEM_STATUS); $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_INFO, S_TRIGGERS_INFO); $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, S_TRIGGERS_OVERVIEW); $cmbRes->addItem(SCREEN_RESOURCE_URL, S_URL); $form->addRow(S_RESOURCE, $cmbRes); if ($resourcetype == SCREEN_RESOURCE_GRAPH) { // User-defined graph $options = array('graphids' => $resourceid, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND); $graphs = CGraph::get($options); $caption = ''; $id = 0; if (!empty($graphs)) { $id = $resourceid; $graph = reset($graphs); order_result($graph['hosts'], 'host'); $graph['host'] = reset($graph['hosts']); $caption = $graph['host']['host'] . ':' . $graph['name']; $nodeName = get_node_name_by_elid($graph['host']['hostid']); if (!zbx_empty($nodeName)) { $caption = '(' . $nodeName . ') ' . $caption; } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 75, 'yes'); $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&real_hosts=1&dstfld1=resourceid&dstfld2=caption&srctbl=graphs&srcfld1=graphid&srcfld2=name',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_GRAPH_NAME, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) { // Simple graph $options = array('itemids' => $resourceid, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND); $items = CItem::get($options); $caption = ''; $id = 0; if (!empty($items)) { $id = $resourceid; $item = reset($items); $item['host'] = reset($item['hosts']); $caption = item_description($item); $nodeName = get_node_name_by_elid($item['itemid']); if (!zbx_empty($nodeName)) { $caption = '(' . $nodeName . ') ' . $caption; } } $form->addVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 75, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&real_hosts=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=simple_graph&srcfld1=itemid&srcfld2=description',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_MAP) { // Map $options = array('sysmapids' => $resourceid, 'output' => API_OUTPUT_EXTEND); $maps = CMap::get($options); $caption = ''; $id = 0; if (!empty($maps)) { $id = $resourceid; $map = reset($maps); $caption = $map['name']; $nodeName = get_node_name_by_elid($map['sysmapid']); if (!zbx_empty($nodeName)) { $caption = '(' . $nodeName . ') ' . $caption; } } $form->addVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=sysmaps&srcfld1=sysmapid&srcfld2=name',400,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) { // Plain text $options = array('itemids' => $resourceid, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND); $items = CItem::get($options); $caption = ''; $id = 0; if (!empty($items)) { $id = $resourceid; $item = reset($items); $item['host'] = reset($item['hosts']); $caption = item_description($item); $nodeName = get_node_name_by_elid($item['itemid']); if (!zbx_empty($nodeName)) { $caption = '(' . $nodeName . ') ' . $caption; } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 75, 'yes'); $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=plain_text&srcfld1=itemid&srcfld2=description',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2)); $form->addRow(S_SHOW_TEXT_AS_HTML, new CCheckBox('style', $style, null, 1)); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_HOSTGROUP_TRIGGERS, SCREEN_RESOURCE_HOST_TRIGGERS))) { // Status of triggers $caption = ''; $id = 0; if (SCREEN_RESOURCE_HOSTGROUP_TRIGGERS == $resourcetype) { if ($resourceid > 0) { $options = array('groupids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'editable' => 1); $groups = CHostgroup::get($options); foreach ($groups as $gnum => $group) { $caption = get_node_name_by_elid($group['groupid'], true, ':') . $group['name']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 60, 'yes'); $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=host_group&srcfld1=groupid&srcfld2=name',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_GROUP, array($textfield, SPACE, $selectbtn)); } else { if ($resourceid > 0) { $options = array('hostids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'editable' => 1); $hosts = CHost::get($options); foreach ($hosts as $hnum => $host) { $caption = get_node_name_by_elid($host['hostid'], true, ':') . $host['host']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 60, 'yes'); $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=hosts&srcfld1=hostid&srcfld2=host',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_HOST, array($textfield, SPACE, $selectbtn)); } $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2)); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_EVENTS, SCREEN_RESOURCE_ACTIONS))) { // History of actions // History of events $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2)); $form->addVar('resourceid', 0); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) { // Overviews $caption = ''; $id = 0; if ($resourceid > 0) { $options = array('groupids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'editable' => 1); $groups = CHostgroup::get($options); foreach ($groups as $gnum => $group) { $caption = get_node_name_by_elid($group['groupid'], true, ':') . $group['name']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 75, 'yes'); $selectbtn = new CButton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=overview&srcfld1=groupid&srcfld2=name',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_GROUP, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_SCREEN) { // Screens $caption = ''; $id = 0; if ($resourceid > 0) { $result = DBselect('SELECT DISTINCT n.name as node_name,s.screenid,s.name ' . ' FROM screens s ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.screenid') . ' WHERE s.screenid=' . $resourceid); while ($row = DBfetch($result)) { $r = CScreen::get(array('screenids' => $row['screenid'], 'output' => API_OUTPUT_SHORTEN)); if (empty($r)) { continue; } if (check_screen_recursion($_REQUEST['screenid'], $row['screenid'])) { continue; } $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } $form->addVar('resourceid', $id); $textfield = new Ctextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=screens2&srcfld1=screenid&srcfld2=name&screenid=" . $_REQUEST['screenid'] . "',800,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn)); } else { if ($resourcetype == SCREEN_RESOURCE_HOSTS_INFO || $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) { // HOSTS info $caption = ''; $id = 0; $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY); if (remove_nodes_from_id($resourceid) > 0) { $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg, groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=' . $resourceid); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . $row['name']; $id = $resourceid; } } else { if (remove_nodes_from_id($resourceid) == 0) { $result = DBselect('SELECT DISTINCT n.name as node_name ' . ' FROM nodes n ' . ' WHERE n.nodeid=' . id2nodeid($resourceid)); while ($row = DBfetch($result)) { $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : ''; $caption = $row['node_name'] . S_MINUS_ALL_GROUPS_MINUS; $id = $resourceid; } } } $form->addVar('resourceid', $id); $textfield = new CTextbox('caption', $caption, 60, 'yes'); $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?writeonly=1&dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=host_group_scr&srcfld1=groupid&srcfld2=name',480,450);"); $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $form->addRow(S_GROUP, array($textfield, SPACE, $selectbtn)); } else { // SCREEN_RESOURCE_CLOCK $form->addVar('resourceid', 0); } } } } } } } } } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO))) { $cmbStyle = new CComboBox("style", $style); $cmbStyle->addItem(STYLE_HORISONTAL, S_HORIZONTAL); $cmbStyle->addItem(STYLE_VERTICAL, S_VERTICAL); $form->addRow(S_STYLE, $cmbStyle); } else { if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) { $cmbStyle = new CComboBox('style', $style); $cmbStyle->addItem(STYLE_LEFT, S_LEFT); $cmbStyle->addItem(STYLE_TOP, S_TOP); $form->addRow(S_HOSTS_LOCATION, $cmbStyle); } else { if ($resourcetype == SCREEN_RESOURCE_CLOCK) { $cmbStyle = new CComboBox('style', $style); $cmbStyle->addItem(TIME_TYPE_LOCAL, S_LOCAL_TIME); $cmbStyle->addItem(TIME_TYPE_SERVER, S_SERVER_TIME); $form->addRow(S_TIME_TYPE, $cmbStyle); } else { $form->addVar('style', 0); } } } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_URL))) { $form->addRow(S_URL, new CTextBox('url', $url, 60)); } else { $form->addVar('url', ''); } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) { $form->addRow(S_WIDTH, new CNumericBox('width', $width, 5)); $form->addRow(S_HEIGHT, new CNumericBox('height', $height, 5)); } else { $form->addVar('width', 500); $form->addVar('height', 100); } if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) { $cmbHalign = new CComboBox('halign', $halign); $cmbHalign->addItem(HALIGN_CENTER, S_CENTRE); $cmbHalign->addItem(HALIGN_LEFT, S_LEFT); $cmbHalign->addItem(HALIGN_RIGHT, S_RIGHT); $form->addRow(S_HORIZONTAL_ALIGN, $cmbHalign); } else { $form->addVar('halign', 0); } $cmbValign = new CComboBox('valign', $valign); $cmbValign->addItem(VALIGN_MIDDLE, S_MIDDLE); $cmbValign->addItem(VALIGN_TOP, S_TOP); $cmbValign->addItem(VALIGN_BOTTOM, S_BOTTOM); $form->addRow(S_VERTICAL_ALIGN, $cmbValign); $form->addRow(S_COLUMN_SPAN, new CNumericBox('colspan', $colspan, 2)); $form->addRow(S_ROW_SPAN, new CNumericBox('rowspan', $rowspan, 2)); // dynamic AddOn if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT))) { $form->addRow(S_DYNAMIC_ITEM, new CCheckBox('dynamic', $dynamic, null, 1)); } $form->addItemToBottomRow(new CButton('save', S_SAVE)); if (isset($_REQUEST['screenitemid'])) { $form->addItemToBottomRow(SPACE); $form->addItemToBottomRow(new CButtonDelete(null, url_param('form') . url_param('screenid') . url_param('screenitemid'))); } $form->addItemToBottomRow(SPACE); $form->addItemToBottomRow(new CButtonCancel(url_param('screenid'))); return $form; }
$sortorder = get_request("sortorder", 0); $yaxisside = get_request("yaxisside", 1); $calc_fnc = get_request("calc_fnc", 2); $type = get_request("type", 0); $periods_cnt = get_request("periods_cnt", 5); $only_hostid = get_request("only_hostid", null); $monitored_hosts = get_request('monitored_hosts', null); $caption = $itemid ? S_UPD_ITEM_FOR_THE_GRAPH : S_NEW_ITEM_FOR_THE_GRAPH; $frmGItem = new CFormTable($caption); $frmGItem->setName('graph_item'); $frmGItem->setHelp("web.graph.item.php"); $frmGItem->addVar('dstfrm', $_REQUEST['dstfrm']); $description = ''; if ($itemid > 0) { $description = get_item_by_itemid($itemid); $description = item_description($description); } $frmGItem->addVar('graphid', $graphid); $frmGItem->addVar('gid', $gid); $frmGItem->addVar('list_name', $list_name); $frmGItem->addVar('itemid', $itemid); $frmGItem->addVar('graphtype', $graphtype); $frmGItem->addVar('only_hostid', $only_hostid); $txtCondVal = new CTextBox('description', $description, 50, 'yes'); $host_condition = ''; if (isset($only_hostid)) { // graph for template must use only one host $host_condition = "&only_hostid=" . $only_hostid; } else { if (isset($monitored_hosts)) { $host_condition = "&monitored_hosts=1";
$itemTriggers = CTrigger::get(array('triggerids' => $itemTriggerIds, 'expandDescription' => true, 'output' => API_OUTPUT_EXTEND, 'select_hosts' => array('hostid', 'host', 'status'), 'select_functions' => API_OUTPUT_EXTEND, 'select_items' => API_OUTPUT_EXTEND, 'preservekeys' => true)); $trigRealHosts = getParentHostsByTriggers($itemTriggers); foreach ($items as $inum => $item) { if ($show_host) { $host = array_pop($item['hosts']); $host = $host['host']; } else { $host = null; } $description = array(); if ($item['templateid']) { $template_host = get_realhost_by_itemid($item['templateid']); $description[] = new CLink($template_host['host'], '?hostid=' . $template_host['hostid'], 'unknown'); $description[] = ':'; } $item['description_expanded'] = item_description($item); $description[] = new CLink($item['description_expanded'], '?form=update&itemid=' . $item['itemid']); $status = new CCol(new CLink(item_status2str($item['status']), '?group_itemid=' . $item['itemid'] . '&go=' . ($item['status'] ? 'activate' : 'disable'), item_status2style($item['status']))); if (zbx_empty($item['error'])) { $error = new CDiv(SPACE, 'iconok'); } else { $error = new CDiv(SPACE, 'iconerror'); $error->setHint($item['error'], '', 'on'); } if (empty($item['applications'])) { $applications = '-'; } else { $applications = array(); foreach ($item['applications'] as $anum => $app) { $applications[] = $app['name']; }