function td($str, $extra = '') { u::td($str, $extra); }
function html_results($cur, $fmt = 1, $link_col = 0, $link = '', $show_no_rows = 1) { if ($fmt) { u::p('<style>table td {white-space: nowrap;border: 1px solid silver;font-family:Courier New}</style>'); u::p('<table>'); } else { u::p('<pre>'); } $print_header = 1; $rows_fetched = 0; while ($rec = oci_fetch_object($cur)) { $rows_fetched++; if ($fmt) { u::p('<tr>'); } # # Display column headers # if ($print_header) { if ($fmt) { u::p('<tr>'); } foreach ($rec as $key => $val) { if ($fmt) { u::th($key, 'style="background-color:silver;color:white"'); } else { u::p($key); } } if ($fmt) { u::p('</tr>'); } $print_header = 0; } # # Row data # if ($fmt) { u::p('<tr>'); } $col = 0; foreach ($rec as $key => $val) { $col++; if ($col === $link_col) { $val = u::a($val, str_replace('__VAL__', $val, $link), 1); } if ($fmt) { # # Extra formatting? # if ($val == 'CRITICAL') { $extra = 'style="background-color:red;"'; } else { $extra = ''; } u::td($val, $extra); } else { u::p($val); } } if ($fmt) { u::p('</tr>'); } } oci_free_statement($cur); if (!$rows_fetched and $fmt and $show_no_rows) { u::trtd('No Rows Returned', 'style="background-color:red;"'); } if ($fmt) { u::p('</table>'); } else { u::p('</pre>'); } }
u::start_tag('table', 'id="data1"'); u::tr('<th>sql_id</th><th>% of ' . $sql_mins_hist . ' mins busy</th><th>Execs</th><th>Avg Disk Reads</th><th>Avg Secs</th><th>SQL Text</th>', '', 1); $i = 0; while ($rec = oci_fetch_object($cur)) { # # Row formatting # $class_str = u::odd_even_class_str($i++); u::start_tag('tr', $class_str); $highlight_graph_str = "onmouseover=\"highlight('{$rec->SQL_ID}');\" "; $sql_cell = "<div {$highlight_graph_str}>" . sql_details_link($rec->SQL_ID, $db) . "</div>"; u::td($sql_cell, '', 1); # # Barchart # $values = array($rec->PERCENT_ON_CPU, $rec->PERCENT_USER_IO, $rec->PERCENT_SYSTEM_IO, $rec->PERCENT_BLOCKED, $rec->PERCENT_OTHER); u::start_tag('td', 'style="padding:0px 0px 0px 0px"'); include 'bar_chart.php'; u::end_tag('td'); u::td($rec->EXECS, '', 1); u::td($rec->AVG_DISK_READS, '', 1); u::td($rec->AVG_SECS, '', 1); u::tagged_item('td', $rec->SQL_TEXT, 'style="border-right:0px;font-size:xx-small;font-family:Courier New;"', 1); u::end_tag('tr'); } # # Fill table up if needed # u::filler_rows($table_rows, $i, 6); u::end_tag('table'); u::end_tag('div');
u::start_tag('tr', $class_str); $sid_cell = "<div " . highlight_js_str($rec->SID) . ">" . drilldown_links($rec->SID, $db, '', $snaps_table) . "</div>"; u::td($sid_cell, '', 1); u::td($rec->USERNAME, '', 1); # # Covert seconds to % for plotting # $values = array($rec->SECONDS_ON_CPU, $rec->SECONDS_USER_IO, $rec->SECONDS_SYSTEM_IO, $rec->SECONDS_BLOCKED, $rec->SECONDS_OTHER); foreach ($values as $key => $value) { $values[$key] = round($value * 100 / ($mins_hist * 60)); } u::start_tag('td', 'style="padding:0;"'); # # Draw percentages as a bar chart # u::info('Draw Bar chart', 1); include 'bar_chart.php'; u::info('Draw Bar chart - Done', 1); u::end_tag('td'); $highlight_graph_str = "onmouseover=\"highlight('{$rec->CURRENT_BLOCKING_SESSION}');\" "; $sid_cell = "<div {$highlight_graph_str}>" . drilldown_links($rec->CURRENT_BLOCKING_SESSION, $db, '', $snaps_table) . "</div>"; u::td($sid_cell, '', 1); u::td("<div " . highlight_js_str($rec->CURRENT_SQL_ID) . ">" . sql_details_link($rec->CURRENT_SQL_ID, $db) . "</div>", '', 1); u::td("<div " . highlight_js_str($rec->PREV_SQL_ID) . ">" . sql_details_link($rec->PREV_SQL_ID, $db) . "</div>", '', 1); u::td($rec->CURRENT_PROGRAM, '', 1); u::td($rec->CURRENT_MACHINE, 'style="border-right:0px;"', 1); u::end_tag('tr'); } u::filler_rows($table_rows, $i, 8); u::end_tag('table'); u::end_tag('div');