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
|
$agents_normal_count = "($agent_table
|
||||||
$agent_normal_filter) AS total_normal_count";
|
$agent_normal_filter) AS total_normal_count";
|
||||||
// Not init
|
// Not init
|
||||||
$agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT);
|
|
||||||
$agents_not_init_count = "($agent_table
|
if($this->filter['show_not_init_agents']){
|
||||||
$agent_not_init_filter) AS total_not_init_count";
|
$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
|
// Alerts fired
|
||||||
$agents_fired_count = "($agent_table
|
$agents_fired_count = "($agent_table
|
||||||
AND ta.fired_count > 0) AS total_fired_count";
|
AND ta.fired_count > 0) AS total_fired_count";
|
||||||
|
@ -287,13 +295,19 @@ class Tree {
|
||||||
// Modules join
|
// Modules join
|
||||||
$modules_join = "";
|
$modules_join = "";
|
||||||
$module_status_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
|
$module_status_join = "INNER JOIN tagente_estado tae
|
||||||
ON tam.id_agente_modulo IS NOT NULL
|
ON tam.id_agente_modulo IS NOT NULL
|
||||||
AND tam.id_agente_modulo = tae.id_agente_modulo
|
AND tam.id_agente_modulo = tae.id_agente_modulo
|
||||||
$module_status_filter";
|
$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
|
$modules_join = "INNER JOIN tagente_modulo tam
|
||||||
|
@ -304,8 +318,22 @@ class Tree {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($module_status_join)) {
|
if (empty($module_status_join)) {
|
||||||
$module_status_join = "LEFT JOIN tagente_estado tae
|
if(!$this->filter['show_not_init_modules'] || !$this->filter['show_not_init_agents']){
|
||||||
ON tam.id_agente_modulo = tae.id_agente_modulo";
|
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;
|
$sql = false;
|
||||||
|
@ -407,7 +435,7 @@ class Tree {
|
||||||
else {
|
else {
|
||||||
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
|
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
|
||||||
FROM tagente ta
|
FROM tagente ta
|
||||||
INNER JOIN tagente_modulo tam
|
LEFT JOIN tagente_modulo tam
|
||||||
ON tam.disabled = 0
|
ON tam.disabled = 0
|
||||||
AND ta.id_agente = tam.id_agente
|
AND ta.id_agente = tam.id_agente
|
||||||
$module_search_filter
|
$module_search_filter
|
||||||
|
@ -1161,7 +1189,6 @@ class Tree {
|
||||||
if (!empty($counters)) {
|
if (!empty($counters)) {
|
||||||
$counters = array_pop($counters);
|
$counters = array_pop($counters);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $counters;
|
return $counters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2046,6 +2073,18 @@ class Tree {
|
||||||
$items = $this->getItems();
|
$items = $this->getItems();
|
||||||
$this->processModules($items);
|
$this->processModules($items);
|
||||||
$processed_items = $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 {
|
else {
|
||||||
$items = array();
|
$items = array();
|
||||||
|
@ -2261,6 +2300,18 @@ class Tree {
|
||||||
// Agents
|
// Agents
|
||||||
else {
|
else {
|
||||||
$items = $this->getItems();
|
$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);
|
$this->processAgents($items);
|
||||||
$processed_items = $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_critical_count'] = $group['critical'];
|
||||||
$group_stats[$group['id_group']]['total_unknown_count'] = $group['unknown'];
|
$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_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_normal_count'] = $group['normal'];
|
||||||
$group_stats[$group['id_group']]['total_fired_count'] = $group['alerts_fired'];
|
$group_stats[$group['id_group']]['total_fired_count'] = $group['alerts_fired'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ var TreeController = {
|
||||||
|
|
||||||
// Load branch
|
// Load branch
|
||||||
function _processGroup (container, elements, rootGroup) {
|
function _processGroup (container, elements, rootGroup) {
|
||||||
|
|
||||||
var $group = $("<ul></ul>");
|
var $group = $("<ul></ul>");
|
||||||
|
|
||||||
// First group
|
// First group
|
||||||
|
@ -157,14 +158,15 @@ var TreeController = {
|
||||||
$counters.addClass('tree-node-counters');
|
$counters.addClass('tree-node-counters');
|
||||||
|
|
||||||
if (typeof counters.total != 'undefined'
|
if (typeof counters.total != 'undefined'
|
||||||
&& counters.total > 0) {
|
&& counters.total >= 0) {
|
||||||
var $totalCounter = $("<div></div>");
|
|
||||||
$totalCounter
|
|
||||||
.addClass('tree-node-counter')
|
|
||||||
.addClass('total')
|
|
||||||
.html(counters.total);
|
|
||||||
|
|
||||||
_processNodeCounterTitle($totalCounter, type, "total");
|
var $totalCounter = $("<div></div>");
|
||||||
|
$totalCounter
|
||||||
|
.addClass('tree-node-counter')
|
||||||
|
.addClass('total')
|
||||||
|
.html(counters.total);
|
||||||
|
|
||||||
|
_processNodeCounterTitle($totalCounter, type, "total");
|
||||||
|
|
||||||
// Open the parentheses
|
// Open the parentheses
|
||||||
$counters.append(" (");
|
$counters.append(" (");
|
||||||
|
@ -233,18 +235,18 @@ var TreeController = {
|
||||||
}
|
}
|
||||||
if (typeof counters.not_init != 'undefined'
|
if (typeof counters.not_init != 'undefined'
|
||||||
&& counters.not_init > 0) {
|
&& counters.not_init > 0) {
|
||||||
var $notInitCounter = $("<div></div>");
|
var $notInitCounter = $("<div></div>");
|
||||||
$notInitCounter
|
$notInitCounter
|
||||||
.addClass('tree-node-counter')
|
.addClass('tree-node-counter')
|
||||||
.addClass('not_init')
|
.addClass('not_init')
|
||||||
.addClass('blue')
|
.addClass('blue')
|
||||||
.html(counters.not_init);
|
.html(counters.not_init);
|
||||||
|
|
||||||
_processNodeCounterTitle($notInitCounter, type, "not_init");
|
_processNodeCounterTitle($notInitCounter, type, "not_init");
|
||||||
|
|
||||||
$counters
|
$counters
|
||||||
.append(" : ")
|
.append(" : ")
|
||||||
.append($notInitCounter);
|
.append($notInitCounter);
|
||||||
}
|
}
|
||||||
if (typeof counters.ok != 'undefined'
|
if (typeof counters.ok != 'undefined'
|
||||||
&& counters.ok > 0) {
|
&& counters.ok > 0) {
|
||||||
|
|
|
@ -23,6 +23,8 @@ $search_agent = get_parameter('searchAgent', '');
|
||||||
$status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL);
|
$status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL);
|
||||||
$search_module = get_parameter('searchModule', '');
|
$search_module = get_parameter('searchModule', '');
|
||||||
$status_module = get_parameter('statusModule', -1);
|
$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');
|
$group_id = (int) get_parameter('group_id');
|
||||||
$tag_id = (int) get_parameter('tag_id');
|
$tag_id = (int) get_parameter('tag_id');
|
||||||
$strict_acl = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
|
$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->style[2] = 'font-weight: bold;';
|
||||||
$table->size = array();
|
$table->size = array();
|
||||||
$table->size[0] = '10%';
|
$table->size[0] = '10%';
|
||||||
$table->size[1] = '35%';
|
$table->size[1] = '20%';
|
||||||
$table->size[2] = '9%';
|
$table->size[2] = '10%';
|
||||||
$table->size[3] = '10%';
|
$table->size[3] = '5%';
|
||||||
$table->size[4] = '10%';
|
$table->size[4] = '10%';
|
||||||
// Agent filter
|
// Agent filter
|
||||||
$agent_status_arr = array();
|
$agent_status_arr = array();
|
||||||
|
@ -142,19 +144,30 @@ $agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init');
|
||||||
|
|
||||||
$row = array();
|
$row = array();
|
||||||
$row[] = __('Search group');
|
$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;
|
$table->data[] = $row;
|
||||||
|
|
||||||
$row = array();
|
$row = array();
|
||||||
$row[] = __('Search agent');
|
$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[] = __('Show full hirearchy');
|
||||||
$row[] = html_print_checkbox("serach_hirearchy", $serach_hirearchy, false, true);
|
$row[] = html_print_checkbox("serach_hirearchy", $serach_hirearchy, false, true);
|
||||||
|
|
||||||
$row[] = __('Agent status');
|
$row[] = __('Agent status');
|
||||||
$row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true);
|
$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
|
// Button
|
||||||
$row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true);
|
$row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true);
|
||||||
|
@ -175,6 +188,13 @@ if (!is_metaconsole()) {
|
||||||
$row = array();
|
$row = array();
|
||||||
$row[] = __('Search module');
|
$row[] = __('Search module');
|
||||||
$row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true);
|
$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[] = __('Module status');
|
||||||
$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true);
|
$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true);
|
||||||
|
|
||||||
|
@ -270,6 +290,22 @@ enterprise_hook('close_meta_frame');
|
||||||
parameters['filter']['searchHirearchy'] = 0;
|
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({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
|
Loading…
Reference in New Issue