function hmib_running() { global $config, $colors, $item_rows, $hmib_hrSWTypes, $hmib_hrSWRunStatus; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("template")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("rows")); input_validate_input_number(get_request_var_request("device")); input_validate_input_number(get_request_var_request("type")); /* ==================================================== */ /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up sort_direction */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* clean up filter string */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up filter string */ if (isset($_REQUEST["process"])) { $_REQUEST["process"] = sanitize_search_string(get_request_var("process")); } if (isset($_REQUEST["reset"])) { kill_session_var("sess_hmib_run_sort_column"); kill_session_var("sess_hmib_run_sort_direction"); kill_session_var("sess_hmib_run_template"); kill_session_var("sess_hmib_run_filter"); kill_session_var("sess_hmib_run_rows"); kill_session_var("sess_hmib_run_device"); kill_session_var("sess_hmib_run_process"); kill_session_var("sess_hmib_run_type"); kill_session_var("sess_hmib_run_current_page"); } elseif (isset($_REQUEST["clear"])) { kill_session_var("sess_hmib_run_sort_column"); kill_session_var("sess_hmib_run_sort_direction"); kill_session_var("sess_hmib_run_template"); kill_session_var("sess_hmib_run_filter"); kill_session_var("sess_hmib_run_rows"); kill_session_var("sess_hmib_run_device"); kill_session_var("sess_hmib_run_process"); kill_session_var("sess_hmib_run_type"); kill_session_var("sess_hmib_run_current_page"); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); unset($_REQUEST["template"]); unset($_REQUEST["filter"]); unset($_REQUEST["rows"]); unset($_REQUEST["device"]); unset($_REQUEST["process"]); unset($_REQUEST["type"]); unset($_REQUEST["page"]); } else { /* if any of the settings changed, reset the page number */ $changed = false; $changed += hmib_check_changed("template", "sess_hmib_run_template"); $changed += hmib_check_changed("fitler", "sess_hmib_run_filter"); $changed += hmib_check_changed("rows", "sess_hmib_run_rows"); $changed += hmib_check_changed("device", "sess_hmib_run_device"); $changed += hmib_check_changed("process", "sess_hmib_run_process"); if (hmib_check_changed("type", "sess_hmib_run_type")) { $_REQUEST["device"] = -1; $changed = true; } if ($changed) { $_REQUEST["page"] = "1"; } } load_current_session_value("page", "sess_hmib_run_current_page", "1"); load_current_session_value("rows", "sess_hmib_run_rows", "-1"); load_current_session_value("device", "sess_hmib_run_device", "-1"); load_current_session_value("process", "sess_hmib_run_process", "-1"); load_current_session_value("type", "sess_hmib_run_type", "-1"); load_current_session_value("sort_column", "sess_hmib_run_sort_column", "name"); load_current_session_value("sort_direction", "sess_hmib_run_sort_direction", "ASC"); load_current_session_value("template", "sess_hmib_run_template", "-1"); load_current_session_value("filter", "sess_hmib_run_filter", ""); ?> <script type="text/javascript"> <!-- function applyRunFilter(objForm) { strURL = '?action=running'; strURL = strURL + '&template=' + objForm.template.value; strURL = strURL + '&filter=' + objForm.filter.value; strURL = strURL + '&rows=' + objForm.rows.value; strURL = strURL + '&device=' + objForm.device.value; strURL = strURL + '&process=' + objForm.process.value; strURL = strURL + '&type=' + objForm.type.value; document.location = strURL; } function clearRun() { strURL = '?action=running&clear='; document.location = strURL; } --> </script> <?php html_start_box("<strong>Running Processes</strong>", "100%", $colors["header"], "3", "center", ""); ?> <tr bgcolor="#<?php print $colors["panel"]; ?> "> <td> <form name="running" method="get" action="hmib.php?action=running"> <table cellpadding="0" cellspacing="0"> <tr> <td nowrap style='white-space: nowrap;' width="60"> OS Type: </td> <td width="1"> <select name="type" onChange="applyRunFilter(document.running)"> <option value="-1"<?php if (get_request_var_request("type") == "-1") { ?> selected<?php } ?> >All</option> <?php $types = db_fetch_assoc("SELECT DISTINCT id, CONCAT_WS('', name, ' [', version, ']') AS name\n\t\t\t\t\t\t\t\tFROM plugin_hmib_hrSystemTypes AS hrst\n\t\t\t\t\t\t\t\tINNER JOIN plugin_hmib_hrSystem AS hrs\n\t\t\t\t\t\t\t\tON hrst.id=hrs.host_type\n\t\t\t\t\t\t\t\tWHERE name!='' ORDER BY name"); if (sizeof($types)) { foreach ($types as $t) { echo "<option value='" . $t["id"] . "' " . (get_request_var_request("type") == $t["id"] ? "selected" : "") . ">" . $t["name"] . "</option>"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="60"> Device: </td> <td width="1"> <select name="device" onChange="applyRunFilter(document.running)"> <option value="-1"<?php if (get_request_var_request("device") == "-1") { ?> selected<?php } ?> >All</option> <?php $hosts = db_fetch_assoc("SELECT DISTINCT host.id, host.description\n\t\t\t\t\t\t\t\tFROM plugin_hmib_hrSystem AS hrs\n\t\t\t\t\t\t\t\tINNER JOIN host\n\t\t\t\t\t\t\t\tON hrs.host_id=host.id " . (get_request_var_request("type") > 0 ? "WHERE hrs.host_type=" . get_request_var_request("type") : "") . " ORDER BY description"); if (sizeof($hosts)) { foreach ($hosts as $h) { echo "<option value='" . $h["id"] . "' " . (get_request_var_request("device") == $h["id"] ? "selected" : "") . ">" . $h["description"] . "</option>"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="60"> Template: </td> <td width="1"> <select name="template" onChange="applyRunFilter(document.running)"> <option value="-1"<?php if (get_request_var_request("template") == "-1") { ?> selected<?php } ?> >All</option> <?php $templates = db_fetch_assoc("SELECT DISTINCT ht.id, ht.name\n\t\t\t\t\t\t\t\tFROM host_template AS ht\n\t\t\t\t\t\t\t\tINNER JOIN host\n\t\t\t\t\t\t\t\tON ht.id=host.host_template_id\n\t\t\t\t\t\t\t\tINNER JOIN plugin_hmib_hrSystem AS hrs\n\t\t\t\t\t\t\t\tON host.id=hrs.host_id\n\t\t\t\t\t\t\t\tORDER BY name"); if (sizeof($templates)) { foreach ($templates as $t) { echo "<option value='" . $t["id"] . "' " . (get_request_var_request("template") == $t["id"] ? "selected" : "") . ">" . $t["name"] . "</option>"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="60"> Rows: </td> <td width="1"> <select name="rows" onChange="applyRunFilter(document.running)"> <option value="-1"<?php if (get_request_var_request("rows") == "-1") { ?> selected<?php } ?> >Default</option> <?php if (sizeof($item_rows)) { foreach ($item_rows as $key => $name) { echo "<option value='" . $key . "' " . (get_request_var_request("rows") == $key ? "selected" : "") . ">" . $name . "</option>"; } } ?> </select> </td> </tr> </table> <table cellpadding="0" cellspacing="0"> <tr> <td nowrap style='white-space: nowrap;' width="60"> Process: </td> <td width="1"> <select name="process" onChange="applyRunFilter(document.running)"> <option value="-1"<?php if (get_request_var_request("process") == "-1") { ?> selected<?php } ?> >All</option> <?php $procs = db_fetch_assoc("SELECT DISTINCT name\n\t\t\t\t\t\t\t\tFROM plugin_hmib_hrSWRun_last_seen AS hrswr\n\t\t\t\t\t\t\t\tWHERE name!='System Idle Time' AND name NOT LIKE '128%' AND (name IS NOT NULL AND name!='')\n\t\t\t\t\t\t\t\tORDER BY name"); if (sizeof($procs)) { foreach ($procs as $p) { echo "<option value='" . $p["name"] . "' " . (get_request_var_request("process") == $p["name"] ? "selected" : "") . ">" . $p["name"] . "</option>"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="60"> Search: </td> <td> <input type='text' size='40' name='filter' value='<?php print get_request_var_request("filter"); ?> '> </td> <td nowrap> <input type="button" onClick="applyRunFilter(document.running)" value="Go" border="0"> <input type="button" onClick="clearRun()" value="Clear" name="clear" border="0"> </td> </tr> </table> <input type='hidden' name='action' value='running'> </form> </td> </tr> <?php html_end_box(); html_start_box("", "100%", $colors["header"], "3", "center", ""); if ($_REQUEST["rows"] == "-1") { $num_rows = read_config_option("num_rows_device"); } else { $num_rows = get_request_var_request("rows"); } $limit = " LIMIT " . $num_rows * (get_request_var_request("page") - 1) . "," . $num_rows; $sql_where = "WHERE hrswr.name!='' AND hrswr.name!='System Idle Process'"; if ($_REQUEST["template"] != "-1") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " host.host_template_id=" . $_REQUEST["template"]; } if ($_REQUEST["device"] != "-1") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " host.id=" . $_REQUEST["device"]; } if ($_REQUEST["type"] != "-1") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " hrs.host_type=" . $_REQUEST["type"]; } if ($_REQUEST["process"] != "-1") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " hrswr.name='" . $_REQUEST["process"] . "'"; } if ($_REQUEST["filter"] != "") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " (host.description LIKE '%" . $_REQUEST["filter"] . "%' OR\n\t\t\thrswr.name LIKE '%" . $_REQUEST["filter"] . "%' OR\n\t\t\thost.hostname LIKE '%" . $_REQUEST["filter"] . "%')"; } $sql = "SELECT hrswr.*, host.hostname, host.description, host.disabled\n\t\tFROM plugin_hmib_hrSWRun AS hrswr\n\t\tINNER JOIN host\n\t\tON host.id=hrswr.host_id\n\t\tINNER JOIN plugin_hmib_hrSystem AS hrs\n\t\tON hrs.host_id=host.id\n\t\tINNER JOIN plugin_hmib_hrSystemTypes AS hrst\n\t\tON hrst.id=hrs.host_type\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . " " . $limit; //echo $sql; $rows = db_fetch_assoc($sql); $total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_hmib_hrSWRun AS hrswr\n\t\tINNER JOIN host\n\t\tON host.id=hrswr.host_id\n\t\tINNER JOIN plugin_hmib_hrSystem AS hrs\n\t\tON hrs.host_id=host.id\n\t\tINNER JOIN plugin_hmib_hrSystemTypes AS hrst\n\t\tON hrst.id=hrs.host_type\n\t\t{$sql_where}"); $totals = db_fetch_row("SELECT\t" . "ROUND(SUM(perfCPU),2) as cpu, " . "ROUND(SUM(perfMemory),2) as memory " . "FROM plugin_hmib_hrSWRun AS hrswr " . "INNER JOIN host ON host.id=hrswr.host_id " . "INNER JOIN plugin_hmib_hrSystem AS hrs ON hrs.host_id=host.id " . "INNER JOIN plugin_hmib_hrSystemTypes AS hrst ON hrst.id=hrs.host_type " . $sql_where); if ($total_rows > 0) { /* generate page list */ $url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, $num_rows, $total_rows, "hmib.php" . "?action=running"); $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='16'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong><< "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("hmib.php" . "?action=running&page=" . (get_request_var_request("page") - 1)) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tShowing Rows " . ($num_rows * (get_request_var_request("page") - 1) + 1) . " to " . ($total_rows < $num_rows || $total_rows < $num_rows * get_request_var_request("page") ? $total_rows : $num_rows * get_request_var_request("page")) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong>"; if (get_request_var_request("page") * $num_rows < $total_rows) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("hmib.php" . "?action=running&page=" . (get_request_var_request("page") + 1)) . "'>"; } $nav .= "Next"; if (get_request_var_request("page") * $num_rows < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n"; } else { $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='16'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tNo Rows Found\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n"; } print $nav; $display_text = array("description" => array("Name", array("ASC", "left")), "hrswr.name" => array("Process", array("DESC", "left")), "path" => array("Path", array("ASC", "left")), "parameters" => array("Parameters", array("ASC", "left")), "perfCpu" => array("CPU (Hrs)", array("DESC", "right")), "perfMemory" => array("Memory (MB)", array("DESC", "right")), "type" => array("Type", array("ASC", "left")), "status" => array("Status", array("DESC", "right"))); hmib_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), "action=running"); $i = 0; if (sizeof($rows)) { foreach ($rows as $row) { form_alternate_row_color($colors["alternate"], $colors["light"], $i); $i++; if (api_plugin_user_realm_auth('host.php')) { $host_url = "<a href='" . htmlspecialchars($config["url_path"] . "host.php?action=edit&id=" . $row["host_id"]) . "' title='Edit Hosts'>" . $row["hostname"] . "</a>"; } else { $host_url = $row["hostname"]; } echo "<td style='white-space:nowrap;' align='left' width='200'><strong>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $row["description"] . "</strong> [" . $host_url . "]") : $row["description"] . "</strong> [" . $host_url . "]") . "</td>"; echo "<td style='white-space:nowrap;' align='left' width='100'>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $row["name"]) : $row["name"]) . "</td>"; echo "<td style='white-space:nowrap;' align='left' title='" . $row["path"] . "' width='100'>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim($row["path"], 40)) : title_trim($row["path"], 40)) . "</td>"; echo "<td style='white-space:nowrap;' align='left' title='" . $row["parameters"] . "' width='100'>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim($row["parameters"], 40)) : title_trim($row["parameters"], 40)) . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . round($row["perfCPU"] / 3600, 0) . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . round($row["perfMemory"] / 1024, 2) . "</td>"; echo "<td width='20' style='white-space:nowrap;' align='left'>" . (isset($hmib_hrSWTypes[$row["type"]]) ? $hmib_hrSWTypes[$row["type"]] : "Unknown") . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . $hmib_hrSWRunStatus[$row["status"]] . "</td>"; } echo "</tr>"; print $nav; } else { print "<tr><td><em>No Running Software Found</em></td></tr>"; } html_end_box(); running_legend($totals, $total_rows); }
function hmib_running() { global $config, $item_rows, $hmib_hrSWTypes, $hmib_hrSWRunStatus; /* ================= input validation and session storage ================= */ $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'template' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'device' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'type' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'process' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '-1', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'name', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'ASC', 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_hmib_run'); /* ================= input validation ================= */ ?> <script type='text/javascript'> function applyFilter() { strURL = '?action=running'; strURL += '&template=' + $('#template').val(); strURL += '&filter=' + $('#filter').val(); strURL += '&rows=' + $('#rows').val(); strURL += '&device=' + $('#device').val(); strURL += '&process=' + $('#process').val(); strURL += '&type=' + $('#type').val(); strURL += '&header=false'; loadPageNoHeader(strURL); } function clearFilter() { strURL = '?action=running&clear=true&header=false'; loadPageNoHeader(strURL); } $(function() { $('#running').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> <?php html_start_box(__('Running Processes'), '100%', '', '3', 'center', ''); ?> <tr class='even'> <td> <form id='running' method='get' action='hmib.php?action=running'> <table class='filterTable'> <tr> <td style='width:55px;white-space: nowrap;'> <?php print __('OS Type'); ?> </td> <td> <select id='type' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('type') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <?php $types = db_fetch_assoc("SELECT DISTINCT id, CONCAT_WS('', name, ' [', version, ']') AS name\n\t\t\t\t\t\t\t\tFROM plugin_hmib_hrSystemTypes AS hrst\n\t\t\t\t\t\t\t\tINNER JOIN plugin_hmib_hrSystem AS hrs\n\t\t\t\t\t\t\t\tON hrst.id=hrs.host_type\n\t\t\t\t\t\t\t\tWHERE name!='' ORDER BY name"); if (sizeof($types)) { foreach ($types as $t) { echo "<option value='" . $t['id'] . "' " . (get_request_var('type') == $t['id'] ? 'selected' : '') . '>' . $t['name'] . '</option>'; } } ?> </select> </td> <td> <?php print __('Device'); ?> </td> <td> <select id='device' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('device') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <?php $hosts = db_fetch_assoc('SELECT DISTINCT host.id, host.description FROM plugin_hmib_hrSystem AS hrs INNER JOIN host ON hrs.host_id=host.id ' . (get_request_var('type') > 0 ? 'WHERE hrs.host_type=' . get_request_var('type') : '') . ' ORDER BY description'); if (sizeof($hosts)) { foreach ($hosts as $h) { echo "<option value='" . $h['id'] . "' " . (get_request_var('device') == $h['id'] ? 'selected' : '') . '>' . $h['description'] . '</option>'; } } ?> </select> </td> <td> <?php print __('Template'); ?> </td> <td> <select id='template' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('template') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <?php $templates = db_fetch_assoc('SELECT DISTINCT ht.id, ht.name FROM host_template AS ht INNER JOIN host ON ht.id=host.host_template_id INNER JOIN plugin_hmib_hrSystem AS hrs ON host.id=hrs.host_id ORDER BY name'); if (sizeof($templates)) { foreach ($templates as $t) { echo "<option value='" . $t['id'] . "' " . (get_request_var('template') == $t['id'] ? 'selected' : '') . '>' . $t['name'] . '</option>'; } } ?> </select> </td> <td> <input type='button' onClick='applyFilter()' value='<?php print __('Go'); ?> '> </td> <td> <input type='button' onClick='clearFilter()' value='<?php print __('Clear'); ?> '> </td> </tr> </table> <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 __('Process'); ?> </td> <td> <select id='process' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('process') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <?php $procs = db_fetch_assoc("SELECT DISTINCT name\n\t\t\t\t\t\t\t\tFROM plugin_hmib_hrSWRun_last_seen AS hrswr\n\t\t\t\t\t\t\t\tWHERE name!='System Idle Time' AND name NOT LIKE '128%' AND (name IS NOT NULL AND name!='')\n\t\t\t\t\t\t\t\tORDER BY name"); if (sizeof($procs)) { foreach ($procs as $p) { echo "<option value='" . $p['name'] . "' " . (get_request_var('process') == $p['name'] ? 'selected' : '') . '>' . $p['name'] . '</option>'; } } ?> </select> </td> <td> <?php print __('Entries'); ?> </td> <td> <select id='rows' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('rows') == '-1') { ?> selected<?php } ?> ><?php print __('Default'); ?> </option> <?php if (sizeof($item_rows)) { foreach ($item_rows as $key => $name) { echo "<option value='" . $key . "' " . (get_request_var('rows') == $key ? 'selected' : '') . '>' . $name . '</option>'; } } ?> </select> </td> </tr> </table> </td> <input type='hidden' id='page' value='<?php print get_request_var('page'); ?> '> </form> </tr> <?php html_end_box(); if (get_request_var('rows') == '-1') { $num_rows = read_config_option('num_rows_table'); } else { $num_rows = get_request_var('rows'); } $limit = ' LIMIT ' . $num_rows * (get_request_var('page') - 1) . ',' . $num_rows; $sql_where = "WHERE hrswr.name!='' AND hrswr.name!='System Idle Process'"; if (get_request_var('template') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' host.host_template_id=' . get_request_var('template'); } if (get_request_var('device') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' host.id=' . get_request_var('device'); } if (get_request_var('type') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' hrs.host_type=' . get_request_var('type'); } if (get_request_var('process') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " hrswr.name='" . get_request_var('process') . "'"; } if (get_request_var('filter') != '') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " (host.description LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thrswr.name LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thost.hostname LIKE '%" . get_request_var('filter') . "%')"; } $sql = "SELECT hrswr.*, host.hostname, host.description, host.disabled\n\t\tFROM plugin_hmib_hrSWRun AS hrswr\n\t\tINNER JOIN host\n\t\tON host.id=hrswr.host_id\n\t\tINNER JOIN plugin_hmib_hrSystem AS hrs\n\t\tON hrs.host_id=host.id\n\t\tINNER JOIN plugin_hmib_hrSystemTypes AS hrst\n\t\tON hrst.id=hrs.host_type\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction') . ' ' . $limit; //echo $sql; $rows = db_fetch_assoc($sql); $total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_hmib_hrSWRun AS hrswr\n\t\tINNER JOIN host\n\t\tON host.id=hrswr.host_id\n\t\tINNER JOIN plugin_hmib_hrSystem AS hrs\n\t\tON hrs.host_id=host.id\n\t\tINNER JOIN plugin_hmib_hrSystemTypes AS hrst\n\t\tON hrst.id=hrs.host_type\n\t\t{$sql_where}"); $totals = db_fetch_row("SELECT\n\t\tROUND(SUM(perfCPU),2) as cpu,\n\t\tROUND(SUM(perfMemory),2) as memory \n\t\tFROM plugin_hmib_hrSWRun AS hrswr \n\t\tINNER JOIN host ON host.id=hrswr.host_id \n\t\tINNER JOIN plugin_hmib_hrSystem AS hrs \n\t\tON hrs.host_id=host.id \n\t\tINNER JOIN plugin_hmib_hrSystemTypes AS hrst \n\t\tON hrst.id=hrs.host_type\n\t\t{$sql_where}"); $nav = html_nav_bar('hmib.php?action=running', MAX_DISPLAY_PAGES, get_request_var('page'), $num_rows, $total_rows, 16, __('Processes'), 'page', 'main'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('description' => array('display' => __('Hostname'), 'sort' => 'ASC', 'align' => 'left'), 'hrswr.name' => array('display' => __('Process'), 'sort' => 'DESC', 'align' => 'left'), 'path' => array('display' => __('Path'), 'sort' => 'ASC', 'align' => 'left'), 'parameters' => array('display' => __('Parameters'), 'sort' => 'ASC', 'align' => 'left'), 'perfCpu' => array('display' => __('CPU (Hrs)'), 'sort' => 'DESC', 'align' => 'right'), 'perfMemory' => array('display' => __('Memory (MB)'), 'sort' => 'DESC', 'align' => 'right'), 'type' => array('display' => __('Type'), 'sort' => 'ASC', 'align' => 'left'), 'status' => array('display' => __('Status'), 'sort' => 'DESC', 'align' => 'right')); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false, 'hmib.php?action=running', 'page', 'main'); if (sizeof($rows)) { foreach ($rows as $row) { form_alternate_row(); if (api_plugin_user_realm_auth('host.php')) { $host_url = "<a href='" . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $row['host_id']) . "' title='" . __('Edit Device') . "'>" . $row['hostname'] . '</a>'; } else { $host_url = $row['hostname']; } echo "<td style='white-space:nowrap;' align='left' width='200'><strong>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $row['description'] . '</strong> [' . $host_url . ']') : $row['description'] . '</strong> [' . $host_url . ']') . '</td>'; echo "<td style='white-space:nowrap;' align='left' width='100'>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $row['name']) : $row['name']) . '</td>'; echo "<td style='white-space:nowrap;' align='left' title='" . $row['path'] . "' width='100'>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", title_trim($row['path'], 40)) : title_trim($row['path'], 40)) . '</td>'; echo "<td style='white-space:nowrap;' align='left' title='" . $row['parameters'] . "' width='100'>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", title_trim($row['parameters'], 40)) : title_trim($row['parameters'], 40)) . '</td>'; echo "<td style='white-space:nowrap;' align='right'>" . number_format_i18n($row['perfCPU'] / 3600, 0) . '</td>'; echo "<td style='white-space:nowrap;' align='right'>" . number_format_i18n($row['perfMemory'] / 1024, 2) . '</td>'; echo "<td width='20' style='white-space:nowrap;' align='left'>" . (isset($hmib_hrSWTypes[$row['type']]) ? $hmib_hrSWTypes[$row['type']] : 'Unknown') . '</td>'; echo "<td style='white-space:nowrap;' align='right'>" . $hmib_hrSWRunStatus[$row['status']] . '</td>'; } echo '</tr>'; } else { print '<tr><td><em>' . __('No Running Software Found') . '</em></td></tr>'; } html_end_box(false); if (sizeof($rows)) { print $nav; } running_legend($totals, $total_rows); }