Filter by not init agents and modules in tree view - #1454
This commit is contained in:
parent
94936a46e9
commit
8d39ae54fa
|
@ -114,9 +114,17 @@ class Tree {
|
|||
$agents_normal_count = "($agent_table
|
||||
$agent_normal_filter) AS total_normal_count";
|
||||
// Not init
|
||||
$agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT);
|
||||
$agents_not_init_count = "($agent_table
|
||||
$agent_not_init_filter) AS total_not_init_count";
|
||||
|
||||
if($this->filter['show_not_init_agents']){
|
||||
$agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT);
|
||||
$agents_not_init_count = "($agent_table
|
||||
$agent_not_init_filter) AS total_not_init_count";
|
||||
}
|
||||
else{
|
||||
$agent_not_init_filter = 0;
|
||||
$agents_not_init_count = 0;
|
||||
}
|
||||
|
||||
// Alerts fired
|
||||
$agents_fired_count = "($agent_table
|
||||
AND ta.fired_count > 0) AS total_fired_count";
|
||||
|
@ -287,13 +295,19 @@ class Tree {
|
|||
// Modules join
|
||||
$modules_join = "";
|
||||
$module_status_join = "";
|
||||
if (!empty($module_search_filter) || !empty($module_status_filter)) {
|
||||
if (!empty($module_search_filter) || !empty($module_status_filter) || !$this->filter['show_not_init_agents']) {
|
||||
|
||||
if (!empty($module_status_filter)) {
|
||||
if (!empty($module_status_filter) || !$this->filter['show_not_init_agents']) {
|
||||
$module_status_join = "INNER JOIN tagente_estado tae
|
||||
ON tam.id_agente_modulo IS NOT NULL
|
||||
AND tam.id_agente_modulo = tae.id_agente_modulo
|
||||
$module_status_filter";
|
||||
|
||||
if(!$this->filter['show_not_init_modules'] || ($this->filter['show_not_init_modules'] && !$this->filter['show_not_init_agents'])){
|
||||
if($type != 'agent' || ($type == 'agent' && !$this->filter['show_not_init_modules'] && !$this->filter['show_not_init_agents'])){
|
||||
$module_status_join .= ' AND tae.estado <> '.AGENT_MODULE_STATUS_NO_DATA.' AND tae.estado <> '.AGENT_MODULE_STATUS_NOT_INIT.' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$modules_join = "INNER JOIN tagente_modulo tam
|
||||
|
@ -304,8 +318,22 @@ class Tree {
|
|||
}
|
||||
|
||||
if (empty($module_status_join)) {
|
||||
$module_status_join = "LEFT JOIN tagente_estado tae
|
||||
ON tam.id_agente_modulo = tae.id_agente_modulo";
|
||||
if(!$this->filter['show_not_init_modules'] || !$this->filter['show_not_init_agents']){
|
||||
if($type == "agent"){
|
||||
$module_status_join = 'INNER JOIN tagente_estado tae
|
||||
ON tam.id_agente_modulo = tae.id_agente_modulo ';
|
||||
}
|
||||
else{
|
||||
$module_status_join = 'LEFT JOIN tagente_estado tae
|
||||
ON tam.id_agente_modulo = tae.id_agente_modulo ';
|
||||
}
|
||||
|
||||
$module_status_join .= ' AND 1=1 AND tae.estado <> '.AGENT_MODULE_STATUS_NO_DATA.' AND tae.estado <> '.AGENT_MODULE_STATUS_NOT_INIT.' ';
|
||||
}
|
||||
else{
|
||||
$module_status_join = 'LEFT JOIN tagente_estado tae
|
||||
ON tam.id_agente_modulo = tae.id_agente_modulo ';
|
||||
}
|
||||
}
|
||||
|
||||
$sql = false;
|
||||
|
@ -407,7 +435,7 @@ class Tree {
|
|||
else {
|
||||
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
|
||||
FROM tagente ta
|
||||
INNER JOIN tagente_modulo tam
|
||||
LEFT JOIN tagente_modulo tam
|
||||
ON tam.disabled = 0
|
||||
AND ta.id_agente = tam.id_agente
|
||||
$module_search_filter
|
||||
|
@ -1161,7 +1189,6 @@ class Tree {
|
|||
if (!empty($counters)) {
|
||||
$counters = array_pop($counters);
|
||||
}
|
||||
|
||||
return $counters;
|
||||
}
|
||||
|
||||
|
@ -2046,6 +2073,18 @@ class Tree {
|
|||
$items = $this->getItems();
|
||||
$this->processModules($items);
|
||||
$processed_items = $items;
|
||||
|
||||
if(!$this->filter['show_not_init_modules']){
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
if($items[$key]['total_count'] != $items[$key]['notinit_count']){
|
||||
$items[$key]['total_count'] = $items[$key]['total_count'] - $items[$key]['notinit_count'];
|
||||
$items[$key]['notinit_count'] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
$items = array();
|
||||
|
@ -2261,6 +2300,18 @@ class Tree {
|
|||
// Agents
|
||||
else {
|
||||
$items = $this->getItems();
|
||||
|
||||
|
||||
if(!$this->filter['show_not_init_modules']){
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
$items[$key]['total_count'] = $items[$key]['total_count'] - $items[$key]['notinit_count'];
|
||||
$items[$key]['notinit_count'] = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->processAgents($items);
|
||||
$processed_items = $items;
|
||||
}
|
||||
|
@ -2733,7 +2784,12 @@ class Tree {
|
|||
$group_stats[$group['id_group']]['total_critical_count'] = $group['critical'];
|
||||
$group_stats[$group['id_group']]['total_unknown_count'] = $group['unknown'];
|
||||
$group_stats[$group['id_group']]['total_warning_count'] = $group['warning'];
|
||||
$group_stats[$group['id_group']]['total_not_init_count'] = $group['non-init'];
|
||||
if($this->filter['show_not_init_modules']){
|
||||
$group_stats[$group['id_group']]['total_not_init_count'] = $group['non-init'];
|
||||
}
|
||||
else{
|
||||
$group_stats[$group['id_group']]['total_not_init_count'] = 0;
|
||||
}
|
||||
$group_stats[$group['id_group']]['total_normal_count'] = $group['normal'];
|
||||
$group_stats[$group['id_group']]['total_fired_count'] = $group['alerts_fired'];
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ var TreeController = {
|
|||
|
||||
// Load branch
|
||||
function _processGroup (container, elements, rootGroup) {
|
||||
|
||||
var $group = $("<ul></ul>");
|
||||
|
||||
// First group
|
||||
|
@ -157,15 +158,16 @@ var TreeController = {
|
|||
$counters.addClass('tree-node-counters');
|
||||
|
||||
if (typeof counters.total != 'undefined'
|
||||
&& counters.total > 0) {
|
||||
var $totalCounter = $("<div></div>");
|
||||
$totalCounter
|
||||
.addClass('tree-node-counter')
|
||||
.addClass('total')
|
||||
.html(counters.total);
|
||||
|
||||
_processNodeCounterTitle($totalCounter, type, "total");
|
||||
&& counters.total >= 0) {
|
||||
|
||||
var $totalCounter = $("<div></div>");
|
||||
$totalCounter
|
||||
.addClass('tree-node-counter')
|
||||
.addClass('total')
|
||||
.html(counters.total);
|
||||
|
||||
_processNodeCounterTitle($totalCounter, type, "total");
|
||||
|
||||
// Open the parentheses
|
||||
$counters.append(" (");
|
||||
|
||||
|
@ -233,18 +235,18 @@ var TreeController = {
|
|||
}
|
||||
if (typeof counters.not_init != 'undefined'
|
||||
&& counters.not_init > 0) {
|
||||
var $notInitCounter = $("<div></div>");
|
||||
$notInitCounter
|
||||
.addClass('tree-node-counter')
|
||||
.addClass('not_init')
|
||||
.addClass('blue')
|
||||
.html(counters.not_init);
|
||||
var $notInitCounter = $("<div></div>");
|
||||
$notInitCounter
|
||||
.addClass('tree-node-counter')
|
||||
.addClass('not_init')
|
||||
.addClass('blue')
|
||||
.html(counters.not_init);
|
||||
|
||||
_processNodeCounterTitle($notInitCounter, type, "not_init");
|
||||
|
||||
$counters
|
||||
.append(" : ")
|
||||
.append($notInitCounter);
|
||||
_processNodeCounterTitle($notInitCounter, type, "not_init");
|
||||
|
||||
$counters
|
||||
.append(" : ")
|
||||
.append($notInitCounter);
|
||||
}
|
||||
if (typeof counters.ok != 'undefined'
|
||||
&& counters.ok > 0) {
|
||||
|
|
|
@ -23,6 +23,8 @@ $search_agent = get_parameter('searchAgent', '');
|
|||
$status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL);
|
||||
$search_module = get_parameter('searchModule', '');
|
||||
$status_module = get_parameter('statusModule', -1);
|
||||
$show_not_init_agents = get_parameter('show_not_init_agents', true);
|
||||
$show_not_init_modules = get_parameter('show_not_init_modules', true);
|
||||
$group_id = (int) get_parameter('group_id');
|
||||
$tag_id = (int) get_parameter('tag_id');
|
||||
$strict_acl = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
|
||||
|
@ -127,9 +129,9 @@ $table->style[0] = 'font-weight: bold;';
|
|||
$table->style[2] = 'font-weight: bold;';
|
||||
$table->size = array();
|
||||
$table->size[0] = '10%';
|
||||
$table->size[1] = '35%';
|
||||
$table->size[2] = '9%';
|
||||
$table->size[3] = '10%';
|
||||
$table->size[1] = '20%';
|
||||
$table->size[2] = '10%';
|
||||
$table->size[3] = '5%';
|
||||
$table->size[4] = '10%';
|
||||
// Agent filter
|
||||
$agent_status_arr = array();
|
||||
|
@ -142,19 +144,30 @@ $agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init');
|
|||
|
||||
$row = array();
|
||||
$row[] = __('Search group');
|
||||
$row[] = html_print_input_text("search_group", $search_group, '', is_metaconsole() ? 70 : 40, 30, true);
|
||||
$row[] = html_print_input_text("search_group", $search_group, '', is_metaconsole() ? 50 : 40, 30, true);
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$row[] = __('Show not init modules');
|
||||
$row[] = html_print_checkbox("show_not_init_modules", $show_not_init_modules, true, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$table->data[] = $row;
|
||||
|
||||
$row = array();
|
||||
$row[] = __('Search agent');
|
||||
$row[] = html_print_input_text("search_agent", $search_agent, '', is_metaconsole() ? 70 : 40, 30, true);
|
||||
$row[] = html_print_input_text("search_agent", $search_agent, '', is_metaconsole() ? 50 : 40, 30, true);
|
||||
|
||||
$row[] = __('Show not init agents');
|
||||
$row[] = html_print_checkbox("show_not_init_agents", $show_not_init_agents, true, true);
|
||||
|
||||
$row[] = __('Show full hirearchy');
|
||||
$row[] = html_print_checkbox("serach_hirearchy", $serach_hirearchy, false, true);
|
||||
|
||||
$row[] = __('Agent status');
|
||||
$row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true);
|
||||
$row[] = html_print_input_hidden('show_not_init_modules_hidden', $show_not_init_modules, true);
|
||||
|
||||
// Button
|
||||
$row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true);
|
||||
|
@ -175,6 +188,13 @@ if (!is_metaconsole()) {
|
|||
$row = array();
|
||||
$row[] = __('Search module');
|
||||
$row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true);
|
||||
|
||||
$row[] = __('Show not init modules');
|
||||
$row[] = html_print_checkbox("show_not_init_modules", $show_not_init_modules, true, true);
|
||||
|
||||
$row[] = '';
|
||||
$row[] = '';
|
||||
|
||||
$row[] = __('Module status');
|
||||
$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true);
|
||||
|
||||
|
@ -269,6 +289,22 @@ enterprise_hook('close_meta_frame');
|
|||
else{
|
||||
parameters['filter']['searchHirearchy'] = 0;
|
||||
}
|
||||
|
||||
if($("#checkbox-show_not_init_agents").is(':checked')){
|
||||
parameters['filter']['show_not_init_agents'] = 1;
|
||||
}
|
||||
else{
|
||||
parameters['filter']['show_not_init_agents'] = 0;
|
||||
}
|
||||
|
||||
if($("#checkbox-show_not_init_modules").is(':checked')){
|
||||
parameters['filter']['show_not_init_modules'] = 1;
|
||||
$('#hidden-show_not_init_modules_hidden').val(1);
|
||||
}
|
||||
else{
|
||||
parameters['filter']['show_not_init_modules'] = 0;
|
||||
$('#hidden-show_not_init_modules_hidden').val(0);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
|
|
Loading…
Reference in New Issue