2009-04-09 Evi Vanoost <vanooste@rcbi.rochester.edu>

* include/functions_reporting.php: Added get_agent_module_info which gives
	valuable information that can be re-used and expanded
	
	* include/functions_events.php, include/functions_ui.php: The chunk_split 
	only works with set width removed for wide css. General cleanup
	
	* include/functions_db.php: get_group_agents allows search now
	
	* include/styles/pandora_width.css, include/styles/pandora.css, 
	include/styles/menu.css: The menu for the agent editor is now even with the
	operation menu and also takes up the whole width
	
	* operation/agentes/tactical.php: Changed for width. Now takes up the wide
	
	* operation/agentes/estado_agente.php: Rewritten. Now outputs variable
	width table and is cleaner

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1606 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2009-04-09 21:06:17 +00:00
parent b4c74d5eac
commit b2457ef301
11 changed files with 288 additions and 343 deletions

View File

@ -1,3 +1,22 @@
2009-04-09 Evi Vanoost <vanooste@rcbi.rochester.edu>
* include/functions_reporting.php: Added get_agent_module_info which gives
valuable information that can be re-used and expanded
* include/functions_events.php, include/functions_ui.php: The chunk_split
only works with set width removed for wide css. General cleanup
* include/functions_db.php: get_group_agents allows search now
* include/styles/pandora_width.css, include/styles/pandora.css,
include/styles/menu.css: The menu for the agent editor is now even with the
operation menu and also takes up the whole width
* operation/agentes/tactical.php: Changed for width. Now takes up the wide
* operation/agentes/estado_agente.php: Rewritten. Now outputs variable
width table and is cleaner
2009-04-08 Jorge Gonzalez <jorgegonz@svn.gnome.org>
* images/console/icons/dotmin_ok.png,

View File

@ -321,12 +321,12 @@ function give_disabled_group ($id_group) {
* Get all the agents within a group(s).
*
* @param mixed $id_group Group id or an array of ID's. If nothing is selected, it will select all
* @param bool $disabled Add disabled agents to agents. Default: False.
* @param mixed $search to add Default: False. If True will return disabled agents as well. If searching array (disabled => (bool), string => (string))
* @param string $case Which case to return the agentname as (lower, upper, none)
*
* @return array An array with all agents in the group or an empty array
*/
function get_group_agents ($id_group = 0, $disabled = false, $case = "lower") {
function get_group_agents ($id_group = 0, $search = false, $case = "lower") {
global $config;
$id_group = safe_acl_group ($config["id_user"], $id_group, "AR");
@ -337,8 +337,20 @@ function get_group_agents ($id_group = 0, $disabled = false, $case = "lower") {
}
$search = sprintf ('WHERE id_grupo IN (%s)', implode (",", $id_group));
if (!empty ($disabled)) {
if ($search === true) {
//No added search. Show both disabled and non-disabled
} elseif (is_array ($search)) {
if (isset ($search["disabled"])) {
$search .= ' AND disabled = '.($search["disabled"] ? 1 : 0); //Bool, no cleanup necessary
} else {
$search .= ' AND disabled = 0';
}
if (isset ($search["string"])) {
$string = safe_input ($search["string"]);
$search .= ' (nombre LIKE "'.$string.'" OR comentarios LIKE "'.$string.'" OR direccion LIKE "'.$string.'"';
}
} else {
$search .= ' AND disabled = 0';
}

View File

@ -294,16 +294,11 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return =
// Event description wrap around by default at 44 or ~3 lines (10 seems to be a good ratio to wrap around for most sizes. Smaller number gets longer strings)
$wrap = floor ($width / 10);
$data[2] = '<span class="'.get_priority_class ($event["criticity"]).'f9" title="'.safe_input ($event["evento"]).'">'.safe_input (chunk_split (mb_substr ($event["evento"],0, $wrap),8, "&shy;"));
if (mb_strlen ($event["evento"]) > $wrap) {
$data[2] .= "&hellip;";
}
$data[2] .= '</span>';
$data[2] = '<span class="'.get_priority_class ($event["criticity"]).'f9" title="'.safe_input ($event["evento"]).'">'.safe_input ($event["evento"]).'</span>';
if ($event["id_agente"] > 0) {
// Agent name
$data[3] = print_agent_name ($event["id_agente"], true, floor ($width / 20)); //At 440 this would be be 22.
$data[3] = print_agent_name ($event["id_agente"], true);
// for System or SNMP generated alerts
} elseif ($event["event_type"] == "system") {
$data[3] = __('System');

View File

@ -738,4 +738,99 @@ function get_agents_detailed_event_reporting ($id_agents, $period = 0, $date = 0
return print_table ($table, $return);
}
/**
* Get a detailed report of the modules of the agent
*
* @param int $id_agent Agent id to get the report for.
*
* @return array An array
*/
function get_agent_module_info ($id_agent) {
global $config;
$return = array ();
$return["modules"] = 0; //Number of modules
$return["monitor_normal"] = 0; //Number of 'good' monitors
$return["monitor_warning"] = 0; //Number of 'warning' monitors
$return["monitor_critical"] = 0; //Number of 'critical' monitors
$return["monitor_down"] = 0; //Number of 'down' monitors
$return["last_contact"] = 0; //Last agent contact
$return["interval"] = get_agent_interval ($id_agent); //How often the agent gets contacted
$return["status_img"] = print_status_image(STATUS_AGENT_NO_DATA, __('Agent without data'), true);
$return["alert_status"] = "notfired";
$return["alert_img"] = print_status_image(STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true);
$return["agent_group"] = get_agent_group ($id_agent);
if (!give_acl ($config["id_user"], $return["agent_group"], "AR")) {
return $return;
}
$sql = sprintf ("SELECT * FROM tagente_estado, tagente_modulo
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND
tagente_modulo.disabled = 0 AND tagente_modulo.id_agente = %d", $id_agent);
$modules = get_db_all_rows_sql ($sql);
if ($modules === false) {
return $return;
}
$now = get_system_time ();
// Calculate modules for this agent
foreach ($modules as $module) {
$return["modules"]++;
if ($module["module_interval"] > $return["interval"]) {
$return["interval"] = $module["module_interval"];
} elseif ($module["module_interval"] == 0) {
$module["module_interval"] = $return["interval"];
}
if ($module["utimestamp"] > $return["last_contact"]) {
$return["last_contact"] = $module["utimestamp"];
}
if ($module["id_tipo_modulo"] < 21 || $module["id_tipo_modulo"] != 100) {
$async = 0;
} else {
$async = 1;
}
if ($async == 0 && ($module["utimestamp"] < ($now - $module["module_interval"] * 2))) {
$return["monitor_down"]++;
} elseif ($module["estado"] == 2) {
$return["monitor_warning"]++;
} elseif ($module["estado"] == 1) {
$return["monitor_critical"]++;
} else {
$return["monitor_normal"]++;
}
}
//No modules is by default
if ($return["modules"] > 0) {
if ($return["monitor_down"] > 0) {
$return["status_img"] = print_status_image (STATUS_AGENT_DOWN, __('At least one module DOWN'), true);
} elseif ($return["monitor_critical"] > 0) {
$return["status_img"] = print_status_image (STATUS_AGENT_CRITICAL, __('At least one module in CRITICAL status'), true);
} elseif ($return["monitor_warning"] > 0) {
$return["status_img"] = print_status_image (STATUS_AGENT_WARNING, __('At least one module in WARNING status'), true);
} else {
$return["status_img"] = print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true);
}
}
//Alert not fired is by default
if (give_disabled_group ($return["agent_group"])) {
$return["alert_status"] = "disabled";
$return["alert_img"] = print_status_image (STATUS_ALERT_DISABLED, __('Alert disabled'), true);
} elseif (check_alert_fired ($id_agent) == 1) {
$return["alert_status"] = "fired";
$return["alert_img"] = print_status_image (STATUS_ALERT_FIRED, __('Alert fired'), true);
}
return $return;
}
?>

View File

@ -208,10 +208,10 @@ function print_group_icon ($id_group, $return = false, $path = "groups_small") {
$output .= '<img class="bot" src="images/'.$path.'/'.$icon.'.png" alt="'.get_group_name ($id_group).'" title="'.get_group_name ($id_group).'" />';
$output .= '</a>';
if ($return)
return $output;
if (!$return)
echo $output;
echo $output;
return $output;
}
/**
@ -236,10 +236,10 @@ function print_os_icon ($id_os, $name = true, $return = false) {
$output .= ' - '.$os_name;
}
if ($return)
return $output;
if (!$return)
echo $output;
echo $output;
return $output;
}
/**
@ -247,20 +247,13 @@ function print_os_icon ($id_os, $name = true, $return = false) {
*
* @param int Agent id
* @param bool Whether to return the string or echo it too
* @param int After how much characters to cut off the inside of the
* link. The full agent name will remain in the roll-over
* @param int Now uses styles to accomplish this
*
* @return string HTML with agent name and link
*/
function print_agent_name ($id_agent, $return = false, $cutoff = 0) {
$agent_name = (string) get_agent_name ($id_agent);
$output = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agent.'" title="'.$agent_name.'"><b>';
if ($cutoff > 0 && (mb_strlen ($agent_name, "UTF-8") > $cutoff)) {
$output .= mb_substr (utf8_decode ($agent_name), 0, $cutoff, "UTF-8").'...';
} else {
$output .= $agent_name;
}
$output .= '</b></a>';
$output = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agent.'" title="'.$agent_name.'"><b>'.$agent_name.'</b></a>';
//TODO: Add a pretty javascript (using jQuery) popup-box with agent details
@ -1055,13 +1048,12 @@ define('STATUS_ALERT_DISABLED', 'alert_disabled.png');
define('STATUS_SERVER_OK', 'server_ok.png');
define('STATUS_SERVER_DOWN', 'server_down.png');
function print_status_image($type, $title = "", $return = false)
{
function print_status_image($type, $title = "", $return = false) {
list($imagepath) = get_status_images_path();
$imagepath .= "/" . $type;
return print_image ($imagepath, $return, array ("border" => 0, "title" => $title));
return print_image ($imagepath, $return, array ("border" => 0, "title" => $title));
}
?>

View File

@ -24,7 +24,6 @@
border-width: 1px 0 0 1px;
border-style: solid;
border-color: #dadbdc;
width: 155px;
}
.menu ul {
list-style-type: none;
@ -56,7 +55,7 @@
.submenu {
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
margin: 0px 10px 0px 0;
width:155px;
width: 164px;
}
.submenu li a {
background-color: #fff;

View File

@ -31,6 +31,7 @@ body {
input, textarea {
border: 1px solid #ddd;
}
textarea {
padding: 5px;
min-height: 100px;
@ -178,7 +179,7 @@ div#page {
border-top: solid 5px #786;
}
div#main {
width: 780px;
width: 785px;
min-height: 500px;
float: right;
padding-left: 0px;
@ -192,7 +193,7 @@ div#main {
margin-right: 0px;
}
div#menu {
width: 155px;
width: 165px;
float: left;
}
div#head {
@ -445,23 +446,17 @@ div.title_line {
height: 5px;
width: 762px;
}
#menu_tab_frame {
background: #D84437;
width: 805px;
min-height: 22px;
padding-left: 0px;
margin-left: -25px;
float:left;
border-bottom: 1px solid #778866;
#menu_tab_frame, #menu_tab_frame_view {
background:#D84437 none repeat scroll 0 0;
border-bottom:1px solid #778866;
float:left;
margin-left:-8px;
min-height:25px;
padding-right:8px;
width:100%;
}
#menu_tab_frame_view {
background: #66AA44;
width: 805px;
min-height: 22px;
padding-left: 0px;
margin-left: -25px;
float:left;
border-bottom: 1px solid #778866;
background: #66AA44;
}
#menu_tab .mn, #menu_tab ul, #menu_tab .mn ul {
padding: 0px;
@ -472,21 +467,17 @@ div.title_line {
float: right;
position: relative;
}
#menu_tab li a, #menu_tab li.nomn a {
#menu_tab li a, #menu_tab a {
background: #d4ddc6;
padding: 2px 5px 2px 5px;
padding: 3px 5px;
color: #333;
border-left: 2px solid #778866;
font-weight: bold;
line-height: 18px;
line-height: 19px;
}
#menu_tab li.nomn_high a {
background: #799E48;
color: #fff;
padding: 2px 10px 2px 10px;
border-left: 2px solid #778866;
font-weight: bold;
line-height: 18px;
}
#menu_tab .mn li a {
display: block;

View File

@ -42,7 +42,7 @@ div#main {
padding-left: 0px;
padding-top: 0px;
padding-bottom: 20px;
margin-left: 180px;
margin-left: 175px;
margin-right: 20px;
}
div#head {
@ -57,8 +57,10 @@ ol.steps {
div#steps_clean {
display:none;
}
div#menu_tab_frame {
#menu_tab_frame, #menu_tab_frame_view {
width: 100%;
padding-right: 28px;
margin-left: -8px;
}
div#events_list {
float: left;

View File

@ -16,25 +16,25 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
echo "
<table cellpadding='3' cellspacing='3'>
echo '
<table cellpadding="3" cellspacing="3">
<tr>
<td class='f9i'>" . print_status_image(STATUS_AGENT_OK, __('All Monitors OK'), true) . __('All Monitors OK') . "</td>
<td class='f9i'>" . print_status_image(STATUS_MODULE_CRITICAL, __('At least one monitor fails'), true) . __('At least one monitor fails') . "</td>
<td class='f9i'>" . print_status_image(STATUS_MODULE_WARNING, __('Change between Green/Red state'), true) . __('Change between Green/Red state') . "</td>
<td class="f9i">' . print_status_image(STATUS_AGENT_OK, __('All Monitors OK'), true) . __('All Monitors OK') . '</td>
<td class="f9i">' . print_status_image(STATUS_MODULE_CRITICAL, __('At least one monitor fails'), true) . __('At least one monitor fails') . '</td>
<td class="f9i">' . print_status_image(STATUS_MODULE_WARNING, __('Change between Green/Red state'), true) . __('Change between Green/Red state') . '</td>
<td class='f9i'>" . print_status_image(STATUS_ALERT_FIRED, __('Alert fired'), true) . __('Alert fired') . "</td>
<td class='f9i'>" . print_status_image(STATUS_ALERT_DISABLED, __('Alert disabled'), true) . __('Alerts disabled') . "</td>
<td class="f9i">' . print_status_image(STATUS_ALERT_FIRED, __('Alert fired'), true) . __('Alert fired') . '</td>
<td class="f9i">' . print_status_image(STATUS_ALERT_DISABLED, __('Alert disabled'), true) . __('Alerts disabled') . '</td>
<tr>
</tr><tr>
<td class='f9i'>" . print_status_image(STATUS_AGENT_NO_MONITORS, __('Agent without monitors'), true) . __('Agent without monitors') . "</td>
<td class='f9i'>" . print_status_image(STATUS_AGENT_NO_DATA, __('Agent without data'), true) . __('Agent without data') . "</td>
<td class='f9i'>" . print_status_image(STATUS_AGENT_DOWN, __('Agent down'), true) . __('Agent down') . "</td>
<td class="f9i">' . print_status_image(STATUS_AGENT_NO_MONITORS, __('Agent without monitors'), true) . __('Agent without monitors') . '</td>
<td class="f9i">' . print_status_image(STATUS_AGENT_NO_DATA, __('Agent without data'), true) . __('Agent without data') . '</td>
<td class="f9i">' . print_status_image(STATUS_AGENT_DOWN, __('Agent down'), true) . __('Agent down') . '</td>
<td class='f9i'>" . print_status_image(STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true) . __('Alert not fired') . "</td>
<td class="f9i">' . print_status_image(STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true) . __('Alert not fired') . '</td>
</tr>
</table>
";
';
?>

View File

@ -18,6 +18,7 @@
// Load global vars
require_once ("include/config.php");
require_once ("include/functions_reporting.php");
check_login ();
if (! give_acl ($config['id_user'], 0, "AR")) {
@ -56,302 +57,141 @@ echo "<h2>".__('Pandora Agents')." &gt; ".__('Summary')."</h2>";
// Show group selector (POST)
if (isset($_POST["ag_group"])){
$ag_group = $_POST["ag_group"];
echo "<form method='post'
action='index.php?sec=estado&sec2=operation/agentes/estado_agente
&refr=60&ag_group_refresh=".$ag_group."'>";
$ag_group = get_parameter_post ("ag_group");
echo '<form method="post" action="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60&amp;ag_group_refresh='.$ag_group.'">';
} else {
echo "<form method='post'
action='index.php?sec=estado&sec2=operation/agentes/estado_agente
&refr=60'>";
echo '<form method="post" action="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60">';
}
echo "<table cellpadding='4' cellspacing='4' class='databox'><tr>";
echo "<td valign='top'>".__('Group')."</td>";
echo "<td valign='top'>";
echo '<table cellpadding="4" cellspacing="4" class="databox">';
echo '<tr><td valign="top">'.__('Group').'</td>';
echo '<td valign="top">';
$groups = get_user_groups ();
print_select ($groups, 'ag_group', $ag_group, 'this.form.submit()', '', '');
echo "<td valign='top'>
<noscript>
<input name='uptbutton' type='submit' class='sub'
value='".__('Show')."'>
</noscript>
</td></form><td valign='top'>";
echo '</td><td valign="top">';
echo __('Free text for search (*)');
echo "</td><td valign='top'>";
echo "<form method='post' action='index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60'>";
echo "<input type=text name='search' value='$search' size='15'>";
echo "</td><td valign='top'>";
echo "<input name='srcbutton' type='submit' class='sub'
value='".__('Search')."'>";
echo "</form>";
echo "</td></table>";
echo __('Free text for search').' (*)';
echo '</td><td valign="top">';
print_input_text ("search", $search, '', 15);
echo '</td><td valign="top">';
print_submit_button (__('Search'), "srcbutton", '', array ("class" => "sub"));
echo "</td></tr></table></form>";
if ($search != ""){
$search_sql = " AND ( nombre LIKE '%$search%' OR comentarios LIKE '%$search%' OR direccion LIKE '%$search%' ) ";
$search_sql = array ("string" => '%'.$search.'%');
} else {
$search_sql = "";
$search_sql = array ();
}
// Show only selected groups
if ($ag_group > 1){
$sql="SELECT * FROM tagente WHERE id_grupo=$ag_group
AND disabled = 0 $search_sql ORDER BY nombre LIMIT $offset, ".$config["block_size"];
$sql2="SELECT COUNT(id_agente) FROM tagente WHERE id_grupo=$ag_group
AND disabled = 0 $search_sql ORDER BY nombre";
if ($ag_group > 1) {
$agent_names = get_group_agents ($ag_group, $search_sql, "upper");
// Not selected any specific group
} else {
// Is admin user ??
if (is_user_admin ($config["id_user"])) {
$sql = "SELECT * FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"];
$sql2 = "SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo";
// standard user
} else {
// User has explicit permission on group 1 ?
$sql = sprintf ("SELECT COUNT(id_grupo) FROM tusuario_perfil WHERE id_usuario='%s' AND id_grupo = 1", $config['id_user']);
$all_group = get_db_sql ($sql);
if ($all_group > 0) {
$sql = sprintf ("SELECT * FROM tagente
WHERE disabled = 0 %s
ORDER BY nombre, id_grupo LIMIT %d,%d",
$search_sql, $offset,
$config["block_size"]);
$sql2 = sprintf ("SELECT COUNT(id_agente)
FROM tagente WHERE disabled = 0 %s
ORDER BY nombre, id_grupo",
$search_sql);
} else {
$sql = sprintf ("SELECT * FROM tagente
WHERE disabled = 0 %s
AND id_grupo IN (SELECT id_grupo
FROM tusuario_perfil
WHERE id_usuario='%s')
ORDER BY nombre, id_grupo LIMIT %d,%d",
$search_sql, $config['id_user'], $offset,
$config["block_size"]);
$sql2 = sprintf ("SELECT COUNT(id_agente)
FROM tagente
WHERE disabled = 0 %s
AND id_grupo IN (SELECT id_grupo
FROM tusuario_perfil
WHERE id_usuario='%s')
ORDER BY nombre, id_grupo",
$search_sql, $config['id_user']);
}
}
$user_group = get_user_groups ($config["id_user"], "AR");
$agent_names = get_group_agents (array_keys ($user_group), $search_sql, "upper");
}
if (!empty ($agent_names)) {
$agents = get_db_all_rows_sql (sprintf ("SELECT * FROM tagente WHERE id_agente IN (%s)", implode (",", array_keys ($agent_names))));
}
if (empty ($agents)) {
$agents = array ();
}
$result2 = mysql_query ($sql2);
$row2 = mysql_fetch_array ($result2);
$total_events = $row2[0];
// Prepare pagination
pagination (count ($agents), "index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=$ag_group&refr=60&search=$search", $offset);
pagination ($total_events,
"index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=$ag_group&refr=60&search=$search",
$offset);
// Show data.
$agents = get_db_all_rows_sql ($sql);
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "90%";
$table->class = "databox";
if ($agents !== false) {
echo "<table cellpadding='4' cellspacing='4' width='700' class='databox' style='margin-top: 10px'>";
echo "<th>".__('Agent')."</th>";
echo "<th>".__('OS')."</th>";
echo "<th>".__('Interval')."</th>";
echo "<th>".__('Group')."</th>";
echo "<th>".__('Modules')."</th>";
echo "<th>".__('Status')."</th>";
echo "<th>".__('Alerts')."</th>";
echo "<th>".__('Last contact')."</th>";
// For every agent defined in the agent table
$color = 1;
foreach ($agents as $agent) {
$intervalo = $agent["intervalo"]; // Interval in seconds
$id_agente = $agent['id_agente'];
$nombre_agente = substr (strtoupper ($agent["nombre"]), 0, 18);
$direccion_agente = $agent["direccion"];
$id_grupo = $agent["id_grupo"];
$id_os = $agent["id_os"];
$ultimo_contacto = $agent["ultimo_contacto"];
$biginterval = $intervalo;
// New check for agent down only based on last contact
$diff_agent_down = get_system_time () - strtotime ($agent["ultimo_contacto"]);
if ($diff_agent_down > $intervalo * 2)
$agent_down = 1;
else
$agent_down = 0;
$belongs = false;
//Verifiy if the group this agent begins is one of the user groups
foreach ($groups as $migrupo) {
if ($migrupo || $id_grupo == $migrupo) {
$belongs = true;
break;
}
}
if (! $belongs)
continue;
$table->head = array ();
$table->head[0] = __('Agent');
$table->head[1] = __('OS');
$table->head[2] = __('Interval');
$table->head[3] = __('Group');
$table->head[4] = __('Modules');
$table->head[5] = __('Status');
$table->head[6] = __('Alerts');
$table->head[7] = __('Last contact');
$table->align = array ();
$table->align[1] = "center";
$table->align[2] = "center";
$table->align[3] = "center";
$table->align[4] = "center";
$table->align[5] = "center";
$table->align[6] = "center";
$table->align[7] = "right";
$table->data = array ();
foreach ($agents as $agent) {
$agent_info = get_agent_module_info ($agent["id_agente"]);
// Obtenemos la lista de todos los modulos de cada agente
$sql = "SELECT * FROM tagente_estado, tagente_modulo
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND
tagente_modulo.disabled = 0
AND tagente_modulo.id_agente=".$id_agente;
$modules = get_db_all_rows_sql ($sql);
if ($modules === false)
$modules = array ();
$numero_modulos = 0;
$est_timestamp = "";
$monitor_normal = 0;
$monitor_warning = 0;
$monitor_critical = 0;
$monitor_down = 0;
$now = get_system_time ();
// Calculate module/monitor totals for this agent
foreach ($modules as $module) {
$numero_modulos ++;
$ultimo_contacto_modulo = $module["timestamp"];
$module_interval = $module["module_interval"];
$module_type = $module["id_tipo_modulo"];
if ($module_interval > $biginterval)
$biginterval = $module_interval;
if ($module_interval != 0)
$intervalo_comp = $module_interval;
else
$intervalo_comp = $intervalo;
if ($ultimo_contacto != "")
$seconds = $now - strtotime ($ultimo_contacto_modulo);
else
$seconds = -1;
if ($module_type < 21 || $module_type != 100) {
$async = 0;
} else {
$async = 1;
}
// Defines if Agent is down (interval x 2 > time last contact
if (($seconds >= ($intervalo_comp * 2)) && ($module_type < 21)) { // If (intervalx2) secs. ago we don't get anything, show alert
if ($async == 0)
$monitor_down++;
} else {
if ($module["estado"] == 2)
$monitor_warning++;
elseif ($module["estado"]== 1)
$monitor_critical++;
else
$monitor_normal++;
}
}
// Color change for each line (1.2 beta2)
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
echo "<tr>";
echo "<td class='$tdcolor'>";
if (give_acl ($config['id_user'], $id_grupo, "AW")) {
echo "<a href='index.php?sec=gagente&amp;
sec2=godmode/agentes/configurar_agente&amp;
id_agente=".$id_agente."'>
<img src='images/setup.png' border=0 width=16></a>&nbsp;";
}
echo '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'"><strong>';
echo $nombre_agente;
echo "</strong></a></td>";
// Show SO icon
echo "<td class='$tdcolor' align='center'>";
print_os_icon ($id_os, false);
echo "</td>";
// If there are a module interval bigger than agent interval
if ($biginterval > $intervalo) {
echo "<td class='$tdcolor'>
<span class='green'>".$biginterval."</span></td>";
} else {
echo "<td class='$tdcolor'>".$intervalo."</td>";
}
// Show GROUP icon
echo '<td class="'.$tdcolor.'" align="center">';
echo "<a href='index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id=$id_grupo'>";
echo print_group_icon ($id_grupo);
//echo '&nbsp;(<b>';
//echo get_group_name ($id_grupo);
//echo "</b>)";
echo "</a>";
echo "<td class='$tdcolor'><b>".$numero_modulos." ";
if ($monitor_normal > 0)
echo " <span class='green'> : ".$monitor_normal." </span>";
if ($monitor_warning > 0)
echo " <span class='yellow'> : ".$monitor_warning." </span>";
if ($monitor_critical > 0)
echo " <span class='red'> : ".$monitor_critical." </span>";
if ($monitor_down > 0)
echo " <span class='grey'> : ".$monitor_down."</span>";
echo "</td>";
$data = array ();
echo "<td class='$tdcolor' align='center'>";
if ($numero_modulos > 0){
if ($agent_down > 0) {
print_status_image(STATUS_AGENT_DOWN, __('Agent down'));
} elseif ($monitor_critical > 0) {
print_status_image(STATUS_AGENT_CRITICAL, __('At least one module in CRITICAL status'));
} elseif ($monitor_warning > 0) {
print_status_image(STATUS_AGENT_WARNING, __('At least one module in WARNING status'));
} else {
print_status_image(STATUS_AGENT_OK, __('All Monitors OK'));
}
} else {
print_status_image(STATUS_AGENT_NO_DATA, __('Agent without data'));
}
// checks if an alert was fired recently
echo "<td class='$tdcolor' align='center'>";
if (give_disabled_group ($id_grupo)) {
print_status_image(STATUS_ALERT_DISABLED, __('Alert disabled'));
} else {
if (check_alert_fired ($id_agente) == 1)
print_status_image(STATUS_ALERT_FIRED, __('Alert fired'));
else
print_status_image(STATUS_ALERT_NOT_FIRED, __('Alert not fired'));
}
echo "</td>";
echo "<td class='$tdcolor'>";
print_timestamp ($ultimo_contacto);
echo "</td>";
$data[0] = '';
if (give_acl ($config['id_user'], $agent["id_grupo"], "AW")) {
$data[0] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$agent["id_agente"].'">';
$data[0] .= print_image ("images/setup.png", true, array ("border" => 0, "width" => 16));
$data[0] .= '</a>&nbsp;';
}
echo "<tr>";
echo "</table><br>";
$data[0] .= print_agent_name ($agent["id_agente"], true, "upper");
$data[1] = print_os_icon ($agent["id_os"], false, true);
if ($agent_info["interval"] > $agent["intervalo"]) {
$data[2] = '<span class="green">'.$agent_info["interval"].'</span>';
} else {
$data[2] = $agent["intervalo"];
}
$data[3] = print_group_icon ($agent["id_grupo"], true);
$data[4] = '<b>';
$data[4] .= $agent_info["modules"];
$data[4] .= '</b> : <span class="green">'.$agent_info["monitor_normal"].'</span>';
$data[4] .= ' : <span class="yellow">'.$agent_info["monitor_warning"].'</span>';
$data[4] .= ' : <span class="red">'.$agent_info["monitor_critical"].'</span>';
$data[4] .= ' : <span class="grey">'.$agent_info["monitor_down"].'</span>';
$data[5] = $agent_info["status_img"];
$data[6] = $agent_info["alert_img"];
$data[7] = print_timestamp ($agent_info["last_contact"], true);
array_push ($table->data, $data);
}
if (!empty ($table->data)) {
print_table ($table);
unset ($table);
require ("bulbs.php");
} else {
echo '</table><br><div class="nf">'.__('There are no agents included in this group').'</div>';
if (give_acl ($config['id_user'], 0, "LM")
|| give_acl ($config['id_user'], 0, "AW")
|| give_acl ($config['id_user'], 0, "PM")
|| give_acl ($config['id_user'], 0, "DM")
|| give_acl ($config['id_user'], 0, "UM")) {
echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente">';
print_input_hidden ('new_agent', 1);
print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"');
echo '</form>';
}
echo '<div class="nf">'.__('There are no agents included in this group').'</div>';
}
if (give_acl ($config['id_user'], 0, "LM") || give_acl ($config['id_user'], 0, "AW")
|| give_acl ($config['id_user'], 0, "PM") || give_acl ($config['id_user'], 0, "DM")
|| give_acl ($config['id_user'], 0, "UM")) {
echo '<form method="post" action="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente">';
print_input_hidden ('new_agent', 1);
print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"');
echo '</form>';
}
?>

View File

@ -51,7 +51,7 @@ echo "<h2>".__('Pandora Agents')." &gt; ".__('Tactical view')."</h2>";
$data = get_group_stats ();
echo '<div style="width:160px; float:left; padding-right: 20px;" id="leftcolumn">';
echo '<div style="width:20%; float:left; padding-right: 5%;" id="leftcolumn">';
// Monitor checks
$table->width = "100%";
@ -69,19 +69,19 @@ $table->style[0] = "padding-top:4px; padding-bottom:4px;";
$table->data[0][0] ='<b>'.__('Monitor health').'</b>';
$table->style[1] = "padding-top:4px; padding-bottom:4px;";
$table->data[1][0] = print_image ($img.$data["monitor_health"], true, array ("title" => $data["monitor_health"].'% '.__('of monitors up')));
$table->data[1][0] = print_image ($img.$data["monitor_health"], true, array ("width" => '100%', "height" => 20, "title" => $data["monitor_health"].'% '.__('of monitors up')));
$table->style[2] = "padding-top:4px; padding-bottom:4px;";
$table->data[2][0] = '<b>'.__('Module sanity').'</b>';
$table->style[3] = "padding-top:4px; padding-bottom:4px;";
$table->data[3][0] = print_image ($img.$data["module_sanity"], true, array ("title" => $data["module_sanity"].'% '.__('of total modules inited')));
$table->data[3][0] = print_image ($img.$data["module_sanity"], true, array ("width" => '100%', "height" => 20, "title" => $data["module_sanity"].'% '.__('of total modules inited')));
$table->style[4] = "padding-top:4px; padding-bottom:4px;";
$table->data[4][0] = '<b>'.__('Alert level').'</b>';
$table->style[5] = "padding-top:4px; padding-bottom:4px;";
$table->data[5][0] = print_image ($img.$data["alert_level"], true, array ("title" => $data["alert_level"].'% '.__('of defined alerts not fired')));
$table->data[5][0] = print_image ($img.$data["alert_level"], true, array ("width" => '100%', "height" => 20, "title" => $data["alert_level"].'% '.__('of defined alerts not fired')));
print_table ($table);
unset ($table);
@ -150,7 +150,7 @@ print_cells_temp ($cells);
echo "</table>";
echo '</div>'; //Left column
echo '<div style="width: 570px; float:left;" id="rightcolumn">';
echo '<div style="width: 75%; float:left;" id="rightcolumn">';
// Server information
@ -205,7 +205,7 @@ if (!empty ($table->data)) {
}
unset ($table);
print_events_table ("", 10, 570);
print_events_table ("", 10, "100%");
echo '</div>';
?>