Added feature to filter by module in events.
2014-09-01 Miguel de Dios <miguel.dedios@artica.es> * pandora_console/include/functions_graph.php, pandora_console/operation/events/events.build_query.php, pandora_console/operation/events/events.php, pandora_console/operation/events/events_list.php: added feature to filter by module in events. TICKETS #385
This commit is contained in:
parent
cd853362f2
commit
12abf276ca
|
@ -2110,10 +2110,27 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
|
|||
$loop = 0;
|
||||
define ('NUM_PIECES_PIE', 6);
|
||||
|
||||
$badstrings = array (";", "SELECT ", "DELETE ", "UPDATE ", "INSERT ", "EXEC");
|
||||
|
||||
//Hotfix for the id_agente_modulo
|
||||
$url = str_replace(
|
||||
'SELECT id_agente_modulo', 'SELECT_id_agente_modulo', $url);
|
||||
|
||||
|
||||
$badstrings = array (";",
|
||||
"SELECT ",
|
||||
"DELETE ",
|
||||
"UPDATE ",
|
||||
"INSERT ",
|
||||
"EXEC");
|
||||
//remove bad strings from the query so queries like ; DELETE FROM don't pass
|
||||
$url = str_ireplace ($badstrings, "", $url);
|
||||
|
||||
|
||||
//Hotfix for the id_agente_modulo
|
||||
$url = str_replace(
|
||||
'SELECT_id_agente_modulo', 'SELECT id_agente_modulo', $url);
|
||||
|
||||
|
||||
// Choose the table where search if metaconsole or not
|
||||
if ($meta) {
|
||||
if ($history) {
|
||||
|
@ -2144,7 +2161,8 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
|
|||
FROM '.$event_table.'
|
||||
WHERE 1=1 %s %s
|
||||
GROUP BY id_agente'.$groupby_extra.'
|
||||
ORDER BY count DESC LIMIT 8', $url, $tags_condition);
|
||||
ORDER BY count DESC LIMIT 8', $url, $tags_condition);
|
||||
|
||||
break;
|
||||
case "postgresql":
|
||||
case "oracle":
|
||||
|
|
|
@ -93,8 +93,9 @@ if ($event_type != "") {
|
|||
if ($severity != -1) {
|
||||
switch ($severity) {
|
||||
case EVENT_CRIT_WARNING_OR_CRITICAL:
|
||||
$sql_post .= " AND (criticity = " . EVENT_CRIT_WARNING . " OR
|
||||
criticity = " . EVENT_CRIT_CRITICAL . ")";
|
||||
$sql_post .= "
|
||||
AND (criticity = " . EVENT_CRIT_WARNING . " OR
|
||||
criticity = " . EVENT_CRIT_CRITICAL . ")";
|
||||
break;
|
||||
case EVENT_CRIT_NOT_NORMAL:
|
||||
$sql_post .= " AND criticity != " . EVENT_CRIT_NORMAL;
|
||||
|
@ -123,11 +124,19 @@ else {
|
|||
$sql_post .= " AND id_agente = " . $id_agent;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($id_agent_module) {
|
||||
$sql_post .= " AND id_agentmodule = " . $id_agent_module;
|
||||
if ($meta) {
|
||||
//There is another filter.
|
||||
}
|
||||
else {
|
||||
if (!empty($text_module)) {
|
||||
$sql_post .= ' AND id_agentmodule IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre = "' . $text_module . '"
|
||||
)';
|
||||
}
|
||||
}
|
||||
|
||||
if ($id_user_ack != "0")
|
||||
|
@ -199,7 +208,10 @@ if (($tags_acls_condition != ERR_WRONG_PARAMETERS) && ($tags_acls_condition != E
|
|||
|
||||
// Metaconsole fitlers
|
||||
if ($meta) {
|
||||
$enabled_nodes = db_get_all_rows_sql('SELECT id FROM tmetaconsole_setup WHERE disabled = 0');
|
||||
$enabled_nodes = db_get_all_rows_sql('
|
||||
SELECT id
|
||||
FROM tmetaconsole_setup
|
||||
WHERE disabled = 0');
|
||||
|
||||
if (empty($enabled_nodes)) {
|
||||
$sql_post .= ' AND 1 = 0';
|
||||
|
@ -209,7 +221,8 @@ if ($meta) {
|
|||
foreach ($enabled_nodes as $en) {
|
||||
$enabled_nodes_id[] = $en['id'];
|
||||
}
|
||||
$sql_post .= ' AND server_id IN ('.implode(',',$enabled_nodes_id).')';
|
||||
$sql_post .= ' AND server_id IN (' .
|
||||
implode(',',$enabled_nodes_id) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,6 @@ $event_type = get_parameter ("event_type", ''); // 0 all
|
|||
$severity = (int) get_parameter ("severity", -1); // -1 all
|
||||
$status = (int) get_parameter ("status", 3); // -1 all, 0 only new, 1 only validated, 2 only in process, 3 only not validated,
|
||||
$id_agent = (int) get_parameter ("id_agent", 0);
|
||||
$id_agent_module = (int) get_parameter ("id_agent_module", 0);
|
||||
$pagination = (int) get_parameter ("pagination", $config["block_size"]);
|
||||
$event_view_hr = (int) get_parameter ("event_view_hr", $history ? 0 : $config["event_view_hr"]);
|
||||
$id_user_ack = get_parameter ("id_user_ack", 0);
|
||||
|
@ -202,6 +201,7 @@ $delete = (bool) get_parameter ("delete");
|
|||
$validate = (bool) get_parameter ("validate", 0);
|
||||
$section = (string) get_parameter ("section", "list");
|
||||
$text_agent = (string) get_parameter('text_agent', __("All"));
|
||||
$text_module = (string) get_parameter('module_search', '');
|
||||
$filter_only_alert = (int) get_parameter('filter_only_alert', -1);
|
||||
$filter_id = (int) get_parameter('filter_id', 0);
|
||||
$id_name = (string) get_parameter('id_name', '');
|
||||
|
@ -328,7 +328,7 @@ if ($config["pure"] == 0 || $meta) {
|
|||
'rss' => $rss,
|
||||
'marquee' => $marquee,
|
||||
'csv' => $csv,
|
||||
'sound_event' => $sound_event) ;
|
||||
'sound_event' => $sound_event);
|
||||
}
|
||||
|
||||
// If the history event is not ebabled, dont show the history tab
|
||||
|
|
|
@ -376,6 +376,25 @@ $table_advanced->data[] = $data;
|
|||
$table_advanced->rowclass[] = '';
|
||||
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('User ack.') . '<br>';
|
||||
|
||||
$user_users = users_get_user_users($config['id_user'], "ER", users_can_manage_group_all(0));
|
||||
|
||||
$data[0] .= html_print_select($user_users, "id_user_ack", $id_user_ack, '',
|
||||
__('Any'), 0, true);
|
||||
if (!$meta) {
|
||||
$data[1] = __('Module search') . '<br>';
|
||||
$data[1] .= html_print_autocomplete_modules('module_search',
|
||||
'', false, true, '', array(), true);
|
||||
}
|
||||
else {
|
||||
$data[1] .= '';
|
||||
}
|
||||
|
||||
$table_advanced->data[] = $data;
|
||||
$table_advanced->rowclass[] = '';
|
||||
|
||||
$data = array();
|
||||
$data[0] = __("Alert events") . '<br>';
|
||||
$data[0] .= html_print_select (array('-1' => __('All'), '0' => __('Filter alert events'), '1' => __('Only alert events')), "filter_only_alert", $filter_only_alert, '', '', '', true);
|
||||
|
@ -402,17 +421,6 @@ $data[1] .= html_print_input_text ('date_to', $date_to, '', 15, 10, true);
|
|||
$table_advanced->data[] = $data;
|
||||
$table_advanced->rowclass[] = '';
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('User ack.') . '<br>';
|
||||
|
||||
$user_users = users_get_user_users($config['id_user'], "ER", users_can_manage_group_all(0));
|
||||
|
||||
$data[0] .= html_print_select($user_users, "id_user_ack", $id_user_ack, '',
|
||||
__('Any'), 0, true);
|
||||
$data[1] = '';
|
||||
$table_advanced->data[] = $data;
|
||||
$table_advanced->rowclass[] = '';
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<fieldset class="databox" style="width: 310px;">' .
|
||||
'<legend>' .
|
||||
|
@ -546,7 +554,6 @@ if ($group_rep == 0) {
|
|||
|
||||
//Extract the events by filter (or not) from db
|
||||
$result = db_get_all_rows_sql ($sql);
|
||||
|
||||
}
|
||||
else {
|
||||
$result = events_get_events_grouped(
|
||||
|
@ -557,9 +564,14 @@ else {
|
|||
$history);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($result)) {
|
||||
$graph = '<div style="width: 350px; margin: 0 auto;">' . grafico_eventos_grupo(350, 148, rawurlencode ($sql_post), $meta, $history) . '</div>';
|
||||
html_print_div(array('id' => 'events_graph', 'hidden' => true, 'content' => $graph));
|
||||
$graph = '<div style="width: 350px; margin: 0 auto;">' .
|
||||
grafico_eventos_grupo(350, 148,
|
||||
rawurlencode ($sql_post), $meta, $history) .
|
||||
'</div>';
|
||||
html_print_div(array('id' => 'events_graph',
|
||||
'hidden' => true, 'content' => $graph));
|
||||
}
|
||||
|
||||
// Delete rnum field generated by oracle_recode_query() function
|
||||
|
@ -582,6 +594,7 @@ else {
|
|||
GROUP BY evento, id_agentmodule) AS t";
|
||||
}
|
||||
|
||||
|
||||
$total_events = (int) db_get_sql ($sql);
|
||||
if (empty ($result)) {
|
||||
$result = array ();
|
||||
|
|
Loading…
Reference in New Issue