2010-08-09 Sergio Martin <sergio.martin@artica.es>

* operation/agentes/agents_modules_view.php
	operation/agentes/tactical.php
	operation/agentes/group_view.php
	operation/menu.php: Added the agents VS modules matrix
	and changed the color of some alert fired numbers and 
	table rows



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3108 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2010-08-09 08:43:56 +00:00
parent c427ab0807
commit 4e21a9e937
5 changed files with 201 additions and 3 deletions

View File

@ -1,3 +1,12 @@
2010-08-09 Sergio Martin <sergio.martin@artica.es>
* operation/agentes/agents_modules_view.php
operation/agentes/tactical.php
operation/agentes/group_view.php
operation/menu.php: Added the agents VS modules matrix
and changed the color of some alert fired numbers and
table rows
2010-08-06 Sergio Martin <sergio.martin@artica.es>
* include/functions_alerts.php

View File

@ -0,0 +1,186 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
require_once ("include/config.php");
require_once ("include/functions_reporting.php");
check_login ();
// ACL Check
if (! give_acl ($config['id_user'], 0, "AR")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access Agent view (Grouped)");
require ("general/noaccess.php");
exit;
}
// Update network modules for this group
// Check for Network FLAG change request
// Made it a subquery, much faster on both the database and server side
if (isset ($_GET["update_netgroup"])) {
$group = get_parameter_get ("update_netgroup", 0);
if (give_acl ($config['id_user'], $group, "AW")) {
$sql = sprintf ("UPDATE tagente_modulo SET `flag` = 1 WHERE `id_agente` = ANY(SELECT id_agente FROM tagente WHERE `id_grupo` = %d)",$group);
process_sql ($sql);
} else {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to set flag for groups");
require ("general/noaccess.php");
exit;
}
}
if ($config["realtimestats"] == 0){
$updated_time = __('Last update'). " : ". print_timestamp (get_db_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true);
} else {
$updated_time = __("Updated at realtime");
}
$offset = get_parameter('offset', 0);
$hor_offset = get_parameter('hor_offset', 0);
$block = 13;
// Header
print_page_header (__("Agents/Modules view"), "images/bricks.png", false, "", false, $updated_time );
// Old style table, we need a lot of special formatting,don't use table function
// Prepare old-style table
$all_modules = get_agent_modules('', false, false, true, false);
$modules_by_name = array();
$name = '';
$cont = 0;
foreach($all_modules as $key => $module) {
if($module == $name){
$modules_by_name[$cont-1]['id'][] = $key;
}
else{
$name = $module;
$modules_by_name[$cont]['name'] = $name;
$modules_by_name[$cont]['id'][] = $key;
$cont ++;
}
}
echo '<table cellpadding="2" cellspacing="0" border="0">';
if($hor_offset > 0) {
$new_hor_offset = $hor_offset-$block;
echo "<th width='30px'><a href='index.php?sec=estado&sec2=operation/agentes/agent_module_view&refr=0&hor_offset=".$new_hor_offset."'><<</a> </th>";
}
echo "<th width='150px'>".__("Agents")." \\ ".__("Modules")."</th>";
$nmodules = 0;
foreach($modules_by_name as $module) {
$nmodules++;
if($nmodules <= $hor_offset || $nmodules > ($hor_offset+$block)) {
continue;
}
echo "<th width='30px'>".printTruncateText($module['name'],4, false)."</th>";
}
if(($hor_offset + $block) < $nmodules) {
$new_hor_offset = $hor_offset+$block;
echo "<th width='30px'><a href='index.php?sec=estado&sec2=operation/agentes/agent_module_view&refr=0&hor_offset=".$new_hor_offset."'>>></a> </th>";
}
$agents = get_agents (array ('offset' => (int) $offset,
'limit' => (int) $config['block_size']));
// Prepare pagination
pagination ((int)count(get_agents ()));
echo "<br>";
foreach ($agents as $agent) {
// Get stats for this group
$data = get_agent_module_info($agent['id_agente']);
// Calculate entire row color
if ($data["monitor_alertsfired"] > 0){
echo "<tr style='background-color: #ffd78f; height: 35px; '>";
} elseif ($data["monitor_critical"] > 0) {
echo "<tr style='background-color: #ffc0b5; height: 35px;'>";
} elseif ($data["monitor_warning"] > 0) {
echo "<tr style='background-color: #f4ffbf; height: 35px;'>";
} elseif ($data["monitor_unknown"] > 0) {
echo "<tr style='background-color: #ddd; height: 35px;'>";
} elseif ($data["monitor_normal"] > 0) {
echo "<tr style='background-color: #bbffa4; height: 35px;'>";
} else {
echo "<tr style='background-color: #ffffff; height: 35px;'>";
}
if($hor_offset > 0) {
echo "<td></td>";
}
echo "<td>".printTruncateText($agent['nombre'],20)."</td>";
$agent_modules = get_agent_modules($agent['id_agente']);
$nmodules = 0;
foreach($modules_by_name as $module) {
$nmodules++;
if($nmodules <= $hor_offset || $nmodules > ($hor_offset+$block)) {
continue;
}
$match = false;
foreach($module['id'] as $module_id){
if(!$match && array_key_exists($module_id,$agent_modules)) {
$status = get_agentmodule_status($module_id);
echo "<td style='text-align: center;'>";
switch($status){
case 0:
print_status_image ('module_ok.png', $module['name']." in ".$agent['nombre'].": ".__('NORMAL'));
break;
case 1:
print_status_image ('module_critical.png', $module['name']." in ".$agent['nombre'].": ".__('CRITICAL'));
break;
case 2:
print_status_image ('module_warning.png', $module['name']." in ".$agent['nombre'].": ".__('WARNING'));
break;
case 3:
print_status_image ('module_unknown.png', $module['name']." in ".$agent['nombre'].": ".__('UNKNOWN'));
break;
case 4:
print_status_image ('module_alertsfired.png', $module['name']." in ".$agent['nombre'].": ".__('ALERTS FIRED'));
break;
}
echo "</td>";
$match = true;
}
}
if(!$match) {
echo "<td></td>";
}
}
if(($hor_offset+$block) < $nmodules) {
echo "<td></td>";
}
echo "</tr>";
}
echo "</table>";
?>

View File

@ -101,7 +101,7 @@ foreach ($groups as $id_group => $group_name) {
// Calculate entire row color
if ($data["monitor_alerts_fired"] > 0){
echo "<tr style='background-color: #ffb4e9; height: 35px; '>";
echo "<tr style='background-color: #ffd78f; height: 35px; '>";
} elseif ($data["monitor_critical"] > 0) {
echo "<tr style='background-color: #ffc0b5; height: 35px;'>";
} elseif ($data["monitor_warning"] > 0) {

View File

@ -126,7 +126,7 @@ $cells[3]["color"] = "#c00";
$cells[2][0] = __('Monitors warning');
$cells[2][1] = $data["monitor_warning"];
$cells[2]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1"; //Down
$cells[2]["color"] = "#ffb900";
$cells[2]["color"] = "#ffcc00";
$cells[1][0] = __('Monitors normal');
$cells[1][1] = $data["monitor_ok"];
@ -151,7 +151,7 @@ $cells[6]["color"] = "#000";
$cells[7][0] = __('Alerts fired');
$cells[7][1] = $data["monitor_alerts_fired"];
$cells[7]["href"] = "index.php?sec=eventos&sec2=operation/events/events&search=&event_type=alert_fired"; //Fired alert events
$cells[7]["color"] = "#c00";
$cells[7]["color"] = "#ff8800";
print_cells_temp ($cells);

View File

@ -47,6 +47,9 @@ if (give_acl ($config['id_user'], 0, "AR")) {
$sub["operation/agentes/group_view"]["text"] = __('Group view');
$sub["operation/agentes/group_view"]["refr"] = 60;
$sub["operation/agentes/agents_modules_view"]["text"] = __('Agents/Modules view');
$sub["operation/agentes/agents_modules_view"]["refr"] = 60;
$sub["operation/agentes/networkmap"]["text"] = __('Network map');
$sub["operation/agentes/estado_agente"]["text"] = __('Agent detail');