function hmib_summary() { global $device_actions, $item_rows, $config; /* ================= input validation ================= */ get_filter_request_var('htop'); get_filter_request_var('ptop'); /* ==================================================== */ /* clean up sort string */ if (isset_request_var('sort_column')) { set_request_var('sort_column', sanitize_search_string(get_nfilter_request_var('sort_column'))); } /* clean up sort string */ if (isset_request_var('sort_direction')) { set_request_var('sort_direction', sanitize_search_string(get_nfilter_request_var('sort_direction'))); } /* clean up search string */ if (isset_request_var('filter')) { set_request_var('filter', sanitize_search_string(get_nfilter_request_var('filter'))); } /* remember these search fields in session vars so we don't have * to keep passing them around */ if (isset_request_var('area') && get_nfilter_request_var('area') == 'processes') { if (isset_request_var('clear')) { kill_session_var('sess_hmib_proc_top'); kill_session_var('sess_hmib_proc_filter'); kill_session_var('sess_hmib_proc_sort_column'); kill_session_var('sess_hmib_proc_sort_direction'); unset_request_var('filter'); unset_request_var('ptop'); unset_request_var('sort_column'); unset_request_var('sort_direction'); } if (isset_request_var('sort_column')) { $_SESSION['sess_hmib_proc_sort_column'] = get_request_var('sort_column'); $_SESSION['sess_hmib_proc_sort_direction'] = get_request_var('sort_direction'); } elseif (!isset($_SESSION['sess_hmib_proc_sort_column'])) { $_SESSION['sess_hmib_proc_sort_column'] = 'maxCpu'; $_SESSION['sess_hmib_proc_sort_direction'] = 'DESC'; } if (!isset($_SESSION['sess_hmib_host_sort_column'])) { $_SESSION['sess_hmib_host_sort_column'] = 'downHosts'; $_SESSION['sess_hmib_host_sort_direction'] = 'DESC'; } } elseif (isset_request_var('area') && get_nfilter_request_var('area') == 'hosts') { if (isset_request_var('clear')) { kill_session_var('sess_hmib_host_top'); kill_session_var('sess_hmib_host_sort_column'); kill_session_var('sess_hmib_host_sort_direction'); unset_request_var('htop'); unset_request_var('sort_column'); unset_request_var('sort_direction'); } if (isset_request_var('sort_column')) { $_SESSION['sess_hmib_host_sort_column'] = get_request_var('sort_column'); $_SESSION['sess_hmib_host_sort_direction'] = get_request_var('sort_direction'); } elseif (!isset($_SESSION['sess_hmib_host_sort_column'])) { $_SESSION['sess_hmib_host_sort_column'] = 'downHosts'; $_SESSION['sess_hmib_host_sort_direction'] = 'DESC'; } if (!isset($_SESSION['sess_hmib_proc_sort_column'])) { $_SESSION['sess_hmib_proc_sort_column'] = 'maxCpu'; $_SESSION['sess_hmib_proc_sort_direction'] = 'DESC'; } } else { if (!isset($_SESSION['sess_hmib_host_sort_column'])) { $_SESSION['sess_hmib_host_sort_column'] = 'downHosts'; $_SESSION['sess_hmib_host_sort_direction'] = 'DESC'; } if (!isset($_SESSION['sess_hmib_proc_sort_column'])) { $_SESSION['sess_hmib_proc_sort_column'] = 'maxCpu'; $_SESSION['sess_hmib_proc_sort_direction'] = 'DESC'; } } load_current_session_value('ptop', 'sess_hmib_proc_top', read_config_option('hmib_top_processes')); load_current_session_value('htop', 'sess_hmib_host_top', read_config_option('hmib_top_types')); load_current_session_value('filter', 'sess_hmib_proc_filter', ''); /* set some defaults */ $url = $config['url_path'] . 'plugins/hmib/hmib.php'; $proc = $config['url_path'] . 'plugins/hmib/images/cog.png'; $host = $config['url_path'] . 'plugins/hmib/images/server.png'; $hardw = $config['url_path'] . 'plugins/hmib/images/view_hardware.gif'; $inven = $config['url_path'] . 'plugins/hmib/images/view_inventory.gif'; $storage = $config['url_path'] . 'plugins/hmib/images/drive.png'; $htdq = db_fetch_cell("SELECT id \n\t\tFROM snmp_query\n\t\tWHERE hash='137aeab842986a76cf5bdef41b96c9a3'"); $hcpudq = db_fetch_cell("SELECT id \n\t\tFROM snmp_query\n\t\tWHERE hash='0d1ab53fe37487a5d0b9e1d3ee8c1d0d'"); $hugt = db_fetch_cell("SELECT id \n\t\tFROM graph_templates \n\t\tWHERE hash='e8462bbe094e4e9e814d4e681671ea82'"); $hpgt = db_fetch_cell("SELECT id \n\t\tFROM graph_templates \n\t\tWHERE hash='62205afbd4066e5c4700338841e3901e'"); $htsd = db_fetch_cell("SELECT id\n\t\tFROM host_template\n\t\tWHERE hash='7c13344910097cc599f0d0485305361d'"); if ($htdq == 0 || $hcpudq == 0 || $hugt == 0 || $hpgt == 0 || $htsd == 0) { $templates_missing = true; } else { $templates_missing = false; } ?> <script type='text/javascript'> function applyFilter(objForm) { strURL = '?action=summary&area=hosts&header=false'; strURL += '&htop=' + $('#htop').val(); loadPageNoHeader(strURL); } function clearFilter() { strURL = '?area=hosts&clear=true&header=false'; loadPageNoHeader(strURL); } </script> <?php html_start_box(__('Summary Filter'), '100%', '', '3', 'center', ''); ?> <tr class='even'> <td> <form name='host_summary'> <table class='filterTable'> <tr> <td> <?php print __('Top'); ?> </td> <td> <select id='htop' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('htop') == '-1') { ?> selected<?php } ?> ><?php print __('All Records'); ?> </option> <option value='5'<?php if (get_request_var('htop') == '5') { ?> selected<?php } ?> ><?php print __('%d Records', 5); ?> </option> <option value='10'<?php if (get_request_var('htop') == '10') { ?> selected<?php } ?> ><?php print __('%d Record', 10); ?> s</option> <option value='15'<?php if (get_request_var('htop') == '15') { ?> selected<?php } ?> ><?php print __('%d Record', 15); ?> s</option> <option value='20'<?php if (get_request_var('htop') == '20') { ?> selected<?php } ?> ><?php print __('%d Record', 20); ?> s</option> </select> </td> <td> <input type='button' onClick='applyFilter()' value='<?php print __('Go'); ?> '> </td> <td> <input type='button' onClick='clearFilter()' value='<?php print __('Clear'); ?> ' name='clear'> </td> <td> <?php print $templates_missing ? '<strong>' . __('WARNING: You need to import your Host MIB Host Template to view Graphs. See the README for more information.') . '</strong>' : ''; ?> </td> </tr> </table> </form> </td> </tr> <?php html_end_box(false); html_start_box(__('Device Type Summary Statistics'), '100%', '', '3', 'center', ''); if (!isset($_SESSION['sess_hmib_host_top'])) { $limit = 'LIMIT ' . read_config_option('hmib_top_types'); } elseif ($_SESSION['sess_hmib_host_top'] == '-1') { $limit = ''; } else { $limit = 'LIMIT ' . $_SESSION['sess_hmib_host_top']; } $sql = 'SELECT hrst.id AS id, hrst.name AS name, hrst.version AS version, hrs.host_type AS host_type, SUM(CASE WHEN host_status=3 THEN 1 ELSE 0 END) AS upHosts, SUM(CASE WHEN host_status=2 THEN 1 ELSE 0 END) AS recHosts, SUM(CASE WHEN host_status=1 THEN 1 ELSE 0 END) AS downHosts, SUM(CASE WHEN host_status=0 THEN 1 ELSE 0 END) AS disabledHosts, SUM(users) AS users, SUM(numCpus) AS cpus, AVG(memUsed) AS avgMem, MAX(memUsed) AS maxMem, AVG(swapUsed) AS avgSwap, MAX(swapUsed) AS maxSwap, AVG(cpuPercent) AS avgCpuPercent, MAX(cpuPercent) AS maxCpuPercent, AVG(processes) AS avgProcesses, MAX(processes) AS maxProcesses FROM plugin_hmib_hrSystem AS hrs LEFT JOIN plugin_hmib_hrSystemTypes AS hrst ON hrs.host_type=hrst.id GROUP BY name, version ORDER BY ' . $_SESSION['sess_hmib_host_sort_column'] . ' ' . $_SESSION['sess_hmib_host_sort_direction'] . ' ' . $limit; $rows = db_fetch_assoc($sql); $display_text = array('nosort' => array('display' => __('Actions'), 'sort' => 'ASC', 'align' => 'left'), 'name' => array('display' => __('Type'), 'sort' => 'ASC', 'align' => 'left'), '(version/1)' => array('display' => __('Version'), 'sort' => 'ASC', 'align' => 'right'), 'upHosts' => array('display' => __('Up'), 'sort' => 'DESC', 'align' => 'right'), 'recHosts' => array('display' => __('Recovering'), 'sort' => 'DESC', 'align' => 'right'), 'downHosts' => array('display' => __('Down'), 'sort' => 'DESC', 'align' => 'right'), 'disabledHosts' => array('display' => __('Disabled'), 'sort' => 'DESC', 'align' => 'right'), 'users' => array('display' => __('Logins'), 'sort' => 'DESC', 'align' => 'right'), 'cpus' => array('display' => __('CPUS'), 'sort' => 'DESC', 'align' => 'right'), 'avgCpuPercent' => array('display' => __('Avg CPU'), 'sort' => 'DESC', 'align' => 'right'), 'maxCpuPercent' => array('display' => __('Max CPU'), 'sort' => 'DESC', 'align' => 'right'), 'avgMem' => array('display' => __('Avg Mem'), 'sort' => 'DESC', 'align' => 'right'), 'maxMem' => array('display' => __('Max Mem'), 'sort' => 'DESC', 'align' => 'right'), 'avgSwap' => array('display' => __('Avg Swap'), 'sort' => 'DESC', 'align' => 'right'), 'maxSwap' => array('display' => __('Max Swap'), 'sort' => 'DESC', 'align' => 'right'), 'avgProcesses' => array('display' => __('Avg Proc'), 'sort' => 'DESC', 'align' => 'right'), 'maxProcesses' => array('display' => __('Max Proc'), 'sort' => 'DESC', 'align' => 'right')); html_header_sort($display_text, $_SESSION['sess_hmib_host_sort_column'], $_SESSION['sess_hmib_host_sort_direction'], false, 'hmib.php?action=summary&area=hosts'); if (sizeof($rows)) { foreach ($rows as $row) { if (!$templates_missing) { $host_id = db_fetch_cell("SELECT id FROM host WHERE host_template_id={$htsd}"); $graph_url = hmib_get_graph_url($htdq, 0, $host_id, $row['id']); $graph_ncpu = hmib_get_graph_url($hcpudq, $row['id'], 0, '', $row['cpus'], false); $graph_acpu = hmib_get_graph_url($hcpudq, $row['id'], 0, '', round($row['avgCpuPercent'], 2), false); $graph_mcpu = hmib_get_graph_url($hcpudq, $row['id'], 0, '', round($row['maxCpuPercent'], 2), false); $graph_users = hmib_get_graph_template_url($hugt, $row['id'], 0, $row['users'], false); $graph_aproc = hmib_get_graph_template_url($hpgt, $row['id'], 0, number_format_i18n($row['avgProcesses'], 0), false); $graph_mproc = hmib_get_graph_template_url($hpgt, $row['id'], 0, number_format_i18n($row['maxProcesses'], 0), false); } else { $graph_url = ''; $graph_ncpu = ''; $graph_acpu = ''; $graph_mcpu = ''; $graph_users = ''; $graph_aproc = ''; $graph_mproc = ''; } form_alternate_row(); echo "<td style='white-space:nowrap;' width='120'>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=devices&type=" . $row['id']) . "'><img src='{$host}' title='" . __('View Devices') . "' align='absmiddle' alt=''></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=storage&ostype=" . $row['id']) . "'><img src='{$storage}' title='" . __('View Storage') . "' align='absmiddle' alt=''></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=hardware&ostype=" . $row['id']) . "'><img src='{$hardw}' title='" . __('View Hardware') . "' align='absmiddle' alt=''></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=running&type=" . $row['id']) . "'><img src='{$proc}' title='" . __('View Processes') . "' align='absmiddle' alt=''></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=software&ostype=" . $row['id']) . "'><img src='{$inven}' title='" . __('View Software Inventory') . "' align='absmiddle' alt=''></a>"; echo $graph_url; echo '</td>'; $upHosts = hmib_get_device_status_url($row['upHosts'], $row['host_type'], 3); $recHosts = hmib_get_device_status_url($row['recHosts'], $row['host_type'], 2); $downHosts = hmib_get_device_status_url($row['downHosts'], $row['host_type'], 1); $disaHosts = hmib_get_device_status_url($row['disabledHosts'], $row['host_type'], 0); echo "<td class='nowrap left'>" . ($row['name'] != '' ? $row['name'] : 'Unknown') . '</td>'; echo "<td class='nowrap right'>" . $row['version'] . '</td>'; echo "<td class='nowrap right'>" . $upHosts . '</td>'; echo "<td class='nowrap right'>" . $recHosts . '</td>'; echo "<td class='nowrap right'>" . $downHosts . '</td>'; echo "<td class='nowrap right'>" . $disaHosts . '</td>'; echo "<td class='nowrap right'>" . $graph_users . '</td>'; echo "<td class='nowrap right'>" . $graph_ncpu . '</td>'; echo "<td class='nowrap right'>" . $graph_acpu . ' %</td>'; echo "<td class='nowrap right'>" . $graph_mcpu . ' %</td>'; echo "<td class='nowrap right'>" . round($row['avgMem'], 2) . ' %</td>'; echo "<td class='nowrap right'>" . round($row['maxMem'], 2) . ' %</td>'; echo "<td class='nowrap right'>" . round($row['avgSwap'], 2) . ' %</td>'; echo "<td class='nowrap right'>" . round($row['maxSwap'], 2) . ' %</td>'; echo "<td class='nowrap right'>" . $graph_aproc . '</td>'; echo "<td class='nowrap right'>" . $graph_mproc . '</td>'; } echo '</tr>'; } else { print '<tr><td colspan="8"><em>' . __('No Device Types') . '</em></td></tr>'; } html_end_box(); html_start_box(__('Process Summary Filter'), '100%', '', '3', 'center', ''); ?> <script type='text/javascript'> function applyProcFilter(objForm) { strURL = '?action=summary&area=processes'; strURL += '&filter=' + $('#filter').val(); strURL += '&ptop=' + $('#ptop').val(); strURL += '&header=false'; loadPageNoHeader(strURL); } function clearProc() { strURL = '?action=summary&area=processes&clear=true&header=false'; loadPageNoHeader(strURL); } $(function() { $('#proc_summary').submit(function(event) { event.preventDefault(); applyProcFilter(); }); }); </script> <?php ?> <tr class='even'> <td> <form id='proc_summary'> <table class='filterTable'> <tr> <td style='width:55px;'> <?php print __('Search'); ?> </td> <td> <input type='textbox' size='25' id='filter' value='<?php print get_request_var('filter'); ?> '> </td> <td> <?php print __('Top'); ?> </td> <td> <select id='ptop' onChange='applyProcFilter()'> <option value='-1'<?php if (get_request_var('ptop') == '-1') { ?> selected<?php } ?> ><?php print __('All Records'); ?> </option> <option value='5'<?php if (get_request_var('ptop') == '5') { ?> selected<?php } ?> ><?php print __('%d Records', 5); ?> </option> <option value='10'<?php if (get_request_var('ptop') == '10') { ?> selected<?php } ?> ><?php print __('%d Records', 10); ?> </option> <option value='15'<?php if (get_request_var('ptop') == '15') { ?> selected<?php } ?> ><?php print __('%d Records', 15); ?> </option> <option value='20'<?php if (get_request_var('ptop') == '20') { ?> selected<?php } ?> ><?php print __('%d Records', 20); ?> </option> </select> </td> <td> <input type='button' onClick='applyProcFilter(document.proc_summary)' value='<?php print __('Go'); ?> '> </td> <td> <input type='button' onClick='clearProc()' value='<?php print __('Clear'); ?> '> </td> <td> <?php print $templates_missing ? '<strong>' . __('WARNING: You need to import your Host MIB Host Template to view Graphs. See the README for more information.') . '</strong>' : ''; ?> </td> </tr> </table> </form> </td> </tr> <?php html_end_box(false); html_start_box(__('Process Summary Statistics'), '100%', '', '3', 'center', ''); if (!isset($_SESSION['sess_hmib_proc_top'])) { $limit = 'LIMIT ' . read_config_option('hmib_top_processes'); } elseif ($_SESSION['sess_hmib_proc_top'] == '-1') { $limit = ''; } else { $limit = 'LIMIT ' . $_SESSION['sess_hmib_proc_top']; } if (strlen(get_request_var('filter'))) { $sql_where = "AND (hrswr.name LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thrswr.path LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thrswr.parameters LIKE '%" . get_request_var('filter') . "%')"; } else { $sql_where = ''; } $sql = "SELECT\n\t\thrswr.name AS name,\n\t\tCOUNT(DISTINCT hrswr.path) AS paths,\n\t\tCOUNT(DISTINCT hrswr.host_id) AS numHosts,\n\t\tCOUNT(hrswr.host_id) AS numProcesses,\n\t\tAVG(hrswr.perfCPU) AS avgCpu,\n\t\tMAX(hrswr.perfCPU) AS maxCpu,\n\t\tAVG(hrswr.perfMemory) AS avgMemory,\n\t\tMAX(hrswr.perfMemory) AS maxMemory\n\t\tFROM plugin_hmib_hrSWRun AS hrswr\n\t\tWHERE hrswr.name!='System Idle Process' AND hrswr.name!=''\n\t\t{$sql_where}\n\t\tGROUP BY hrswr.name\n\t\tORDER BY " . $_SESSION['sess_hmib_proc_sort_column'] . ' ' . $_SESSION['sess_hmib_proc_sort_direction'] . ' ' . $limit; $rows = db_fetch_assoc($sql); //echo $sql; $display_text = array('nosort' => array('display' => __('Actions'), 'sort' => 'ASC', 'align' => 'left'), 'name' => array('display' => __('Process Name'), 'sort' => 'ASC', 'align' => 'left'), 'paths' => array('display' => __('Num Paths'), 'sort' => 'DESC', 'align' => 'right'), 'numHosts' => array('display' => __('Hosts'), 'sort' => 'DESC', 'align' => 'right'), 'numProcesses' => array('display' => __('Processes'), 'sort' => 'DESC', 'align' => 'right'), 'avgCpu' => array('display' => __('Avg CPU'), 'sort' => 'DESC', 'align' => 'right'), 'maxCpu' => array('display' => __('Max CPU'), 'sort' => 'DESC', 'align' => 'right'), 'avgMemory' => array('display' => __('Avg Memory'), 'sort' => 'DESC', 'align' => 'right'), 'maxMemory' => array('display' => __('Max Memory'), 'sort' => 'DESC', 'align' => 'right')); html_header_sort($display_text, $_SESSION['sess_hmib_proc_sort_column'], $_SESSION['sess_hmib_proc_sort_direction'], false, 'hmib.php?action=summary&area=processes'); /* set some defaults */ $url = $config['url_path'] . 'plugins/hmib/hmib.php'; $proc = $config['url_path'] . 'plugins/hmib/images/cog.png'; $host = $config['url_path'] . 'plugins/hmib/images/server.png'; /* get the data query for the application use */ $adq = db_fetch_cell("SELECT id\n\t\tFROM snmp_query\n\t\tWHERE hash='6b0ef0fe7f1d85bbb6812801ca15a7c5'"); if (sizeof($rows)) { foreach ($rows as $row) { $graph_url = hmib_get_graph_url($adq, 0, 0, $row['name']); form_alternate_row(); echo "<td width='70'>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=devices&process=" . $row['name']) . "'><img src='{$host}' title='" . __('View Devices') . "' align='absmiddle' alt=''></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=running&process=" . $row['name']) . "'><img src='{$proc}' title='" . __('View Processes') . "' align='absmiddle' alt=''></a>"; echo $graph_url; echo '</td>'; echo "<td class='left' width='140'>" . $row['name'] . '</td>'; echo "<td class='right'>" . $row['paths'] . '</td>'; echo "<td class='right'>" . $row['numHosts'] . '</td>'; echo "<td class='right'>" . $row['numProcesses'] . '</td>'; echo "<td class='right'>" . number_format_i18n($row['avgCpu'] / 3600, 0) . ' Hrs</td>'; echo "<td class='right'>" . number_format_i18n($row['maxCpu'] / 3600, 0) . ' Hrs</td>'; echo "<td class='right'>" . number_format_i18n($row['avgMemory'] / 1024, 2) . ' MB</td>'; echo "<td class='right'>" . number_format_i18n($row['maxMemory'] / 1024, 2) . ' MB</td>'; } echo '</tr>'; } else { print '<tr><td><em>' . __('No Processes') . '</em></td></tr>'; } html_end_box(); }
function flowview_display_report() { global $config, $colors; general_header(); if (isset_request_var('tab') && strlen(get_nfilter_request_var('tab')) > 10) { $flowdata = unserialize(base64_decode(get_nfilter_request_var('tab'))); $sessionid = get_nfilter_request_var('tab'); foreach ($flowdata['post'] as $item => $value) { switch ($item) { case 'bytes': case 'flows': case 'packets': break; case 'exclude': if (isset_request_var('exclude')) { get_filter_request_var('exclude'); break; } else { set_request_var($item, $value); break; } default: set_request_var($item, $value); break; } } set_request_var('action', 'view'); } else { $sessionid = ''; } include $config['base_path'] . '/plugins/flowview/variables.php'; include $config['base_path'] . '/plugins/flowview/arrays.php'; $rname = ''; if ($stat_report > 0) { $rname = $stat_report_array[$stat_report]; } if ($print_report > 0) { $rname = $print_report_array[$print_report]; } $current = ''; $error = flowview_check_fields(); if ($error != '') { display_tabs(); print "<font class='textError'>{$error}</font>"; html_end_box(); return; } /* if the user pushed the 'clear' button */ if (isset_request_var('clear')) { kill_session_var('sess_flows_exclude'); kill_session_var('sess_flows_table'); kill_session_var('sess_flows_bytes'); kill_session_var('sess_flows_packets'); kill_session_var('sess_flows_flows'); unset_request_var('exclude'); unset_request_var('table'); unset_request_var('bytes'); unset_request_var('packets'); unset_request_var('flows'); } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value('exclude', 'sess_flows_exclude', '0'); load_current_session_value('table', 'sess_flows_table', 'on'); load_current_session_value('bytes', 'sess_flows_bytes', ''); load_current_session_value('packets', 'sess_flows_packets', ''); load_current_session_value('flows', 'sess_flows_flows', ''); $filter = createfilter($sessionid); display_tabs(); if (isset_request_var('stat_report') && get_nfilter_request_var('stat_report') != 99) { html_start_box("Report: {$rname}", '100%', '', '3', 'center', ''); ?> <tr class='even'> <td> <form id='view' name='view' action='flowview.php' method='post'> <table class='filterTable'> <tr> <td> Exclude </td> <td> <select name='exclude' id='exclude'> <option value='0'<?php echo get_request_var('exclude') == 0 ? ' selected' : ''; ?> >None</option> <option value='1'<?php echo get_request_var('exclude') == 1 ? ' selected' : ''; ?> >Top Sample</option> <option value='2'<?php echo get_request_var('exclude') == 2 ? ' selected' : ''; ?> >Top 2 Samples</option> <option value='3'<?php echo get_request_var('exclude') == 3 ? ' selected' : ''; ?> >Top 3 Samples</option> <option value='4'<?php echo get_request_var('exclude') == 4 ? ' selected' : ''; ?> >Top 4 Samples</option> <option value='5'<?php echo get_request_var('exclude') == 5 ? ' selected' : ''; ?> >Top 5 Samples</option> </select> </td> <td> Show/Hide </td> <td> <input type='checkbox' name='table' id='table' <?php print get_request_var('table') == 'true' || get_request_var('table') == 'on' ? 'checked' : ''; ?> > </td> <td> <label for='table'>Table</label> </td> <td> <input type='checkbox' name='bytes' id='bytes' <?php print get_request_var('bytes') == 'true' || get_request_var('bytes') == 'on' ? 'checked' : ''; ?> > </td> <td> <label for='bytes'>Bytes Bar</label> </td> <td> <input type='checkbox' name='packets' id='packets' <?php print get_request_var('packets') == 'true' || get_request_var('packets') == 'on' ? 'checked' : ''; ?> > </td> <td> <label for='packets'>Packets Bar</label> </td> <td> <input type='checkbox' name='flows' id='flows' <?php print get_request_var('flows') == 'true' || get_request_var('flows') == 'on' ? 'checked' : ''; ?> > </td> <td> <label for='flows'>Flows Bar</label> </td> <td> <input type='button' id='clear' value='Clear' title='Clear Filters'> </td> </tr> </table> <input type='hidden' name='page' value='1'> <input type='hidden' name='tab' id='tab' value='<?php print $sessionid; ?> '> </form> </td> </tr> <?php html_end_box(); flowview_draw_chart('bytes', $rname); flowview_draw_chart('packets', $rname); flowview_draw_chart('flows', $rname); } elseif (isset_request_var('print_report') && get_nfilter_request_var('print_report') > 0) { html_start_box("Report: {$rname}", '100%', '', '3', 'center', ''); } echo "<div id='flowcontent'>"; echo $filter; html_end_box(); echo "</div>"; ?> <script type='text/javascript'> swfobject.embedSWF('open-flash-chart.swf', 'chartbytes', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . get_request_var('exclude') . "&type=bytes&title={$rname}"); ?> ', 'id':'chartbytes'}); swfobject.embedSWF('open-flash-chart.swf', 'chartpackets', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . get_request_var('exclude') . "&type=packets&title={$rname}"); ?> ', 'id':'chartpackets'}); swfobject.embedSWF('open-flash-chart.swf', 'chartflows', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . get_request_var('exclude') . "&type=flows&title={$rname}"); ?> ', 'id':'chartflows'}); $('#bytes').click(function() { if (!$('#bytes').is(':checked')) { $('#wrapperbytes').hide(); $.get('flowview.php?action=updatesess&type=bytes&value='); }else{ $('#wrapperbytes').show(); } }); $('#packets').click(function() { if (!$('#packets').is(':checked')) { $('#wrapperpackets').hide(); $.get('flowview.php?action=updatesess&type=packets&value='); }else{ $('#wrapperpackets').show(); } }); $('#flows').click(function() { if (!$('#flows').is(':checked')) { $('#wrapperflows').hide(); $.get('flowview.php?action=updatesess&type=flows&value='); }else{ $('#wrapperflows').show(); } }); $('#table').click(function() { if (!$('#table').is(':checked')) { $('#flowcontent').hide(); $.get('flowview.php?action=updatesess&type=table&value='); }else{ $.get('flowview.php?action=updatesess&type=table&value=on'); $('#flowcontent').show(); } }); $('#clear').click(function() { loadPageNoHeader('flowview.php?header=false&action=view&clear=true&tab='+$('#tab').val()); }); $('#exclude').change(function() { loadPageNoHeader('flowview.php?header=false&action=view&exclude='+$('#exclude').val()+'&tab='+$('#tab').val()); }); if ($('#table').is(':checked') || <?php print isset_request_var('stat_report') ? get_nfilter_request_var('stat_report') == 99 ? 'true' : 'false' : 'true'; ?> ) { $('#flowcontent').show(); }else{ $('#flowcontent').hide(); } if ($('#bytes').is(':checked')) { $('#wrapperbytes').show(); } if ($('#packets').is(':checked')) { $('#wrapperpackets').show(); } if ($('#flows').is(':checked')) { $('#wrapperflows').show(); } $.tablesorter.addParser({ id: 'bytes', is: function(s) { return false; }, format: function(s) { if (s.indexOf('MB') > 0) { loc=s.indexOf('MB'); return s.substring(0,loc) * 1024 * 1024; }else if (s.indexOf('KB') > 0) { loc=s.indexOf('KB'); return s.substring(0,loc) * 1024; }else if (s.indexOf('Bytes') > 0) { loc=s.indexOf('Bytes'); return s.substring(0,loc); }else if (s.indexOf('GB') > 0) { loc=s.indexOf('GB'); return s.substring(0,loc) * 1024 * 1024 * 1024; }else if (s.indexOf('TB') > 0) { loc=s.indexOf('TB'); return s.substring(0,loc) * 1024 * 1024 * 1024 * 1024; }else{ return s; } }, type: 'numeric' }); $(function() { $('#sorttable').tablesorter({ widgets: ['zebra'], widgetZebra: { css: ['even', 'odd'] }, headerTemplate: '<div class="textSubHeaderDark">{content} {icon}</div>', cssIconAsc: 'fa-sort-asc', cssIconDesc: 'fa-sort-desc', cssIconNone: 'fa-sort', cssIcon: 'fa' }); $('#sorttable').resizable(); }); </script> <?php bottom_footer(); }
/** function syslog_request_validation() * This is a generic funtion for this page that makes sure that * we have a good request. We want to protect against people who * like to create issues with Cacti. */ function syslog_request_validation($current_tab, $force = false) { global $title, $rows, $config, $reset_multi; include_once './lib/timespan_settings.php'; if ($current_tab != 'alerts' && isset_request_var('host') && get_nfilter_request_var('host') == -1) { kill_session_var('sess_syslog_' . $current_tab . '_hosts'); unset_request_var('host'); } /* ================= input validation and session storage ================= */ $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => read_user_setting('syslog_rows', '-1', $force)), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'id' => array('filter' => FILTER_VALIDATE_INT, 'default' => ''), 'removal' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('syslog_removal', '1', $force)), 'refresh' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('syslog_refresh', read_config_option('syslog_refresh'), $force)), 'trimval' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('syslog_trimval', '75', $force)), 'enabled' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'host' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '0', 'options' => array('options' => 'sanitize_search_string')), 'efacility' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('syslog_efacility', '-1', $force), 'options' => array('options' => 'sanitize_search_string')), 'epriority' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('syslog_epriority', '-1', $force), 'options' => array('options' => 'sanitize_search_string')), 'eprogram' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('syslog_eprogram', '-1', $force), 'options' => array('options' => 'sanitize_search_string')), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'logtime', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'DESC', 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_syslogs_' . $current_tab); /* ================= input validation ================= */ api_plugin_hook_function('syslog_request_val'); if (isset_request_var('host')) { $_SESSION['sess_syslog_' . $current_tab . '_hosts'] = get_nfilter_request_var('host'); } else { if (isset($_SESSION['sess_syslog_' . $current_tab . '_hosts'])) { set_request_var('host', $_SESSION['sess_syslog_' . $current_tab . '_hosts']); } else { set_request_var('host', '-1'); } } }