2013-03-04 Sergio Martin <sergio.martin@artica.es>
* include/functions_alerts.php: Update the fired counts on validate alerts function * include/functions_events.php include/functions_reporting.php include/javascript/jquery.pandora.js include/functions_treeview.php operation/tree.php operation/agentes/estado_generalagente.php operation/agentes/estado_agente.php operation/search_agents.php: Improve and unify code of the status counts in agents list, agent detail, tree view and search views * ajax.php: Load the user language in the ajax entry point. Until now the language was the general! git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7769 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c28bd6b165
commit
95e9d43fde
|
@ -1,3 +1,23 @@
|
|||
2013-03-04 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_alerts.php: Update the fired
|
||||
counts on validate alerts function
|
||||
|
||||
* include/functions_events.php
|
||||
include/functions_reporting.php
|
||||
include/javascript/jquery.pandora.js
|
||||
include/functions_treeview.php
|
||||
operation/tree.php
|
||||
operation/agentes/estado_generalagente.php
|
||||
operation/agentes/estado_agente.php
|
||||
operation/search_agents.php: Improve and unify code
|
||||
of the status counts in agents list, agent detail,
|
||||
tree view and search views
|
||||
|
||||
* ajax.php: Load the user language in the
|
||||
ajax entry point. Until now the language was the
|
||||
general!
|
||||
|
||||
2013-03-01 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_graph.php
|
||||
|
|
|
@ -67,10 +67,20 @@ $isFunctionSkins = enterprise_include_once ('include/functions_skins.php');
|
|||
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK)
|
||||
$config["relative_path"] = enterprise_hook('skins_set_image_skin_path',array($config['id_user']));
|
||||
|
||||
// Load user language
|
||||
$user_language = get_user_language ($config['id_user']);
|
||||
|
||||
$l10n = NULL;
|
||||
if (file_exists ('./include/languages/'.$user_language.'.mo')) {
|
||||
$l10n = new gettext_reader (new CachedFileReader ('./include/languages/'.$user_language.'.mo'));
|
||||
$l10n->load_tables();
|
||||
}
|
||||
|
||||
// Not cool way of know if we are executing from metaconsole or normal console
|
||||
if (strpos($_SERVER['HTTP_REFERER'], ENTERPRISE_DIR . '/meta/') !== false)
|
||||
define ('METACONSOLE', true);
|
||||
session_write_close ();
|
||||
|
||||
if (file_exists ($page)) {
|
||||
require_once ($page);
|
||||
}
|
||||
|
|
|
@ -1157,6 +1157,9 @@ function alerts_validate_alert_agent_module ($id_alert_agent_module, $noACLs = f
|
|||
array ('times_fired' => 0,
|
||||
'internal_counter' => 0),
|
||||
array ('id' => $id));
|
||||
|
||||
// Update fired alert count on the agent
|
||||
db_process_sql(sprintf('UPDATE tagente SET fired_count=fired_count-1 WHERE id_agente = %d', $agent_id));
|
||||
|
||||
if ($result > 0) {
|
||||
events_create_event ("Manual validation of alert for ".
|
||||
|
|
|
@ -693,38 +693,6 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0, $id_use
|
|||
return (int) db_process_sql ($sql, "insert_id");
|
||||
}
|
||||
|
||||
/**
|
||||
* Print tiny statistics of an agent
|
||||
*
|
||||
* @param integer number of total modules
|
||||
* @param integer number of normal modules
|
||||
* @param integer number of critical modules
|
||||
* @param integer number of warning modules
|
||||
* @param integer number of unknown modules
|
||||
* @param bool return or echo flag
|
||||
*
|
||||
*/
|
||||
function events_tiny_stats ($total_modules, $normal_modules, $critical_modules, $warning_modules, $unknown_modules, $return = false) {
|
||||
$out = '<b>' . $total_modules;
|
||||
if ($critical_modules > 0)
|
||||
$out .= ' : <span class="red">' . $critical_modules . '</span>';
|
||||
if ($warning_modules > 0)
|
||||
$out .= ' : <span class="yellow">' . $warning_modules . '</span>';
|
||||
if ($unknown_modules > 0)
|
||||
$out .= ' : <span class="grey">' . $unknown_modules . '</span>';
|
||||
if ($normal_modules > 0)
|
||||
$out .= ' : <span class="green">' . $normal_modules . '</span>';
|
||||
|
||||
$out .= '</b>';
|
||||
|
||||
if ($return) {
|
||||
return $out;
|
||||
}
|
||||
else {
|
||||
echo $out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a small event table
|
||||
|
|
|
@ -6607,4 +6607,105 @@ function reporting_get_count_events_validated ($filter, $period = 0,
|
|||
$filter_event_validated, $filter_event_critical,
|
||||
$filter_event_warning, $filter_event_no_validated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print tiny statistics of the status of one agent, group, etc.
|
||||
*
|
||||
* @param mixed Array with the counts of the total modules, normal modules, critical modules, warning modules, unknown modules and fired alerts
|
||||
* @param bool return or echo flag
|
||||
*
|
||||
* @return string html formatted tiny stats of modules/alerts of an agent
|
||||
*/
|
||||
function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent') {
|
||||
$out = '';
|
||||
|
||||
// Depend the type of object, the stats will refer agents, modules...
|
||||
switch($type) {
|
||||
case 'agent':
|
||||
$template_title['total_count'] = __('%d Total modules');
|
||||
$template_title['normal_count'] = __('%d Normal modules');
|
||||
$template_title['critical_count'] = __('%d Critical modules');
|
||||
$template_title['warning_count'] = __('%d Warning modules');
|
||||
$template_title['unknown_count'] = __('%d Unknown modules');
|
||||
$template_title['fired_count'] = __('%d Fired alerts');
|
||||
break;
|
||||
default:
|
||||
$template_title['total_count'] = __('%d Total agents');
|
||||
$template_title['normal_count'] = __('%d Normal agents');
|
||||
$template_title['critical_count'] = __('%d Critical agents');
|
||||
$template_title['warning_count'] = __('%d Warning agents');
|
||||
$template_title['unknown_count'] = __('%d Unknown agents');
|
||||
$template_title['fired_count'] = __('%d Fired agents');
|
||||
break;
|
||||
}
|
||||
|
||||
// Store the counts in a data structure to print hidden divs with titles
|
||||
$stats = array();
|
||||
|
||||
if(isset($counts_info['total_count'])) {
|
||||
$total_count = $counts_info['total_count'];
|
||||
$stats[] = array('name' => 'total_count', 'count' => $total_count, 'title' => sprintf($template_title['total_count'], $total_count));
|
||||
}
|
||||
|
||||
if(isset($counts_info['normal_count'])) {
|
||||
$normal_count = $counts_info['normal_count'];
|
||||
$stats[] = array('name' => 'normal_count', 'count' => $normal_count, 'title' => sprintf($template_title['normal_count'], $normal_count));
|
||||
}
|
||||
|
||||
if(isset($counts_info['critical_count'])) {
|
||||
$critical_count = $counts_info['critical_count'];
|
||||
$stats[] = array('name' => 'critical_count', 'count' => $critical_count, 'title' => sprintf($template_title['critical_count'], $critical_count));
|
||||
}
|
||||
|
||||
if(isset($counts_info['warning_count'])) {
|
||||
$warning_count = $counts_info['warning_count'];
|
||||
$stats[] = array('name' => 'warning_count', 'count' => $warning_count, 'title' => sprintf($template_title['warning_count'], $warning_count));
|
||||
}
|
||||
|
||||
if(isset($counts_info['unknown_count'])) {
|
||||
$unknown_count = $counts_info['unknown_count'];
|
||||
$stats[] = array('name' => 'unknown_count', 'count' => $unknown_count, 'title' => sprintf($template_title['unknown_count'], $unknown_count));
|
||||
}
|
||||
|
||||
if(isset($counts_info['fired_count'])) {
|
||||
$fired_count = $counts_info['fired_count'];
|
||||
$stats[] = array('name' => 'fired_count', 'count' => $fired_count, 'title' => sprintf($template_title['total_count'], $fired_count));
|
||||
}
|
||||
|
||||
$uniq_id = uniqid();
|
||||
|
||||
foreach($stats as $stat) {
|
||||
$params = array('id' => 'forced_title_' . $stat['name'] . '_' . $uniq_id,
|
||||
'class' => 'forced_title_layer',
|
||||
'content' => $stat['title'],
|
||||
'hidden' => true);
|
||||
$out .= html_print_div($params, true);
|
||||
}
|
||||
|
||||
// If total count is less than 0, is an error. Never show negative numbers
|
||||
if($total_count < 0) {
|
||||
$total_count = 0;
|
||||
}
|
||||
|
||||
$out .= '<b>' . '<span id="total_count_' . $uniq_id . '" class="forced_title">' . $total_count . '</span>';
|
||||
if (isset($fired_count) && $fired_count > 0)
|
||||
$out .= ' : <span class="orange forced_title" id="fired_count_' . $uniq_id . '">' . $fired_count . '</span>';
|
||||
if (isset($critical_count) && $critical_count > 0)
|
||||
$out .= ' : <span class="red forced_title" id="critical_count_' . $uniq_id . '">' . $critical_count . '</span>';
|
||||
if (isset($warning_counts) && $warning_count > 0)
|
||||
$out .= ' : <span class="yellow forced_title" id="warning_count_' . $uniq_id . '">' . $warning_count . '</span>';
|
||||
if (isset($unknown_count) && $unknown_count > 0)
|
||||
$out .= ' : <span class="grey forced_title" id="unknown_count_' . $uniq_id . '">' . $unknown_count . '</span>';
|
||||
if (isset($normal_count) && $normal_count > 0)
|
||||
$out .= ' : <span class="green forced_title" id="normal_count_' . $uniq_id . '">' . $normal_count . '</span>';
|
||||
|
||||
$out .= '</b>';
|
||||
|
||||
if ($return) {
|
||||
return $out;
|
||||
}
|
||||
else {
|
||||
echo $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -441,13 +441,20 @@ function treeview_printTree($type) {
|
|||
else {
|
||||
$id = $item['_id_'];
|
||||
}
|
||||
|
||||
echo "<a onfocus='JavaScript: this.blur()' href='javascript: loadSubTree(\"" . $type . "\",\"" . $id . "\", " . $lessBranchs . ", \"\", \"\")'>";
|
||||
|
||||
echo $img . $item['_iconImg_'] ." " . __($item['_name_']) . ' ('.
|
||||
'<span class="green">'.'<b>'.$item['_num_ok_'].'</b>'.'</span>'.
|
||||
' : <span class="red">'.$item['_num_critical_'].'</span>' .
|
||||
' : <span class="yellow">'.$item['_num_warning_'].'</span>'.
|
||||
' : <span class="grey">'.$item['_num_unknown_'].'</span>'.') '. "</a>";
|
||||
echo $img . $item['_iconImg_'] ." " . __($item['_name_']) . ' (';
|
||||
|
||||
$counts_info = array('total_count' => $item['_num_ok_'] + $item['_num_critical_'] + $item['_num_warning_'] + $item['_num_unknown_'],
|
||||
'normal_count' => $item['_num_ok_'],
|
||||
'critical_count' => $item['_num_critical_'],
|
||||
'warning_count' => $item['_num_warning_'],
|
||||
'unknown_count' => $item['_num_unknown_']);
|
||||
|
||||
reporting_tiny_stats($counts_info, false, $type);
|
||||
|
||||
echo ') '. "</a>";
|
||||
|
||||
echo "<div hiddenDiv='1' loadDiv='0' style='margin: 0px; padding: 0px;' class='tree_view' id='tree_div_" . $type . "_" . $id . "'></div>";
|
||||
echo "</li>\n";
|
||||
|
|
|
@ -168,9 +168,13 @@ $(document).ready (function () {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
forced_title_callback();
|
||||
});
|
||||
|
||||
function forced_title_callback() {
|
||||
// Forced title code
|
||||
$('IMG.forced_title').hover(function() {
|
||||
$('.forced_title').hover(function() {
|
||||
///////////////////////////////////////////
|
||||
// Get info of the image
|
||||
///////////////////////////////////////////
|
||||
|
@ -225,4 +229,4 @@ $(document).ready (function () {
|
|||
function () {
|
||||
$('#forced_title_layer').hide().empty();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -455,20 +455,7 @@ foreach ($agents as $agent) {
|
|||
|
||||
$data[4] = ui_print_group_icon ($agent["id_grupo"], true);
|
||||
|
||||
$data[5] = '<b>';
|
||||
$data[5] .= $agent["total_count"];
|
||||
|
||||
if ($agent["fired_count"] > 0)
|
||||
$data[5] .= ' : <span class="orange">' . $agent["fired_count"] . '</span>';
|
||||
if ($agent["critical_count"] > 0)
|
||||
$data[5] .= ' : <span class="red">' . $agent["critical_count"] . '</span>';
|
||||
if ($agent["warning_count"] > 0)
|
||||
$data[5] .= ' : <span class="yellow">' . $agent["warning_count"] . '</span>';
|
||||
if ($agent["unknown_count"] > 0)
|
||||
$data[5] .= ' : <span class="grey">' . $agent["unknown_count"] . '</span>';
|
||||
if ($agent["normal_count"] > 0)
|
||||
$data[5] .= ' : <span class="green">' . $agent["normal_count"] . '</span>';
|
||||
$data[5] .= '</b>';
|
||||
$data[5] = reporting_tiny_stats($agent, true);
|
||||
|
||||
$data[6] = $status_img;
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ $data[0] .= $agent_name;
|
|||
|
||||
$status_img = agents_tree_view_status_img ($agent["critical_count"],
|
||||
$agent["warning_count"], $agent["unknown_count"]);
|
||||
$data[1] = events_tiny_stats ($agent['total_count'], $agent['normal_count'], $agent['critical_count'], $agent['warning_count'], $agent['unknown_count'], true);
|
||||
$data[1] = reporting_tiny_stats ($agent, true);
|
||||
$data[2] = str_replace('.png' ,'_ball.png', $status_img);
|
||||
|
||||
$table_agent->data[] = $data;
|
||||
|
|
|
@ -245,17 +245,14 @@ else {
|
|||
foreach ($agents as $agent) {
|
||||
$agent_info = reporting_get_agent_module_info ($agent["id_agente"]);
|
||||
|
||||
$modulesCell = '<b>'. $agent_info["modules"] . '</b>';
|
||||
if ($agent_info["monitor_alertsfired"] > 0)
|
||||
$modulesCell .= ' : <span class="orange">'.$agent_info["monitor_alertsfired"].'</span>';
|
||||
if ($agent_info["monitor_normal"] > 0)
|
||||
$modulesCell .= '</b> : <span class="green">'.$agent_info["monitor_normal"].'</span>';
|
||||
if ($agent_info["monitor_warning"] > 0)
|
||||
$modulesCell .= ' : <span class="yellow">'.$agent_info["monitor_warning"].'</span>';
|
||||
if ($agent_info["monitor_critical"] > 0)
|
||||
$modulesCell .= ' : <span class="red">'.$agent_info["monitor_critical"].'</span>';
|
||||
if ($agent_info["monitor_unknown"] > 0)
|
||||
$modulesCell .= ' : <span class="grey">'.$agent_info["monitor_unknown"].'</span>';
|
||||
$counts_info = array('total_count' => $agent_info["modules"],
|
||||
'normal_count' => $agent_info["monitor_normal"],
|
||||
'critical_count' => $agent_info["monitor_critical"],
|
||||
'warning_count' => $agent_info["monitor_warning"],
|
||||
'unknown_count' => $agent_info["monitor_unknown"],
|
||||
'fired_count' => $agent_info["monitor_alertsfired"]);
|
||||
|
||||
$modulesCell = reporting_tiny_stats($counts_info, true);
|
||||
|
||||
if ($agent['disabled']) {
|
||||
$cellName = "<em>" . ui_print_agent_name ($agent["id_agente"], true, "text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . "</em>";
|
||||
|
|
|
@ -238,21 +238,7 @@ if (is_ajax ())
|
|||
|
||||
echo $row["nombre"];
|
||||
|
||||
echo " (";
|
||||
echo '<b>';
|
||||
echo $agent_info["modules"];
|
||||
echo '</b>';
|
||||
if ($agent_info["monitor_alertsfired"] > 0)
|
||||
echo ' : <span class="orange">'.$agent_info["monitor_alertsfired"].'</span>';
|
||||
if ($agent_info["monitor_critical"] > 0)
|
||||
echo ' : <span class="red">'.$agent_info["monitor_critical"].'</span>';
|
||||
if ($agent_info["monitor_warning"] > 0)
|
||||
echo ' : <span class="yellow">'.$agent_info["monitor_warning"].'</span>';
|
||||
if ($agent_info["monitor_unknown"] > 0)
|
||||
echo ' : <span class="grey">'.$agent_info["monitor_unknown"].'</span>';
|
||||
if ($agent_info["monitor_normal"] > 0)
|
||||
echo ' : <span class="green">'.$agent_info["monitor_normal"].'</span>';
|
||||
echo ")";
|
||||
echo " (" . reporting_tiny_stats($row, true) . ")";
|
||||
|
||||
if ($row['quiet']) {
|
||||
echo " ";
|
||||
|
@ -687,6 +673,9 @@ treeview_printTree($activeTab);
|
|||
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddendiv',0);
|
||||
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 1);
|
||||
}
|
||||
|
||||
// Refresh forced title callback to work with html code created dinamicly
|
||||
forced_title_callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue