$search_div->setAttribute('id', 'zbx_search'); $search_div->setAttribute('class', 'zbx_search'); $sub_menu_table->addRow(array($menu_divs, $search_div)); $page_menu->addItem($sub_menu_table); //--- /* SEARCH form $search_form = new CForm('search.php'); $search_form->addItem(new CDiv(array(S_SEARCH_BIG.': ', new CTextBox('search','',20)))); $search_div = new CDiv($search_form); $search_div->setAttribute('id','zbx_search'); $search_div->setAttribute('class','zbx_search'); $page_menu->addItem($search_div); //*/ $page_menu->show(); } //------------------------------------- <HISTORY> --------------------------------------- if (isset($page['hist_arg']) && $USER_DETAILS['alias'] != ZBX_GUEST_USER && $page['type'] == PAGE_TYPE_HTML && !defined('ZBX_PAGE_NO_MENU')) { $table = new CTable(); $table->setClass('history'); $table->setCellSpacing(0); $table->setCellPadding(0); $history = get_user_history(); $tr = new CRow(new CCol('History:', 'caption')); $tr->addItem($history); $table->addRow($tr); $table->Show(); } else { if ($page['type'] == PAGE_TYPE_HTML && !defined('ZBX_PAGE_NO_MENU')) { echo SBR;
if (isset($summary[$alert['userid']]['medias'][$alert['mediatypeid']])) { $summary[$alert['userid']]['medias'][$alert['mediatypeid']]++; } else { $summary[$alert['userid']]['medias'][$alert['mediatypeid']] = 1; } } next($alerts); } foreach ($summary as $s) { if ($s['total'] == 0) { array_push($row, ''); } else { array_push($row, [$s['total'], $media_type == 0 ? SPACE . '(' . implode('/', $s['medias']) . ')' : '']); } } $table->addRow($row); } $widget->addItem($table)->show(); if ($media_type == 0) { echo BR(); $links = []; foreach ($media_types as $id => $description) { $links[] = new CLink($description, 'zabbix.php?action=mediatype.edit&mediatypeid=' . $id); $links[] = SPACE . '/' . SPACE; } array_pop($links); $linksDiv = new CDiv([SPACE . _('all') . SPACE . '(' . SPACE, $links, SPACE . ')']); $linksDiv->show(); } } require_once dirname(__FILE__) . '/include/page_footer.php';
/** * Output profiling data. */ public function show() { global $DB; $debug_str = '<a name="debug"></a>'; $debug_str .= '******************** ' . _('Script profiler') . ' ********************' . '<br>'; $totalScriptTime = $this->stopTime - $this->startTime; $totalTimeStr = _s('Total time: %s', round($totalScriptTime, 6)); if ($totalTimeStr > $this->slowScriptTime) { $totalTimeStr = '<b>' . $totalTimeStr . '</b>'; } $debug_str .= $totalTimeStr . '<br>'; $sqlTotalTimeStr = _s('Total SQL time: %s', $this->sqlTotalTime); if ($sqlTotalTimeStr > $this->slowTotalSqlTime) { $sqlTotalTimeStr = '<b>' . $sqlTotalTimeStr . '</b>'; } $debug_str .= $sqlTotalTimeStr . '<br>'; if (isset($DB) && isset($DB['SELECT_COUNT'])) { $debug_str .= _s('SQL count: %s (selects: %s | executes: %s)', count($this->sqlQueryLog), $DB['SELECT_COUNT'], $DB['EXECUTE_COUNT']) . '<br>'; } $debug_str .= _s('Peak memory usage: %s', mem2str($this->getMemoryPeak())) . '<br>'; $debug_str .= _s('Memory limit: %s', ini_get('memory_limit')) . '<br>'; $debug_str .= '<br>'; foreach ($this->apiLog as $i => $apiCall) { $debug_str .= '<div style="border-bottom: 1px dotted gray; margin-bottom: 20px;">'; list($class, $method, $params, $result, $file, $line) = $apiCall; // api method $debug_str .= '<div style="padding-bottom: 10px;">'; $debug_str .= $i + 1 . '. <b>' . $class . '->' . $method . '</b> [' . $file . ':' . $line . ']'; $debug_str .= '</div>'; // parameters $debug_str .= '<table><tr><td style="width: 300px" valign="top">Parameters:'; foreach ($params as $p) { $debug_str .= '<pre>' . print_r(CHtml::encode($p), true) . '</pre>'; } $debug_str .= '</td>'; // result $debug_str .= '<td valign="top">Result:<pre>' . print_r(CHtml::encode($result), true) . '</pre></td>'; $debug_str .= '</tr></table>'; $debug_str .= '</div>'; } $debug_str .= '<br>'; foreach ($this->sqlQueryLog as $query) { $time = $query[0]; $sql = htmlspecialchars($query[1], ENT_QUOTES, 'UTF-8'); if (strpos($sql, 'SELECT ') !== false) { $sqlString = '<span style="color: green; font-size: 1.2em;">' . $sql . '</span>'; } else { $sqlString = '<span style="color: blue; font-size: 1.2em;">' . $sql . '</span>'; } $sqlString = 'SQL (' . $time . '): ' . $sqlString . '<br>'; if ($time > $this->slowSqlQueryTime) { $sqlString = '<b>' . $sqlString . '</b>'; } $debug_str .= $sqlString; $callStackString = '<span style="font-style: italic;">' . $this->formatCallStack($query[2]) . '</span>' . '<br>' . '<br>'; $debug_str .= rtrim($callStackString, '-> ') . '</span>' . '<br>' . '<br>'; } $debug = new CDiv(null, 'textcolorstyles'); $debug->attr('name', 'zbx_debug_info'); $debug->attr('style', 'display: none; overflow: auto; width: 95%; border: 1px #777777 solid; margin: 4px; padding: 4px;'); $debug->addItem(array(BR(), new CJSscript($debug_str), BR())); $debug->show(); }
$rst_icon = new CDiv(SPACE, 'iconreset'); $rst_icon->addOption('title', S_RESET); $rst_icon->addAction('onclick', new CScript("javascript: graphload(SCROLL_BAR.dom_graphs, " . (time() + 100000000) . ", 3600, false);")); } $charts_hat = create_hat(S_GRAPHS_BIG, $p_elements, array($icon, $rst_icon, $fs_icon), 'hat_charts', get_profile('web.charts.hats.hat_charts.state', 1)); $charts_hat->show(); if ($_REQUEST['graphid'] > 0) { // NAV BAR $stime = get_min_itemclock_by_graphid($_REQUEST['graphid']); $stime = is_null($stime) ? 0 : $stime; $bstime = time() - $effectiveperiod; if (isset($_REQUEST['stime'])) { $bstime = $_REQUEST['stime']; $bstime = mktime(substr($bstime, 8, 2), substr($bstime, 10, 2), 0, substr($bstime, 4, 2), substr($bstime, 6, 2), substr($bstime, 0, 4)); } $script = 'scrollinit(0,' . $effectiveperiod . ',' . $stime . ',0,' . $bstime . '); showgraphmenu("graph");'; if ($graphtype == GRAPH_TYPE_NORMAL || $graphtype == GRAPH_TYPE_STACKED) { $script .= 'graph_zoom_init("' . $dom_graph_id . '",' . $bstime . ',' . $effectiveperiod . ',ZBX_G_WIDTH,' . $graph_height . ',true);'; } zbx_add_post_js($script); $scroll_div = new CDiv(); $scroll_div->addOption('id', 'scroll_cntnr'); $scroll_div->addOption('style', 'border: 0px #CC0000 solid; height: 25px; width: 800px;'); $scroll_div->show(); // navigation_bar('charts.php',array('groupid','hostid','graphid')); //------------- } include_once 'include/page_footer.php'; ?>
public static function profiling_stop($type = NULL) { global $starttime; global $memorystamp; global $sqlrequests; global $sqlmark; global $perf_counter; global $var_list; global $USER_DETAILS; global $DB; if (isset($USER_DETAILS['debug_mode']) && $USER_DETAILS['debug_mode'] == GROUP_DEBUG_MODE_DISABLED) { return; } $endtime = COpt::getmicrotime(); $memory = COpt::getmemoryusage(); if (is_null($type)) { $type = 'global'; } $debug_str = ''; $debug_str .= '<a name="debug"></a>'; $debug_str .= "******************* Stats for {$type} *************************" . OBR; if (defined('USE_TIME_PROF')) { $time = $endtime - $starttime[$type]; if ($time < TOTAL_TIME) { $debug_str .= 'Total time: ' . round($time, 6) . OBR; } else { $debug_str .= '<b>Total time: ' . round($time, 6) . '</b>' . OBR; } } if (defined('USE_MEM_PROF')) { $debug_str .= 'Memory limit : ' . ini_get('memory_limit') . OBR; $debug_str .= 'Memory usage : ' . mem2str($memorystamp[$type]) . ' - ' . mem2str($memory) . OBR; $debug_str .= 'Memory leak : ' . mem2str($memory - $memorystamp[$type]) . OBR; } if (defined('USE_VAR_MON')) { $curr_var_list = isset($GLOBALS) ? array_keys($GLOBALS) : array(); $var_diff = array_diff($curr_var_list, $var_list[$type]); $debug_str .= ' Undeleted vars : ' . count($var_diff) . ' ['; print_r(implode(', ', $var_diff)); $debug_str .= ']' . OBR; } if (defined('USE_COUNTER_PROF')) { if (isset($perf_counter[$type])) { ksort($perf_counter[$type]); foreach ($perf_counter[$type] as $name => $value) { $debug_str .= 'Counter "' . $name . '" : ' . $value . OBR; } } } if (defined('USE_SQLREQUEST_PROF')) { if (defined('SHOW_SQLREQUEST_DETAILS')) { $requests_cnt = count($sqlrequests); $debug_str .= 'SQL selects count: ' . $DB['SELECT_COUNT'] . OBR; $debug_str .= 'SQL executes count: ' . $DB['EXECUTE_COUNT'] . OBR; $debug_str .= 'SQL requests count: ' . ($requests_cnt - $sqlmark[$type]) . OBR; $sql_time = 0; for ($i = $sqlmark[$type]; $i < $requests_cnt; $i++) { $time = $sqlrequests[$i][0]; $sql_time += $time; if ($time < LONG_QUERY) { $debug_str .= 'Time:' . round($time, 8) . ' SQL: ' . $sqlrequests[$i][1] . OBR; } else { $debug_str .= '<b>Time:' . round($time, 8) . ' LONG SQL: ' . $sqlrequests[$i][1] . '</b>' . OBR; } } } else { $debug_str .= 'SQL requests count: ' . ($sqlrequests - $sqlmark[$type]) . OBR; } if ($sql_time < QUERY_TOTAL_TIME) { $debug_str .= 'Total time spent on SQL: ' . round($sql_time, 8) . OBR; } else { $debug_str .= '<b>Total time spent on SQL: ' . round($sql_time, 8) . '</b>' . OBR; } } $debug_str .= "******************** End of {$type} ***************************" . OBR; // DEBUG of ZBX FrontEnd $zbx_debug = new CWidget('debug_hat', new CSpan(new CScript($debug_str), 'textcolorstyles')); $zbx_debug->addHeader(S_DEBUG); $debud = new CDiv(array(BR(), $zbx_debug)); $debud->setAttribute('id', 'zbx_gebug_info'); $debud->setAttribute('style', 'display: none;'); $debud->show(); //---------------- }