Minor fixes and solve issues with module templates

This commit is contained in:
Jose Gonzalez 2023-01-11 13:02:18 +01:00
parent 4cb5055488
commit 118099cd24
4 changed files with 137 additions and 191 deletions

View File

@ -1,20 +1,35 @@
<?php <?php
/**
* Agent Modules Templates.
*
* @category Module
* @package Pandora FMS
* @subpackage Agent Configuration
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config; global $config;
// Load global vars // Load global vars.
if (!isset($id_agente)) { if (isset($id_agente) === false) {
die('Not Authorized'); die('Not Authorized');
} }
@ -23,8 +38,8 @@ require_once $config['homedir'].'/include/functions_modules.php';
// ========================== // ==========================
// TEMPLATE ASSIGMENT LOGIC // TEMPLATE ASSIGMENT LOGIC
// ========================== // ==========================
if (isset($_POST['template_id'])) { if (isset($_POST['template_id']) === true) {
// Take agent data // Take agent data.
$row = db_get_row('tagente', 'id_agente', $id_agente); $row = db_get_row('tagente', 'id_agente', $id_agente);
if ($row !== false) { if ($row !== false) {
$intervalo = $row['intervalo']; $intervalo = $row['intervalo'];
@ -49,7 +64,8 @@ if (isset($_POST['template_id'])) {
$npc = []; $npc = [];
} }
$success_count = $error_count = 0; $success_count = 0;
$error_count = 0;
$modules_already_added = []; $modules_already_added = [];
foreach ($npc as $row) { foreach ($npc as $row) {
@ -60,7 +76,7 @@ if (isset($_POST['template_id'])) {
} }
foreach ($nc as $row2) { foreach ($nc as $row2) {
// Insert each module from tnetwork_component into agent // Insert each module from tnetwork_component into agent.
$values = [ $values = [
'id_agente' => $id_agente, 'id_agente' => $id_agente,
'id_tipo_modulo' => $row2['type'], 'id_tipo_modulo' => $row2['type'],
@ -113,14 +129,14 @@ if (isset($_POST['template_id'])) {
$name = $row2['name']; $name = $row2['name'];
// Put tags in array if the component has to add them later // Put tags in array if the component has to add them later.
if (!empty($row2['tags'])) { if (empty($row2['tags']) === false) {
$tags = explode(',', $row2['tags']); $tags = explode(',', $row2['tags']);
} else { } else {
$tags = []; $tags = [];
} }
// Check if this module exists in the agent // Check if this module exists in the agent.
$module_name_check = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['delete_pending' => 0, 'nombre' => $name, 'id_agente' => $id_agente]); $module_name_check = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['delete_pending' => 0, 'nombre' => $name, 'id_agente' => $id_agente]);
if ($module_name_check !== false) { if ($module_name_check !== false) {
@ -132,13 +148,13 @@ if (isset($_POST['template_id'])) {
if ($id_agente_modulo === false) { if ($id_agente_modulo === false) {
$error_count++; $error_count++;
} else { } else {
if (!empty($tags)) { if (empty($tags) === false) {
// Creating tags // Creating tags.
$tag_ids = []; $tag_ids = [];
foreach ($tags as $tag_name) { foreach ($tags as $tag_name) {
$tag_id = tags_get_id($tag_name); $tag_id = tags_get_id($tag_name);
// If tag exists in the system we store to create it // If tag exists in the system we store to create it.
$tag_ids[] = $tag_id; $tag_ids[] = $tag_id;
} }
@ -152,7 +168,7 @@ if (isset($_POST['template_id'])) {
} }
if ($error_count > 0) { if ($error_count > 0) {
if (empty($modules_already_added)) { if (empty($modules_already_added) === true) {
ui_print_error_message(__('Error adding modules').sprintf(' (%s)', $error_count)); ui_print_error_message(__('Error adding modules').sprintf(' (%s)', $error_count));
} else { } else {
ui_print_error_message(__('Error adding modules. The following errors already exists: ').implode(', ', $modules_already_added)); ui_print_error_message(__('Error adding modules. The following errors already exists: ').implode(', ', $modules_already_added));
@ -168,7 +184,7 @@ if (isset($_POST['template_id'])) {
// ========================== // ==========================
// TEMPLATE ASSIGMENT FORM // TEMPLATE ASSIGMENT FORM
// ========================== // ==========================
echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=template&id_agente='.$id_agente.'">'; echo '<form style="margin: 10px" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=template&id_agente='.$id_agente.'">';
$nps = db_get_all_fields_in_table('tnetwork_profile', 'name'); $nps = db_get_all_fields_in_table('tnetwork_profile', 'name');
if ($nps === false) { if ($nps === false) {
@ -194,7 +210,7 @@ html_print_div(
false, false,
[ [
'icon' => 'wand', 'icon' => 'wand',
'mode' => 'mini', 'mode' => 'secondary mini',
], ],
true true
), ),
@ -209,35 +225,20 @@ echo '</form>';
// ========================== // ==========================
// MODULE VISUALIZATION TABLE // MODULE VISUALIZATION TABLE
// ========================== // ==========================
switch ($config['dbtype']) { $sql = sprintf(
case 'mysql': 'SELECT *
case 'postgresql': FROM tagente_modulo
$sql = sprintf( WHERE id_agente = %d AND delete_pending = false
'SELECT * ORDER BY id_module_group, nombre',
FROM tagente_modulo $id_agente
WHERE id_agente = %d AND delete_pending = false );
ORDER BY id_module_group, nombre',
$id_agente
);
break;
case 'oracle':
$sql = sprintf(
'SELECT *
FROM tagente_modulo
WHERE id_agente = %d
AND (delete_pending <> 1 AND delete_pending IS NOT NULL)
ORDER BY id_module_group, dbms_lob.substr(nombre,4000,1)',
$id_agente
);
break;
}
$result = db_get_all_rows_sql($sql); $result = db_get_all_rows_sql($sql);
if ($result === false) { if ($result === false) {
$result = []; $result = [];
} }
$table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->cellpadding = 0; $table->cellpadding = 0;
$table->cellspacing = 0; $table->cellspacing = 0;
@ -246,10 +247,10 @@ $table->head = [];
$table->data = []; $table->data = [];
$table->align = []; $table->align = [];
$table->head[0] = __('Module name'); $table->head[0] = '<span>'.__('Module name').'</span>';
$table->head[1] = __('Type'); $table->head[1] = '<span>'.__('Type').'</span>';
$table->head[2] = __('Description'); $table->head[2] = '<span>'.__('Description').'</span>';
$table->head[3] = __('Action'); $table->head[3] = '<span>'.__('Action').'</span>';
$table->align[1] = 'left'; $table->align[1] = 'left';
$table->align[3] = 'left'; $table->align[3] = 'left';
@ -258,25 +259,35 @@ $table->size[1] = '5%';
$table->size[3] = '8%'; $table->size[3] = '8%';
foreach ($result as $row) { foreach ($result as $row) {
$table->cellclass[][3] = 'table_action_buttons';
$data = []; $data = [];
$data[0] = '<span>'.$row['nombre']; $data[0] = '<span>'.$row['nombre'];
if ($row['id_tipo_modulo'] > 0) { $data[1] = ($row['id_tipo_modulo'] > 0) ? ui_print_moduletype_icon($row['id_tipo_modulo'], true, false, true) : '';
$data[1] = html_print_image('images/'.modules_show_icon_type($row['id_tipo_modulo']), true, ['border' => '0', 'class' => 'invert_filter']);
} else {
$data[1] = '';
}
$data[2] = mb_substr($row['descripcion'], 0, 60); $data[2] = mb_substr($row['descripcion'], 0, 60);
$data[3] = html_print_menu_button(
$table->cellclass[][3] = 'table_action_buttons'; [
$data[3] = '<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&tab=template&id_agente='.$id_agente.'&delete_module='.$row['id_agente_modulo'].'">'.html_print_image('images/cross.png', true, ['class' => 'invert_filter', 'border' => '0', 'alt' => __('Delete'), 'onclick' => "if (!confirm('".__('Are you sure?')."')) return false;"]).'</a>'; 'href' => 'index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&tab=template&id_agente='.$id_agente.'&delete_module='.$row['id_agente_modulo'],
$data[3] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&edit_module=1&id_agent_module='.$row['id_agente_modulo'].'">'.html_print_image('images/config.png', true, ['class' => 'invert_filter', 'border' => '0', 'alt' => __('Update')]).'</a>'; 'image' => 'images/delete.svg',
'title' => __('Delete'),
'onClick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;',
],
true
);
$data[3] .= html_print_menu_button(
[
'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&edit_module=1&id_agent_module='.$row['id_agente_modulo'],
'image' => 'images/edit.svg',
'title' => __('Edit'),
],
true
);
array_push($table->data, $data); array_push($table->data, $data);
} }
if (!empty($table->data)) { if (empty($table->data) === false) {
html_print_table($table); html_print_table($table);
unset($table); unset($table);
} else { } else {

View File

@ -55,26 +55,25 @@ $sec2 = (string) get_parameter('sec2');
$filterTable = new stdClass(); $filterTable = new stdClass();
$filterTable->class = 'fixed_filter_bar'; $filterTable->class = 'fixed_filter_bar';
$filterTable->data = []; $filterTable->data = [];
$filterTable->cellstyle[0][0] = 'flex: 0 1 20%;align-items: center;'; $filterTable->cellstyle[0][0] = 'width:0';
$filterTable->data[0][0] = html_print_div([ 'content' => __('Search') ], true); $filterTable->data[0][0] = __('Search');
$filterTable->data[0][0] .= html_print_input_text( $filterTable->data[1][0] .= html_print_input_text(
'search_string', 'search_string',
$search_string, $search_string,
'', '',
0, 30,
255, 255,
true, true,
false, false,
false, false,
'', '',
'w100p' ''
); );
$filterTable->data[0][0] .= html_print_input_hidden('search', 1, true); $filterTable->data[0][0] .= html_print_input_hidden('search', 1, true);
if ((bool) $policy_page === false) { if ((bool) $policy_page === false) {
$filterTable->cellstyle[0][1] = 'flex: 0 1 20%'; $filterTable->data[0][1] = __('Show in hierachy mode');
$filterTable->data[0][1] = html_print_div([ 'content' => __('Show in hierachy mode') ], true); $filterTable->data[1][1] = html_print_checkbox_switch(
$filterTable->data[0][1] .= html_print_checkbox_switch(
'status_hierachy_mode', 'status_hierachy_mode',
'', '',
((string) $checked === 'true'), ((string) $checked === 'true'),
@ -84,8 +83,7 @@ if ((bool) $policy_page === false) {
); );
} }
$filterTable->cellstyle[0][2] = 'flex: 0 1 60%; justify-content: flex-end;'; $filterTable->data[1][2] = html_print_submit_button(
$filterTable->data[0][2] .= html_print_submit_button(
__('Filter'), __('Filter'),
'filter', 'filter',
false, false,
@ -782,7 +780,7 @@ $url_interval = $url.'&sort_field=interval&sort=';
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->class = 'info_table'; $table->class = 'tactical_table info_table';
$table->head = []; $table->head = [];
$table->head['checkbox'] = html_print_checkbox( $table->head['checkbox'] = html_print_checkbox(
'all_delete', 'all_delete',
@ -791,7 +789,7 @@ $table->head['checkbox'] = html_print_checkbox(
true, true,
false false
); );
$table->head[0] = __('Name').ui_get_sorting_arrows( $table->head[0] = '<span>'.__('Name').'</span>'.ui_get_sorting_arrows(
$url_name.'up', $url_name.'up',
$url_name.'down', $url_name.'down',
$selectNameUp, $selectNameUp,
@ -799,40 +797,42 @@ $table->head[0] = __('Name').ui_get_sorting_arrows(
); );
// The access to the policy is granted only with AW permission. // The access to the policy is granted only with AW permission.
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && check_acl( if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && (bool) check_acl(
$config['id_user'], $config['id_user'],
$agent['id_grupo'], $agent['id_grupo'],
'AW' 'AW'
) ) === true
) { ) {
$table->head[1] = "<span title='".__('Policy')."'>".__('P.').'</span>'; $table->head[1] = "<span title='".__('Policy')."'>".__('P').'</span>';
$table->headstyle[1] = 'width: 4%';
} }
$table->head[2] = "<span title='".__('Server')."'>".__('S.').'</span>'.ui_get_sorting_arrows( $table->head[2] = '<span title=\''.__('Server').'\'>'.__('S').'</span>'.ui_get_sorting_arrows(
$url_server.'up', $url_server.'up',
$url_server.'down', $url_server.'down',
$selectServerUp, $selectServerUp,
$selectServerDown $selectServerDown
); );
$table->head[3] = __('Type').ui_get_sorting_arrows( $table->headstyle[2] = 'width: 8%';
$table->head[3] = '<span>'.__('Type').'</span>'.ui_get_sorting_arrows(
$url_type.'up', $url_type.'up',
$url_type.'down', $url_type.'down',
$selectTypeUp, $selectTypeUp,
$selectTypeDown $selectTypeDown
); );
$table->head[4] = __('Interval').ui_get_sorting_arrows( $table->headstyle[3] = 'width: 10%';
$table->head[4] = '<span>'.__('Interval').'</span>'.ui_get_sorting_arrows(
$url_interval.'up', $url_interval.'up',
$url_interval.'down', $url_interval.'down',
$selectIntervalUp, $selectIntervalUp,
$selectIntervalDown $selectIntervalDown
); );
$table->head[5] = __('Description'); $table->headstyle[4] = 'width: 100px';
$table->head[6] = __('Status'); $table->head[5] = '<span>'.__('Description').'</span>';
$table->head[7] = __('Warn'); $table->head[6] = '<span>'.__('Status').'</span>';
$table->head[7] = '<span>'.__('Warn').'</span>';
$table->head[8] = '<span>'.__('Action').'</span>';
$table->head[8] = __('Action'); $table->headstyle[8] = 'width: 15%';
$table->head[9] = '<span title="'.__('Delete').'">'.__('Del.').'</span>';
$table->rowstyle = []; $table->rowstyle = [];
$table->style = []; $table->style = [];
@ -860,7 +860,7 @@ foreach ($tempRows as $row) {
$numericModules[$row['id_tipo']] = true; $numericModules[$row['id_tipo']] = true;
} }
if ($checked) { if ($checked === true) {
$modules_hierachy = []; $modules_hierachy = [];
$modules_hierachy = get_hierachy_modules_tree($modules); $modules_hierachy = get_hierachy_modules_tree($modules);
@ -892,13 +892,13 @@ foreach ($modules as $module) {
$module_interval2 = $module['module_interval']; $module_interval2 = $module['module_interval'];
$module_group2 = $module['id_module_group']; $module_group2 = $module['id_module_group'];
if ($module['id_modulo'] == MODULE_DATA && $module['id_policy_module'] != 0) { if ((int) $module['id_modulo'] === MODULE_DATA && (int) $module['id_policy_module'] !== 0) {
$nombre_modulo = utf8_decode($module['nombre']); $nombre_modulo = utf8_decode($module['nombre']);
} }
$data = []; $data = [];
if (!$checked) { if ($checked === false) {
if ($module['id_module_group'] != $last_modulegroup) { if ($module['id_module_group'] != $last_modulegroup) {
$last_modulegroup = $module['id_module_group']; $last_modulegroup = $module['id_module_group'];
$data[0] = '<strong>'.modules_get_modulegroup_name( $data[0] = '<strong>'.modules_get_modulegroup_name(
@ -917,7 +917,7 @@ foreach ($modules as $module) {
} }
} }
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) {
$data['checkbox'] = html_print_checkbox( $data['checkbox'] = html_print_checkbox(
'id_delete[]', 'id_delete[]',
$module['id_agente_modulo'], $module['id_agente_modulo'],
@ -931,7 +931,7 @@ foreach ($modules as $module) {
$data[0] = ''; $data[0] = '';
if (isset($module['deep']) && ($module['deep'] != 0)) { if (isset($module['deep']) === true && ((int) $module['deep'] !== 0)) {
$data[0] .= str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $module['deep']); $data[0] .= str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $module['deep']);
$data[0] .= html_print_image( $data[0] .= html_print_image(
'images/icono_escuadra.png', 'images/icono_escuadra.png',
@ -943,7 +943,7 @@ foreach ($modules as $module) {
).'&nbsp;&nbsp;'; ).'&nbsp;&nbsp;';
} }
if ($module['quiet']) { if ((bool) $module['quiet'] === true) {
$data[0] .= html_print_image( $data[0] .= html_print_image(
'images/dot_blue.png', 'images/dot_blue.png',
true, true,
@ -955,11 +955,11 @@ foreach ($modules as $module) {
).'&nbsp;'; ).'&nbsp;';
} }
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) {
$data[0] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&edit_module=1&id_agent_module='.$module['id_agente_modulo'].'">'; $data[0] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&edit_module=1&id_agent_module='.$module['id_agente_modulo'].'">';
} }
if ($module['disabled']) { if ((bool) $module['disabled'] === true) {
$dt_disabled_icon = ''; $dt_disabled_icon = '';
$in_planned_downtime = db_get_sql( $in_planned_downtime = db_get_sql(
@ -999,30 +999,26 @@ foreach ($modules as $module) {
); );
} }
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) {
$data[0] .= '</a>'; $data[0] .= '</a>';
} }
// The access to the policy is granted only with AW permission. // The access to the policy is granted only with AW permission.
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && check_acl( if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && (bool) check_acl(
$config['id_user'], $config['id_user'],
$agent['id_grupo'], $agent['id_grupo'],
'AW' 'AW'
) ) === true
) { ) {
$policyInfo = policies_info_module_policy($module['id_agente_modulo']); $policyInfo = policies_info_module_policy($module['id_agente_modulo']);
if ($policyInfo === false) { if ($policyInfo === false) {
$data[1] = ''; $data[1] = '';
} else { } else {
$linked = policies_is_module_linked($module['id_agente_modulo']); $linked = policies_is_module_linked($module['id_agente_modulo']);
$adopt = policies_is_module_adopt($module['id_agente_modulo']);
$adopt = false; if ($linked !== false) {
if (policies_is_module_adopt($module['id_agente_modulo'])) { if ($adopt === true) {
$adopt = true;
}
if ($linked) {
if ($adopt) {
$img = 'images/policies_brick.png'; $img = 'images/policies_brick.png';
$title = '('.__('Adopted').') '.$policyInfo['name_policy']; $title = '('.__('Adopted').') '.$policyInfo['name_policy'];
} else { } else {
@ -1030,7 +1026,7 @@ foreach ($modules as $module) {
$title = $policyInfo['name_policy']; $title = $policyInfo['name_policy'];
} }
} else { } else {
if ($adopt) { if ($adopt === true) {
$img = 'images/policies_not_brick.png'; $img = 'images/policies_not_brick.png';
$title = '('.__('Unlinked').') ('.__('Adopted').') '.$policyInfo['name_policy']; $title = '('.__('Unlinked').') ('.__('Adopted').') '.$policyInfo['name_policy'];
} else { } else {
@ -1064,7 +1060,7 @@ foreach ($modules as $module) {
); );
// This module is initialized ? (has real data). // This module is initialized ? (has real data).
if ($status == STATUS_MODULE_NO_DATA) { if ($status === STATUS_MODULE_NO_DATA) {
$data[2] .= html_print_image( $data[2] .= html_print_image(
'images/error.png', 'images/error.png',
true, true,
@ -1085,7 +1081,7 @@ foreach ($modules as $module) {
$data[4] = human_time_description_raw($agent_interval); $data[4] = human_time_description_raw($agent_interval);
} }
if ($module['id_modulo'] == MODULE_DATA && $module['id_policy_module'] != 0) { if ((int) $module['id_modulo'] === MODULE_DATA && (int) $module['id_policy_module'] !== 0) {
$data[4] .= ui_print_help_tip( $data[4] .= ui_print_help_tip(
__('The policy modules of data type will only update their intervals when policy is applied.'), __('The policy modules of data type will only update their intervals when policy is applied.'),
true true
@ -1152,32 +1148,6 @@ foreach ($modules as $module) {
); );
// Make a data normalization. // Make a data normalization.
/*
if (isset($numericModules[$type]) === true) {
if ($numericModules[$type] === true) {
$data[8] .= html_print_menu_button(
[
'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&fix_module='.$module['id_agente_modulo'],
'onClick' => "if (!confirm(\' '.__('Are you sure?').'\')) return false;",
'image' => 'images/module-graph.svg',
'title' => __('Normalize'),
'image_class' => (isset($numericModules[$type]) === false || $numericModules[$type] === false) ? 'alpha50' : 'invert_filter main_menu_icon',
],
true
);
}
} else {
$data[8] .= html_print_image(
'images/svg/module-graph.svg',
true,
[
'title' => __('Normalize (Disabled)'),
'image_class' => 'opacity: 0.5;',
]
);
$data[8] .= '&nbsp;&nbsp;';
}
*/
$data[8] .= html_print_menu_button( $data[8] .= html_print_menu_button(
[ [
'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&fix_module='.$module['id_agente_modulo'], 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&fix_module='.$module['id_agente_modulo'],
@ -1191,30 +1161,6 @@ foreach ($modules as $module) {
); );
// Create network component action. // Create network component action.
/*
if ((is_user_admin($config['id_user']) === true)
&& ((int) $module['id_modulo'] === MODULE_NETWORK)
) {
$data[8] .= '<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_network_components&create_network_from_module=1&id_agente='.$id_agente.'&create_module_from='.$module['id_agente_modulo'].'"
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[8] .= html_print_image(
'images/op_network.png',
true,
[
'title' => __('Create network component'),
'class' => 'invert_filter',
]
);
$data[8] .= '</a> ';
} else {
$data[8] .= html_print_image(
'images/network.disabled.png',
true,
['title' => __('Create network component (Disabled)')]
);
$data[8] .= '&nbsp;&nbsp;';
}
*/
$data[8] .= html_print_menu_button( $data[8] .= html_print_menu_button(
[ [
'href' => 'index.php?sec=gmodules&sec2=godmode/modules/manage_network_components&create_network_from_module=1&id_agente='.$id_agente.'&create_module_from='.$module['id_agente_modulo'], 'href' => 'index.php?sec=gmodules&sec2=godmode/modules/manage_network_components&create_network_from_module=1&id_agente='.$id_agente.'&create_module_from='.$module['id_agente_modulo'],
@ -1230,7 +1176,7 @@ foreach ($modules as $module) {
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) { if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) {
// Delete module. // Delete module.
$data[9] = html_print_menu_button( $data[8] .= html_print_menu_button(
[ [
'href' => 'index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$module['id_agente_modulo'], 'href' => 'index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$module['id_agente_modulo'],
'onClick' => "if (!confirm(\' '.__('Are you sure?').'\')) return false;", 'onClick' => "if (!confirm(\' '.__('Are you sure?').'\')) return false;",
@ -1241,15 +1187,10 @@ foreach ($modules as $module) {
); );
} }
$table->cellclass[] = [ // TODO. REVIEW THIS ANNOYING BEHAVIOR.
8 => 'table_action_buttons', $table->cellclass[] = [8 => 'table_action_buttons'];
9 => 'table_action_buttons',
];
array_push($table->data, $data); array_push($table->data, $data);
$table->cellclass[] = [ $table->cellclass[] = [8 => 'table_action_buttons'];
8 => 'table_action_buttons',
9 => 'table_action_buttons',
];
} }
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {

View File

@ -952,10 +952,9 @@ if (check_login()) {
$url_down_status = $url.'&sort_field=status&amp;sort=down&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.' &status_text_monitor='.$status_text_monitor.'&status_module_group= '.$status_module_group; $url_down_status = $url.'&sort_field=status&amp;sort=down&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.' &status_text_monitor='.$status_text_monitor.'&status_module_group= '.$status_module_group;
$url_up_last = $url.'&sort_field=last_contact&amp;sort=up&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.' &status_text_monitor='.$status_text_monitor.'&status_module_group= '.$status_module_group; $url_up_last = $url.'&sort_field=last_contact&amp;sort=up&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.' &status_text_monitor='.$status_text_monitor.'&status_module_group= '.$status_module_group;
$url_down_last = $url.'&sort_field=last_contact&amp;sort=down&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.' &status_text_monitor='.$status_text_monitor.'&status_module_group= '.$status_module_group; $url_down_last = $url.'&sort_field=last_contact&amp;sort=down&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.' &status_text_monitor='.$status_text_monitor.'&status_module_group= '.$status_module_group;
// Enterprise policies functions included.
$isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); $isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
// Table.
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->styleTable = 'border: 0;border-radius: 0;vertical-align: baseline;'; $table->styleTable = 'border: 0;border-radius: 0;vertical-align: baseline;';
@ -1083,12 +1082,10 @@ if (check_login()) {
} }
// Module server type. // Module server type.
// $table->cellstyle[$rowIndex][1] = 'width: 1%;';
$data[1] = ''; $data[1] = '';
$data[1] .= ui_print_servertype_icon((int) $module['id_modulo']); $data[1] .= ui_print_servertype_icon((int) $module['id_modulo']);
// Module name. // Module name.
// $table->cellstyle[$rowIndex][2] = 'width: 1%;';
$data[2] = ''; $data[2] = '';
if (isset($module['deep']) === true && ((int) $module['deep'] !== 0)) { if (isset($module['deep']) === true && ((int) $module['deep'] !== 0)) {
$data[2] .= str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $module['deep']); $data[2] .= str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $module['deep']);
@ -1118,7 +1115,7 @@ if (check_login()) {
} }
// Adds relations context information. // Adds relations context information.
if (modules_relation_exists($module['id_agente_modulo'])) { if (modules_relation_exists($module['id_agente_modulo']) === true) {
$data[2] .= ' <a class="relations_details" href="ajax.php?page=operation/agentes/estado_monitores&get_relations_tooltip=1&id_agente_modulo='.$module['id_agente_modulo'].'">'.html_print_image('images/link2.png', true, ['id' => 'relations-details-'.$module['id_agente_modulo'], 'class' => 'img_help']).'</a> '; $data[2] .= ' <a class="relations_details" href="ajax.php?page=operation/agentes/estado_monitores&get_relations_tooltip=1&id_agente_modulo='.$module['id_agente_modulo'].'">'.html_print_image('images/link2.png', true, ['id' => 'relations-details-'.$module['id_agente_modulo'], 'class' => 'img_help']).'</a> ';
} }
@ -1127,7 +1124,6 @@ if (check_login()) {
$data[3] .= ui_print_string_substr($module['descripcion'], 60, true, 9); $data[3] .= ui_print_string_substr($module['descripcion'], 60, true, 9);
// Module status. // Module status.
// $table->cellstyle[$rowIndex][4] = 'width: 5%;';
$data[4] = ''; $data[4] = '';
if ($module['datos'] !== strip_tags($module['datos'])) { if ($module['datos'] !== strip_tags($module['datos'])) {
$module_value = io_safe_input($module['datos']); $module_value = io_safe_input($module['datos']);
@ -1156,7 +1152,6 @@ if (check_login()) {
} }
// Module thresholds. // Module thresholds.
// $table->cellstyle[$rowIndex][5] = 'width: 10%;';
$data[5] = ''; $data[5] = '';
if ((int) $module['id_tipo_modulo'] !== 25) { if ((int) $module['id_tipo_modulo'] !== 25) {
$data[5] = ui_print_module_warn_value($module['max_warning'], $module['min_warning'], $module['str_warning'], $module['max_critical'], $module['min_critical'], $module['str_critical'], $module['warning_inverse'], $module['critical_inverse'], 'class="font_9pt"'); $data[5] = ui_print_module_warn_value($module['max_warning'], $module['min_warning'], $module['str_warning'], $module['max_critical'], $module['min_critical'], $module['str_critical'], $module['warning_inverse'], $module['critical_inverse'], 'class="font_9pt"');
@ -1165,12 +1160,10 @@ if (check_login()) {
} }
// Module last value. // Module last value.
// $table->cellstyle[$rowIndex][6] = 'width: 10%;';
$data[6] = ''; $data[6] = '';
$data[6] .= '<span class="inherited_text_data_for_humans">'.modules_get_agentmodule_data_for_humans($module).'</span>'; $data[6] .= '<span class="inherited_text_data_for_humans">'.modules_get_agentmodule_data_for_humans($module).'</span>';
// Last contact. // Last contact.
// $table->cellstyle[$rowIndex][7] = 'width: 10%;';
$data[7] = ''; $data[7] = '';
if ((int) $module['estado'] === 3) { if ((int) $module['estado'] === 3) {
$timestampClass = 'redb font_9pt'; $timestampClass = 'redb font_9pt';
@ -1181,7 +1174,6 @@ if (check_login()) {
$data[7] .= ui_print_timestamp($module['utimestamp'], true, ['class' => $timestampClass ]); $data[7] .= ui_print_timestamp($module['utimestamp'], true, ['class' => $timestampClass ]);
// Graph buttons. // Graph buttons.
// $table->cellstyle[$rowIndex][8] = 'width: 100px;';
$data[8] = ''; $data[8] = '';
if ((int) $module['history_data'] === 1) { if ((int) $module['history_data'] === 1) {
if (empty((float) $module['min_warning']) === true if (empty((float) $module['min_warning']) === true
@ -1346,16 +1338,17 @@ if (check_login()) {
/* ]]> */ /* ]]> */
</script> </script>
<?php <?php
if (empty($table->data)) { if (empty($table->data) === true) {
if ($filter_monitors) { ui_print_info_message(
ui_print_info_message([ 'no_close' => true, 'message' => __('Any monitors aren\'t with this filter.') ]); [
} else { 'no_close' => true,
ui_print_info_message([ 'no_close' => true, 'message' => __('This agent doesn\'t have any active monitors.') ]); 'message' => ($filter_monitors === true) ? __('Any monitors aren\'t with this filter.') : __('This agent doesn\'t have any active monitors.'),
} ]
);
} else { } else {
$url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.'&status_text_monitor='.$status_text_monitor.'&status_module_group='.$status_module_group; $url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.'&status_text_monitor='.$status_text_monitor.'&status_module_group='.$status_module_group;
if ($paginate_module) { if ($paginate_module === true) {
ui_pagination( ui_pagination(
$count_modules, $count_modules,
false, false,
@ -1375,7 +1368,7 @@ if (check_login()) {
html_print_table($table); html_print_table($table);
if ($paginate_module) { if ($paginate_module === true) {
ui_pagination( ui_pagination(
$count_modules, $count_modules,
false, false,
@ -1398,7 +1391,7 @@ if (check_login()) {
unset($table_data); unset($table_data);
} }
if ($get_type) { if ($get_type === true) {
$id_module = (int) get_parameter('id_module'); $id_module = (int) get_parameter('id_module');
$module = modules_get_agentmodule($id_module); $module = modules_get_agentmodule($id_module);
$graph_type = return_graphtype($module['id_tipo_modulo']); $graph_type = return_graphtype($module['id_tipo_modulo']);
@ -1652,7 +1645,7 @@ if (check_login()) {
// If not valid it will throw an exception. // If not valid it will throw an exception.
json_decode($response); json_decode($response);
if (json_last_error() == JSON_ERROR_NONE) { if (json_last_error() === JSON_ERROR_NONE) {
// If valid dump. // If valid dump.
echo $response; echo $response;
} else { } else {

View File

@ -10764,6 +10764,7 @@ pre.external_tools_output {
width: -moz-fill-available; width: -moz-fill-available;
} }
/*
.fixed_filter_bar tr { .fixed_filter_bar tr {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -10777,7 +10778,7 @@ pre.external_tools_output {
align-self: center; align-self: center;
justify-content: flex-start; justify-content: flex-start;
} }
*/
.fixed_filter_bar td > div { .fixed_filter_bar td > div {
margin-right: 10px; margin-right: 10px;
font-size: 10pt; font-size: 10pt;