示例#1
0
function hmib_summary()
{
    global $colors, $device_actions, $item_rows, $config;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("htop"));
    input_validate_input_number(get_request_var_request("ptop"));
    /* ==================================================== */
    /* clean up sort string */
    if (isset($_REQUEST["sort_column"])) {
        $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
    }
    /* clean up sort string */
    if (isset($_REQUEST["sort_direction"])) {
        $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
    }
    /* clean up search string */
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
    }
    /* clean up process string */
    if (isset($_REQUEST["process"])) {
        $_REQUEST["process"] = sanitize_search_string(get_request_var("process"));
    }
    /* remember these search fields in session vars so we don't have
     * to keep passing them around
     */
    if (!isset($_REQUEST["area"])) {
        $_REQUEST["sort_column"] = "downHosts";
        $_REQUEST["sort_direction"] = "DESC";
        load_current_session_value("sort_column", "sess_hmib_host_sort_column", "downHosts");
        load_current_session_value("sort_direction", "sess_hmib_host_sort_direction", "ASC");
        load_current_session_value("htop", "sess_hmib_host_top", read_config_option("hmib_top_types"));
    } elseif ($_REQUEST["area"] == "hosts") {
        /* if the user pushed the 'clear' button */
        if (isset($_REQUEST["clearh"])) {
            kill_session_var("sess_hmib_host_top");
            kill_session_var("sess_hmib_sort_column");
            kill_session_var("sess_hmib_sort_direction");
            unset($_REQUEST["htop"]);
            unset($_REQUEST["sort_column"]);
            unset($_REQUEST["sort_direction"]);
        }
        load_current_session_value("sort_column", "sess_hmib_host_sort_column", "downHosts");
        load_current_session_value("sort_direction", "sess_hmib_host_sort_direction", "ASC");
        load_current_session_value("htop", "sess_hmib_host_top", read_config_option("hmib_top_types"));
    } else {
        load_current_session_value("htop", "sess_hmib_host_top", read_config_option("hmib_top_types"));
        load_current_session_value("my_sort_column", "sess_hmib_host_sort_column", "downHosts");
        load_current_session_value("my_sort_direction", "sess_hmib_host_sort_direction", "ASC");
    }
    if (isset($_REQUEST["my_sort_column"])) {
        $sort_column = $_REQUEST["my_sort_column"];
        $sort_dir = $_REQUEST["my_sort_direction"];
    } else {
        $sort_column = $_REQUEST["sort_column"];
        $sort_dir = $_REQUEST["sort_direction"];
    }
    unset($_REQUEST["my_sort_column"]);
    unset($_REQUEST["my_sort_direction"]);
    ?>
	<script type="text/javascript">
	<!--
	function applyHostFilter(objForm) {
		strURL = '?action=summary&area=hosts';
		strURL = strURL + '&htop=' + objForm.htop.value;
		document.location = strURL;
	}

	function clearHosts() {
		strURL = '?area=hosts&clearh=';
		document.location = strURL;
	}
	-->
	</script>
	<?php 
    html_start_box("<strong>Summary Filter</strong>", "100%", $colors["header"], "3", "center", "");
    ?>
	<tr bgcolor="#<?php 
    print $colors["panel"];
    ?>
">
		<td>
			<form name="host_summary" action="hmib.php?action=summary">
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<td nowrap style='white-space: nowrap;' width="60">
						&nbsp;Top:&nbsp;
					</td>
					<td width="1">
						<select name="htop" onChange="applyHostFilter(document.host_summary)">
							<option value="-1"<?php 
    if (get_request_var_request("htop") == "-1") {
        ?>
 selected<?php 
    }
    ?>
>All Records</option>
							<option value="5"<?php 
    if (get_request_var_request("htop") == "5") {
        ?>
 selected<?php 
    }
    ?>
>5 Records</option>
							<option value="10"<?php 
    if (get_request_var_request("htop") == "10") {
        ?>
 selected<?php 
    }
    ?>
>10 Records</option>
							<option value="15"<?php 
    if (get_request_var_request("htop") == "15") {
        ?>
 selected<?php 
    }
    ?>
>15 Records</option>
							<option value="20"<?php 
    if (get_request_var_request("htop") == "20") {
        ?>
 selected<?php 
    }
    ?>
>20 Records</option>
						</select>
					</td>
					<td nowrap>
						&nbsp;<input type="button" onClick="applyHostFilter(document.host_summary)" value="Go" border="0">
						<input type="button" onClick="clearHosts()" value="Clear" name="clearh" border="0">
					</td>
				</tr>
			</table>
			</form>
		</td>
	</tr>
	<?php 
    html_end_box(false);
    html_start_box("<strong>Host Type Summary Statistics</strong>", "100%", $colors["header"], "3", "center", "");
    if ($_REQUEST["htop"] == -1) {
        $limit = "";
    } else {
        $limit = "LIMIT " . get_request_var_request("htop");
    }
    $sql = "SELECT\n\t\thrst.id AS id,\n\t\thrst.name AS name,\n\t\thrst.version AS version,\n\t\thrs.host_type AS host_type,\n\t\tSUM(CASE WHEN host_status=3 THEN 1 ELSE 0 END) AS upHosts,\n\t\tSUM(CASE WHEN host_status=2 THEN 1 ELSE 0 END) AS recHosts,\n\t\tSUM(CASE WHEN host_status=1 THEN 1 ELSE 0 END) AS downHosts,\n\t\tSUM(CASE WHEN host_status=0 THEN 1 ELSE 0 END) AS disabledHosts,\n\t\tSUM(users) AS users,\n\t\tSUM(numCpus) AS cpus,\n\t\tAVG(memUsed) AS avgMem,\n\t\tMAX(memUsed) AS maxMem,\n\t\tAVG(swapUsed) AS avgSwap,\n\t\tMAX(swapUsed) AS maxSwap,\n\t\tAVG(cpuPercent) AS avgCpuPercent,\n\t\tMAX(cpuPercent) AS maxCpuPercent,\n\t\tAVG(processes) AS avgProcesses,\n\t\tMAX(processes) AS maxProcesses\n\t\tFROM plugin_hmib_hrSystem AS hrs\n\t\tLEFT JOIN plugin_hmib_hrSystemTypes AS hrst\n\t\tON hrs.host_type=hrst.id\n\t\tGROUP BY name, version\n\t\tORDER BY " . $sort_column . " " . $sort_dir . " " . $limit;
    $rows = db_fetch_assoc($sql);
    $display_text = array("nosort" => array("Actions", array("ASC", "left")), "name" => array("Type", array("ASC", "left")), "(version/1)" => array("Version", array("ASC", "right")), "upHosts" => array("Up", array("DESC", "right")), "recHosts" => array("Recovering", array("DESC", "right")), "downHosts" => array("Down", array("DESC", "right")), "disabledHosts" => array("Disabled", array("DESC", "right")), "users" => array("Logins", array("DESC", "right")), "cpus" => array("CPUS", array("DESC", "right")), "avgCpuPercent" => array("Avg CPU", array("DESC", "right")), "maxCpuPercent" => array("Max CPU", array("DESC", "right")), "avgMem" => array("Avg Mem", array("DESC", "right")), "maxMem" => array("Max Mem", array("DESC", "right")), "avgSwap" => array("Avg Swap", array("DESC", "right")), "maxSwap" => array("Max Swap", array("DESC", "right")), "avgProcesses" => array("Avg Proc", array("DESC", "right")), "maxProcesses" => array("Max Proc", array("DESC", "right")));
    hmib_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), "action=summary&area=hosts");
    /* set some defaults */
    $url = $config["url_path"] . "plugins/hmib/hmib.php";
    $proc = $config["url_path"] . "plugins/hmib/images/view_processes.gif";
    $host = $config["url_path"] . "plugins/hmib/images/view_hosts.gif";
    $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/view_storage.gif";
    $htdq = read_config_option("hmib_dq_host_type");
    $hcpudq = read_config_option("hmib_dq_host_cpu");
    $hugt = read_config_option("hmib_gt_users");
    $hpgt = read_config_option("hmib_gt_processes");
    $htsd = read_config_option("hmib_summary_host_template");
    $i = 0;
    if (sizeof($rows)) {
        foreach ($rows as $row) {
            $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, round($row["avgProcesses"], 0), false);
            $graph_mproc = hmib_get_graph_template_url($hpgt, $row["id"], 0, round($row["maxProcesses"], 0), false);
            form_alternate_row_color($colors["alternate"], $colors["light"], $i);
            $i++;
            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' border='0'></a>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=storage&ostype=" . $row["id"]) . "'><img src='{$storage}' title='View Storage' align='absmiddle' border='0'></a>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=hardware&ostype=" . $row["id"]) . "'><img src='{$hardw}' title='View Hardware' align='absmiddle' border='0'></a>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=running&type=" . $row["id"]) . "'><img src='{$proc}' title='View Processes' align='absmiddle' border='0'></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' border='0'></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 style='white-space:nowrap;' align='left' width='80'>" . ($row["name"] != "" ? $row["name"] : "Unknown") . "</td>";
            echo "<td style='white-space:nowrap;' align='right' width='20'>" . $row["version"] . "</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . $upHosts . "</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . $recHosts . "</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . $downHosts . "</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . $disaHosts . "</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . $graph_users . "</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . $graph_ncpu . "</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . $graph_acpu . " %</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . $graph_mcpu . " %</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . round($row["avgMem"], 2) . " %</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . round($row["maxMem"], 2) . " %</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . round($row["avgSwap"], 2) . " %</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . round($row["maxSwap"], 2) . " %</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . $graph_aproc . "</td>";
            echo "<td style='white-space:nowrap;' align='right'>" . $graph_mproc . "</td>";
        }
        echo "</tr>";
    } else {
        print "<tr><td><em>No Host Types</em></td></tr>";
    }
    html_end_box();
    if (!isset($_REQUEST["area"])) {
        $_REQUEST["sort_column"] = "maxCpu";
        $_REQUEST["sort_direction"] = "DESC";
        load_current_session_value("filter", "sess_hmib_proc_filter", "");
        load_current_session_value("process", "sess_hmib_proc_process", "-1");
        load_current_session_value("sort_column", "sess_hmib_proc_sort_column", "maxCpu");
        load_current_session_value("sort_direction", "sess_hmib_proc_sort_direction", "DESC");
        load_current_session_value("ptop", "sess_hmib_proc_top", read_config_option("hmib_top_processes"));
    } elseif ($_REQUEST["area"] == "processes") {
        /* if the user pushed the 'clear' button */
        if (isset($_REQUEST["clearp"])) {
            kill_session_var("sess_hmib_proc_top");
            kill_session_var("sess_hmib_proc_process");
            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["filter"]);
            unset($_REQUEST["ptop"]);
            unset($_REQUEST["process"]);
            unset($_REQUEST["sort_column"]);
            unset($_REQUEST["sort_direction"]);
        }
        load_current_session_value("filter", "sess_hmib_proc_filter", "");
        load_current_session_value("process", "sess_hmib_proc_process", "-1");
        load_current_session_value("sort_column", "sess_hmib_proc_sort_column", "maxCpu");
        load_current_session_value("sort_direction", "sess_hmib_proc_sort_direction", "DESC");
        load_current_session_value("ptop", "sess_hmib_proc_top", read_config_option("hmib_top_processes"));
    } else {
        load_current_session_value("filter", "sess_hmib_proc_filter", "");
        load_current_session_value("process", "sess_hmib_proc_process", "-1");
        load_current_session_value("ptop", "sess_hmib_proc_top", read_config_option("hmib_top_processes"));
        load_current_session_value("my_sort_column", "sess_hmib_proc_sort_column", "maxCpu");
        load_current_session_value("my_sort_direction", "sess_hmib_proc_sort_direction", "DESC");
    }
    html_start_box("<strong>Host Process Summary Filter</strong>", "100%", $colors["header"], "3", "center", "");
    ?>
	<tr bgcolor="#<?php 
    print $colors["panel"];
    ?>
">
		<td>
			<form name="proc_summary" action="hmib.php?action=summary">
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td nowrap style='white-space: nowrap;' width="60">
						&nbsp;Top:&nbsp;
					</td>
					<td width="1">
						<select name="ptop" onChange="applyProcFilter(document.proc_summary)">
							<option value="-1"<?php 
    if (get_request_var_request("ptop") == "-1") {
        ?>
 selected<?php 
    }
    ?>
>All Records</option>
							<option value="5"<?php 
    if (get_request_var_request("ptop") == "5") {
        ?>
 selected<?php 
    }
    ?>
>5 Records</option>
							<option value="10"<?php 
    if (get_request_var_request("ptop") == "10") {
        ?>
 selected<?php 
    }
    ?>
>10 Records</option>
							<option value="15"<?php 
    if (get_request_var_request("ptop") == "15") {
        ?>
 selected<?php 
    }
    ?>
>15 Records</option>
							<option value="20"<?php 
    if (get_request_var_request("ptop") == "20") {
        ?>
 selected<?php 
    }
    ?>
>20 Records</option>
						</select>
					</td>
					<td nowrap style='white-space: nowrap;' width="60">
						&nbsp;Process:&nbsp;
					</td>
					<td width="1">
						<select name="process" onChange="applyProcFilter(document.proc_summary)">
							<option value="-1"<?php 
    if (get_request_var_request("process") == "-1") {
        ?>
 selected<?php 
    }
    ?>
>All</option>
							<?php 
    $processes = db_fetch_assoc("SELECT DISTINCT name FROM plugin_hmib_hrSWRun WHERE name!='' ORDER BY name");
    if (sizeof($processes)) {
        foreach ($processes 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">
						&nbsp;Search:&nbsp;
					</td>
					<td>
						<input type='text' size='40' name='filter' value='<?php 
    print get_request_var_request("filter");
    ?>
'>
					</td>
					<td nowrap>
						&nbsp;<input type="button" onClick="applyProcFilter(document.proc_summary)" value="Go" border="0">
						<input type="button" onClick="clearProc()" value="Clear" name="clearp" border="0">
					</td>
				</tr>
			</table>
			</form>
		</td>
	</tr>
	<tr style='display:none;'><td>
	<script type="text/javascript">
	<!--
	function applyProcFilter(objForm) {
		strURL = '?action=summary&area=processes';
		strURL = strURL + '&filter='   + objForm.filter.value;
		strURL = strURL + '&process='   + objForm.process.value;
		strURL = strURL + '&ptop='   + objForm.ptop.value;
		document.location = strURL;
	}

	function clearProc() {
		strURL = '?action=summary&area=processes&clearp';
		document.location = strURL;
	}
	-->
	</script>
	</td></tr>
	<?php 
    html_end_box(false);
    html_start_box("<strong>Host Process Summary Statistics</strong>", "100%", $colors["header"], "3", "center", "");
    if (isset($_REQUEST["my_sort_column"])) {
        $sort_column = $_REQUEST["my_sort_column"];
        $sort_dir = $_REQUEST["my_sort_direction"];
    } else {
        $sort_column = $_REQUEST["sort_column"];
        $sort_dir = $_REQUEST["sort_direction"];
    }
    if ($_REQUEST["ptop"] == -1) {
        $limit = "";
    } else {
        $limit = "LIMIT " . get_request_var_request("ptop");
    }
    if (strlen($_REQUEST["filter"])) {
        $sql_where = "AND (hrswr.name LIKE '%%" . get_request_var_request("filter") . "%%' OR\n\t\t\thrswr.path LIKE '%%" . get_request_var_request("filter") . "%%' OR\n\t\t\thrswr.parameters LIKE '%%" . get_request_var_request("filter") . "%%')";
    } else {
        $sql_where = "";
    }
    if ($_REQUEST["process"] != "-1") {
        $sql_where .= " AND hrswr.name='" . $_REQUEST["process"] . "'";
    }
    $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 " . $sort_column . " " . $sort_dir . " " . $limit;
    $rows = db_fetch_assoc($sql);
    //echo $sql;
    $display_text = array("nosort" => array("Actions", array("ASC", "left")), "name" => array("Process Name", array("ASC", "left")), "paths" => array("Num Paths", array("DESC", "right")), "numHosts" => array("Hosts", array("DESC", "right")), "numProcesses" => array("Processes", array("DESC", "right")), "avgCpu" => array("Avg CPU", array("DESC", "right")), "maxCpu" => array("Max CPU", array("DESC", "right")), "avgMemory" => array("Avg Memory", array("DESC", "right")), "maxMemory" => array("Max Memory", array("DESC", "right")));
    hmib_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), "action=summary&area=processes");
    /* set some defaults */
    $url = $config["url_path"] . "plugins/hmib/hmib.php";
    $proc = $config["url_path"] . "plugins/hmib/images/view_processes.gif";
    $host = $config["url_path"] . "plugins/hmib/images/view_hosts.gif";
    /* get the data query for the application use */
    $adq = read_config_option("hmib_dq_applications");
    $i = 0;
    if (sizeof($rows)) {
        foreach ($rows as $row) {
            $graph_url = hmib_get_graph_url($adq, 0, 0, $row["name"]);
            form_alternate_row_color($colors["alternate"], $colors["light"], $i);
            $i++;
            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' border='0'></a>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=running&process=" . $row["name"]) . "'><img src='{$proc}' title='View Processes' align='absmiddle' border='0'></a>";
            echo $graph_url;
            echo "</td>";
            echo "<td align='left' width='80'>" . $row["name"] . "</td>";
            echo "<td align='right'>" . $row["paths"] . "</td>";
            echo "<td align='right'>" . $row["numHosts"] . "</td>";
            echo "<td align='right'>" . $row["numProcesses"] . "</td>";
            echo "<td align='right'>" . round($row["avgCpu"] / 3600, 0) . " Hrs</td>";
            echo "<td align='right'>" . round($row["maxCpu"] / 3600, 0) . " Hrs</td>";
            echo "<td align='right'>" . round($row["avgMemory"] / 1024, 2) . " MB</td>";
            echo "<td align='right'>" . round($row["maxMemory"] / 1024, 2) . " MB</td>";
        }
        echo "</tr>";
    } else {
        print "<tr><td><em>No Processes</em></td></tr>";
    }
    html_end_box();
}
示例#2
0
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>
						&nbsp;&nbsp;<?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>
						&nbsp;&nbsp;<?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();
}