2014-03-24 Miguel de Dios <miguel.dedios@artica.es>

* godmode/massive/massive_edit_modules.php,
	godmode/massive/massive_edit_agents.php,
	godmode/massive/massive_delete_modules.php,
	godmode/massive/massive_copy_modules.php,
	godmode/groups/group_list.php, operation/agentes/ver_agente.php:
	implement the filter by agent status in the other massive
	operations.
	
	Incident: #669




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9644 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2014-03-25 12:39:26 +00:00
parent 7511dbbf7d
commit b1d644e772
7 changed files with 324 additions and 146 deletions

View File

@ -1,3 +1,15 @@
2014-03-24 Miguel de Dios <miguel.dedios@artica.es>
* godmode/massive/massive_edit_modules.php,
godmode/massive/massive_edit_agents.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_copy_modules.php,
godmode/groups/group_list.php, operation/agentes/ver_agente.php:
implement the filter by agent status in the other massive
operations.
Incident: #669
2014-03-24 Alejandro Gallardo <alejandro.gallardo@artica.es>
* operation/agentes/estado_monitores.php: Fixed an error

View File

@ -94,7 +94,8 @@ if (is_ajax ()) {
$filter['status'] = $status_agents;
}
$agents = agents_get_group_agents($id_group, $filter, "none", false, $recursion);
$agents = agents_get_group_agents($id_group, $filter, "none",
false, $recursion);
// Add keys prefix
if ($keys_prefix !== "") {

View File

@ -61,13 +61,8 @@ $table->data = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold; vertical-align:top';
$table->style[2] = 'font-weight: bold';
$table->size = array ();
$table->size[0] = '10%';
$table->size[1] = '30%';
$table->size[2] = '10%';
$table->size[3] = '10%';
$table->size[4] = '10%';
$table->size[5] = '30%';
$table->style[4] = 'font-weight: bold';
$table->style[6] = 'font-weight: bold';
/* Source selection */
$table->id = 'source_table';
@ -76,11 +71,21 @@ $table->data[0][1] = html_print_select_groups(false, "AR", true, 'source_id_grou
false, '', '', true);
$table->data[0][2] = __('Group recursion');
$table->data[0][3] = html_print_checkbox ("source_recursion", 1, $source_recursion, true, false);
$table->data[0][4] = __('Agent');
$table->data[0][4] .= ' <span id="source_agent_loading" class="invisible">';
$table->data[0][4] .= html_print_image ("images/spinner.png", true);
$table->data[0][4] .= '</span>';
$table->data[0][5] = html_print_select (agents_get_group_agents ($source_id_group, false, "none"),
$status_list = array ();
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_STATUS_WARNING] = __('Warning');
$status_list[AGENT_STATUS_CRITICAL] = __('Critical');
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data[0][4] = __('Status');
$table->data[0][5] = html_print_select($status_list,
'status_agents_source', 'selected', '', __('All'), AGENT_STATUS_ALL, true);
$table->data[0][6] = __('Agent');
$table->data[0][6] .= ' <span id="source_agent_loading" class="invisible">';
$table->data[0][6] .= html_print_image ("images/spinner.png", true);
$table->data[0][6] .= '</span>';
$table->data[0][7] = html_print_select (agents_get_group_agents ($source_id_group, false, "none"),
'source_id_agent', $source_id_agent, false, __('Select'), 0, true);
echo '<form action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=copy_modules" id="manage_config_form" method="post">';
@ -149,6 +154,8 @@ echo '<legend><span>'.__('Targets').'</span></legend>';
html_print_table ($table);
echo '</fieldset>';
/* Destiny selection */
$table->id = 'destiny_table';
$table->data = array ();
@ -157,28 +164,42 @@ $table->size[1] = '30%';
$table->size[2] = '20%';
$table->size[3] = '30%';
$table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select ($groups, 'destiny_id_group', $destiny_id_group,
false, '', '', true);
$table->data[0][1] = html_print_select ($groups, 'destiny_id_group',
$destiny_id_group, false, '', '', true);
$table->data[0][2] = __('Group recursion');
$table->data[0][3] = html_print_checkbox ("destiny_recursion", 1, $destiny_recursion, true, false);
$table->data[1][0] = __('Agent');
$table->data[1][0] .= '<span id="destiny_agent_loading" class="invisible">';
$table->data[1][0] .= html_print_image ("images/spinner.png", true);
$table->data[1][0] .= '</span>';
$table->data[1][1] = html_print_select (agents_get_group_agents ($destiny_id_group, false, "none"),
$table->data[0][3] = html_print_checkbox ("destiny_recursion", 1,
$destiny_recursion, true, false);
$status_list = array ();
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_STATUS_WARNING] = __('Warning');
$status_list[AGENT_STATUS_CRITICAL] = __('Critical');
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data[1][0] = __('Status');
$table->data[1][1] = html_print_select($status_list,
'status_agents_destiny', 'selected', '', __('All'), AGENT_STATUS_ALL, true);
$table->data[2][0] = __('Agent');
$table->data[2][0] .= '<span id="destiny_agent_loading" class="invisible">';
$table->data[2][0] .= html_print_image ("images/spinner.png", true);
$table->data[2][0] .= '</span>';
$table->data[2][1] = html_print_select (agents_get_group_agents ($destiny_id_group, false, "none"),
'destiny_id_agent[]', 0, false, '', '', true, true);
echo '<fieldset id="fieldset_destiny"'.($source_id_agent ? '' : ' class="invisible"').'>';
echo '<legend><span>'.__('To agent(s)').'</span></legend>';
echo '<fieldset id="fieldset_destiny"' .
($source_id_agent ? '' : ' class="invisible"') . '>';
echo '<legend><span>' . __('To agent(s)') . '</span></legend>';
html_print_table ($table);
echo '</fieldset>';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<div class="action-buttons" style="width: ' . $table->width . '">';
html_print_input_hidden ('do_operation', 1);
html_print_submit_button (__('Copy'), 'go', false, 'class="sub wand"');
echo '</div>';
echo '</form>';
echo '<h3 class="error invisible" id="message">&nbsp;</h3>';
ui_require_jquery_file ('form');
@ -196,10 +217,19 @@ $(document).ready (function () {
$("#source_id_group").pandoraSelectGroupAgent ({
agentSelect: "select#source_id_agent",
recursion: function() {return source_recursion},
recursion: function() {
return source_recursion
},
status_agents: function () {
return $("#status_agents_source").val();
},
loading: "#source_agent_loading"
});
$("#status_agents_source").change(function() {
$("#source_id_group").trigger("change");
});
var destiny_recursion;
$("#checkbox-destiny_recursion").click(function () {
destiny_recursion = this.checked ? 1 : 0;
@ -209,6 +239,9 @@ $(document).ready (function () {
$("#destiny_id_group").pandoraSelectGroupAgent ({
agentSelect: "select#destiny_id_agent",
recursion: function() {return destiny_recursion},
status_agents: function () {
return $("#status_agents_destiny").val();
},
loading: "#destiny_agent_loading",
callbackPost: function (id, value, option) {
if ($("#source_id_agent").fieldValue ().in_array (id)) {
@ -218,6 +251,10 @@ $(document).ready (function () {
}
});
$("#status_agents_destiny").change(function() {
$("#destiny_id_group").trigger("change");
});
$("#source_id_agent").change (function () {
var id_agent = this.value;
if (id_agent == 0) {

View File

@ -197,7 +197,8 @@ if ($delete) {
$groups = users_get_groups ();
$agents = agents_get_group_agents (array_keys (users_get_groups ()), false, "none");
$agents = agents_get_group_agents (array_keys (users_get_groups ()),
false, "none");
switch ($config["dbtype"]) {
case "mysql":
case "oracle":
@ -212,11 +213,11 @@ switch ($config["dbtype"]) {
case "postgresql":
$module_types = db_get_all_rows_filter ('tagente_modulo,ttipo_modulo',
array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo',
'id_agente' => array_keys ($agents),
'disabled' => 0,
'order' => 'description'),
'id_agente' => array_keys ($agents),
'disabled' => 0,
'order' => 'description'),
array ('DISTINCT(id_tipo)',
'ttipo_modulo.descripcion || \' (\' || ttipo_modulo.nombre || \')\' AS description'));
'ttipo_modulo.descripcion || \' (\' || ttipo_modulo.nombre || \')\' AS description'));
break;
}
@ -231,23 +232,33 @@ foreach ($module_types as $type) {
$table->width = '99%';
$table->data = array ();
$table->style[2] = 'font-weight: bold';
$table->data[0][0] = __('Selection mode');
$table->data[0][1] = __('Select modules first').' '.html_print_radio_button_extended ("selection_mode", 'modules', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->data[0][2] = '';
$table->data[0][3] = __('Select agents first').' '.html_print_radio_button_extended ("selection_mode", 'agents', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->rowclass[1] = 'select_modules_row';
$table->data[1][0] = __('Module type');
$table->data[1][0] .= '<span id="module_loading" class="invisible">';
$table->data[1][0] .= html_print_image('images/spinner.png', true);
$table->data[1][0] .= '</span>';
$table->data['selection_mode'][0] = __('Selection mode');
$table->data['selection_mode'][1] = __('Select modules first') . ' ' .
html_print_radio_button_extended ("selection_mode", 'modules', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->data['selection_mode'][2] = '';
$table->data['selection_mode'][3] = __('Select agents first') . ' ' .
html_print_radio_button_extended ("selection_mode", 'agents', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->rowclass['form_modules_1'] = 'select_modules_row';
$table->data['form_modules_1'][0] = __('Module type');
$table->data['form_modules_1'][0] .= '<span id="module_loading" class="invisible">';
$table->data['form_modules_1'][0] .= html_print_image('images/spinner.png', true);
$table->data['form_modules_1'][0] .= '</span>';
$types[0] = __('All');
$table->colspan[1][1] = 2;
$table->data[1][1] = html_print_select ($types,
'module_type', '', false, __('Select'), -1, true, false, true, '', false, 'width:100%');
$table->colspan['form_modules_1'][1] = 2;
$table->data['form_modules_1'][1] = html_print_select ($types, 'module_type', '',
false, __('Select'), -1, true, false, true, '', false,
'width:100%');
$table->data['form_modules_1'][3] = __('Select all modules of this type') . ' ' .
html_print_checkbox_extended("force_type", 'type', '', '', false,
'', 'style="margin-right: 40px;"', true);
$table->data[1][3] = __('Select all modules of this type').' '.html_print_checkbox_extended ("force_type", 'type', '', '', false, '', 'style="margin-right: 40px;"', true);
$modules = array ();
if ($module_type != '') {
@ -263,43 +274,68 @@ foreach ($names as $name) {
$modules[$name['nombre']] = $name['nombre'];
}
$table->rowclass[2] = 'select_agents_row';
$table->data[2][0] = __('Agent group');
$table->rowclass['form_agents_1'] = 'select_agents_row';
$table->data['form_agents_1'][0] = __('Agent group');
$groups = groups_get_all(true);
$groups[0] = __('All');
$table->colspan[2][1] = 2;
$table->data[2][1] = html_print_select ($groups, 'groups_select',
$table->colspan['form_agents_1'][1] = 2;
$table->data['form_agents_1'][1] = html_print_select ($groups, 'groups_select',
'', true, __('Select'), -1, true, false, true, '', false, 'width:100%').
' ' . __('Group recursion') . ' ' . html_print_checkbox ("recursion", 1, false, true, false);
$table->data[2][3] = __('Select all modules of this group').' '.html_print_checkbox_extended ("force_group", 'group', '', '', false, '', 'style="margin-right: 40px;"', true);
' ' . __('Group recursion') . ' ' .
html_print_checkbox ("recursion", 1, false, true, false);
$table->data['form_agents_1'][3] = __('Select all modules of this group') . ' ' .
html_print_checkbox_extended ("force_group", 'group', '', '', false,
'', 'style="margin-right: 40px;"', true);
$table->rowstyle[3] = 'vertical-align: top;';
$table->rowclass[3] = 'select_modules_row select_modules_row_2';
$table->data[3][0] = __('Modules');
$table->data[3][1] = html_print_select ($modules, 'module_name[]',
$table->rowclass['form_agents_2'] = 'select_agents_row';
$table->data['form_agents_2'][0] = __('Status');
$table->colspan['form_agents_2'][1] = 2;
$status_list = array ();
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_STATUS_WARNING] = __('Warning');
$status_list[AGENT_STATUS_CRITICAL] = __('Critical');
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data['form_agents_2'][1] = html_print_select($status_list,
'status_agents', 'selected', '', __('All'), AGENT_STATUS_ALL, true);
$table->data['form_agents_2'][3] = '';
$table->rowstyle['form_modules_2'] = 'vertical-align: top;';
$table->rowclass['form_modules_2'] = 'select_modules_row select_modules_row_2';
$table->data['form_modules_2'][0] = __('Modules');
$table->data['form_modules_2'][1] = html_print_select ($modules, 'module_name[]',
$module_name, false, __('Select'), -1, true, true, true, '', false, 'width:100%');
$table->data[3][2] = __('When select modules');
$table->data[3][2] .= '<br>';
$table->data[3][2] .= html_print_select (array('common' => __('Show common agents'), 'all' => __('Show all agents')), 'agents_selection_mode',
$table->data['form_modules_2'][2] = __('When select modules');
$table->data['form_modules_2'][2] .= '<br>';
$table->data['form_modules_2'][2] .= html_print_select(
array('common' => __('Show common agents'),
'all' => __('Show all agents')), 'agents_selection_mode',
'common', false, '', '', true, false, true, '', false);
$table->data[3][3] = html_print_select (array(), 'agents[]',
$table->data['form_modules_2'][3] = html_print_select (array(), 'agents[]',
$agents_select, false, __('None'), 0, true, true, false, '', false, 'width:100%');
$table->rowstyle[4] = 'vertical-align: top;';
$table->rowclass[4] = 'select_agents_row select_agents_row_2';
$table->data[4][0] = __('Agents');
$table->data[4][1] = html_print_select ($agents, 'id_agents[]',
$table->rowstyle['form_agents_3'] = 'vertical-align: top;';
$table->rowclass['form_agents_3'] = 'select_agents_row select_agents_row_2';
$table->data['form_agents_3'][0] = __('Agents');
$table->data['form_agents_3'][1] = html_print_select ($agents, 'id_agents[]',
$agents_id, false, '', '', true, true, false, '', false, 'width:100%');
$table->data[4][2] = __('When select agents');
$table->data[4][2] .= '<br>';
$table->data[4][2] .= html_print_select (array('common' => __('Show common modules'), 'all' => __('Show all modules')), 'modules_selection_mode',
$table->data['form_agents_3'][2] = __('When select agents');
$table->data['form_agents_3'][2] .= '<br>';
$table->data['form_agents_3'][2] .= html_print_select (array('common' => __('Show common modules'), 'all' => __('Show all modules')), 'modules_selection_mode',
'common', false, '', '', true);
$table->data[4][3] = html_print_select (array(), 'module[]',
$table->data['form_agents_3'][3] = html_print_select (array(), 'module[]',
$modules_select, false, '', '', true, true, false, '', false, 'width:100%');
echo '<form method="post" id="form_modules" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_modules" >';
html_print_table ($table);
@ -332,8 +368,10 @@ $(document).ready (function () {
clean_lists();
$(".select_modules_row").css('display', '<?php echo $modules_row?>');
$(".select_agents_row").css('display', '<?php echo $agents_row?>');
$(".select_modules_row")
.css('display', '<?php echo $modules_row?>');
$(".select_agents_row")
.css('display', '<?php echo $agents_row?>');
// Trigger change to refresh selection when change selection mode
$("#agents_selection_mode").change (function() {
@ -357,7 +395,8 @@ $(document).ready (function () {
$(".select_modules_row_2").css('display', '');
}
$("tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit35, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7, tr#delete_table-edit8").hide ();
$("tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit35, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7, tr#delete_table-edit8")
.hide ();
if (this.value == '0') {
filter = '';
@ -372,17 +411,19 @@ $(document).ready (function () {
$("#module_name option[value!=0]").remove ();
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
"get_agent_modules_json" : 1,
"filter" : filter,
"fields" : "DISTINCT(nombre)",
"indexed" : 0
"get_agent_modules_json" : 1,
"filter" : filter,
"fields" : "DISTINCT(nombre)",
"indexed" : 0
},
function (data, status) {
jQuery.each (data, function (id, value) {
option = $("<option></option>").attr ("value", value["nombre"]).html (value["nombre"]);
option = $("<option></option>")
.attr("value", value["nombre"])
.html(value["nombre"]);
$("#module_name").append (option);
});
$("#module_loading").hide ();
$("#module_loading").hide();
$("#module_name").removeAttr ("disabled");
},
"json"
@ -418,7 +459,7 @@ $(document).ready (function () {
$("#groups_select").trigger("change");
}
else {
if(this.checked) {
if (this.checked) {
$(".select_agents_row_2").css('display', 'none');
}
else {
@ -432,11 +473,11 @@ $(document).ready (function () {
selector = this.value;
clean_lists();
if(selector == 'agents') {
if (selector == 'agents') {
$(".select_modules_row").css('display', 'none');
$(".select_agents_row").css('display', '');
}
else if(selector == 'modules') {
else if (selector == 'modules') {
$(".select_agents_row").css('display', 'none');
$(".select_modules_row").css('display', '');
}
@ -459,11 +500,15 @@ $(document).ready (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"recursion" : $("#checkbox-recursion").attr ("checked") ? 1 : 0,
"id_group" : this.value,
// Add a key prefix to avoid auto sorting in js object conversion
"keys_prefix" : "_"
"get_agents_group_json" : 1,
"recursion" : $("#checkbox-recursion")
.attr("checked") ? 1 : 0,
"id_group" : this.value,
status_agents: function () {
return $("#status_agents").val();
},
// Add a key prefix to avoid auto sorting in js object conversion
"keys_prefix" : "_"
},
function (data, status) {
$("#id_agents").html('');
@ -471,7 +516,9 @@ $(document).ready (function () {
// Remove keys_prefix from the index
id = id.substring(1);
option = $("<option></option>").attr ("value", value["id_agente"]).html (value["nombre"]);
option = $("<option></option>")
.attr ("value", value["id_agente"])
.html (value["nombre"]);
$("#id_agents").append (option);
});
},
@ -479,6 +526,10 @@ $(document).ready (function () {
);
}
);
$("#status_agents").change(function() {
$("#groups_select").trigger("change");
});
});
/* ]]> */
</script>

View File

@ -36,7 +36,7 @@ if (is_ajax ()) {
if ($get_n_conf_files) {
$id_agents = get_parameter('id_agents');
$cont = 0;
foreach($id_agents as $id_agent) {
foreach ($id_agents as $id_agent) {
$name = agents_get_name($id_agent);
$agent_md5 = md5($name);
if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5"))
@ -47,8 +47,8 @@ if (is_ajax ()) {
}
}
$update_agents = get_parameter ('update_agents', 0);
$recursion = get_parameter ('recursion');
$update_agents = get_parameter('update_agents', 0);
$recursion = get_parameter('recursion');
if ($update_agents) {
$values = array();
@ -59,7 +59,7 @@ if ($update_agents) {
if (get_parameter ('id_os', '') != -1)
$values['id_os'] = get_parameter ('id_os');
if (get_parameter ('id_parent', '') != '')
$values['id_parent'] = agents_get_agent_id(get_parameter ('id_parent'));
$values['id_parent'] = agents_get_agent_id(get_parameter('id_parent'));
if (get_parameter ('server_name', '') != -1)
$values['server_name'] = get_parameter ('server_name');
if (get_parameter ('description', '') != '')
@ -103,8 +103,10 @@ if ($update_agents) {
$n_deleted = 0;
foreach ($id_agents as $id_agent) {
$agent_md5 = md5(agents_get_name($id_agent));
@unlink ($config["remote_config"]."/md5/".$agent_md5.".md5");
$result = @unlink ($config["remote_config"]."/conf/".$agent_md5.".conf");
@unlink($config["remote_config"] .
"/md5/" . $agent_md5 . ".md5");
$result = @unlink($config["remote_config"] .
"/conf/" . $agent_md5 . ".conf");
$n_deleted += (int)$result;
}
@ -119,7 +121,7 @@ if ($update_agents) {
ui_print_result_message ($n_deleted > 0,
__('Configuration files deleted successfully').'('.$n_deleted.')',
__('Configuration files deleted successfully') . '(' . $n_deleted . ')',
__('Configuration files cannot be deleted'));
}
@ -138,16 +140,18 @@ if ($update_agents) {
// Update Custom Fields
foreach ($fields as $field) {
if (get_parameter_post ('customvalue_'.$field['id_field'], '') != '') {
if (get_parameter_post ('customvalue_' . $field['id_field'], '') != '') {
$key = $field['id_field'];
$value = get_parameter_post ('customvalue_'.$field['id_field'], '');
$value = get_parameter_post ('customvalue_' . $field['id_field'], '');
$old_value = db_get_all_rows_filter('tagent_custom_data', array('id_agent' => $id_agent, 'id_field' => $key));
if ($old_value === false) {
// Create custom field if not exist
$result = db_process_sql_insert ('tagent_custom_data',
array('id_field' => $key,'id_agent' => $id_agent, 'description' => $value));
array('id_field' => $key,
'id_agent' => $id_agent,
'description' => $value));
}
else {
$result = db_process_sql_update ('tagent_custom_data',
@ -172,7 +176,7 @@ if ($update_agents) {
ui_print_result_message ($result !== false,
__('Agents updated successfully').'('.$n_edited.')',
__('Agents updated successfully') . '(' . $n_edited . ')',
__('Agents cannot be updated'));
}
$id_group = 0;
@ -193,10 +197,11 @@ $table->size[3] = '35%';
$table->data = array ();
$table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group,
false, '', '', true);
$table->data[0][1] = html_print_select_groups(false, "AR", true,
'id_group', $id_group, false, '', '', true);
$table->data[0][2] = __('Group recursion');
$table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, true, false);
$table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion,
true, false);
$status_list = array ();

View File

@ -77,7 +77,7 @@ if ($update) {
if ($force == 'type') {
$condition = '';
if ($module_type != 0)
$condition = ' AND t2.id_tipo_modulo = '.$module_type;
$condition = ' AND t2.id_tipo_modulo = ' . $module_type;
$agents_ = db_get_all_rows_sql('
SELECT DISTINCT(t1.id_agente)
@ -103,9 +103,11 @@ if ($update) {
}
}
else if ($force == 'group') {
$agents_ = array_keys (agents_get_group_agents ($group_select, false, "none"));
$agents_ = array_keys(agents_get_group_agents($group_select,
false, "none"));
foreach ($agents_ as $id_agent) {
$module_name = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent),'nombre');
$module_name = db_get_all_rows_filter('tagente_modulo',
array('id_agente' => $id_agent),'nombre');
if ($module_name == false) {
$module_name = array();
}
@ -210,22 +212,30 @@ $snmp_versions['3'] = 'v. 3';
$table->width = '99%';
$table->data = array ();
$table->data[0][0] = __('Selection mode');
$table->data[0][1] = __('Select modules first').' '.html_print_radio_button_extended ("selection_mode", 'modules', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->data[0][2] = '';
$table->data[0][3] = __('Select agents first').' '.html_print_radio_button_extended ("selection_mode", 'agents', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->rowclass[1] = 'select_modules_row';
$table->data[1][0] = __('Module type');
$table->data[1][0] .= '<span id="module_loading" class="invisible">';
$table->data[1][0] .= html_print_image('images/spinner.png', true);
$table->data[1][0] .= '</span>';
$table->data['selection_mode'][0] = __('Selection mode');
$table->data['selection_mode'][1] = __('Select modules first') . ' ' .
html_print_radio_button_extended ("selection_mode", 'modules', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->data['selection_mode'][2] = '';
$table->data['selection_mode'][3] = __('Select agents first') . ' ' .
html_print_radio_button_extended ("selection_mode", 'agents', '', $selection_mode, false, '', 'style="margin-right: 40px;"', true);
$table->rowclass['form_modules_1'] = 'select_modules_row';
$table->data['form_modules_1'][0] = __('Module type');
$table->data['form_modules_1'][0] .= '<span id="module_loading" class="invisible">';
$table->data['form_modules_1'][0] .= html_print_image('images/spinner.png', true);
$table->data['form_modules_1'][0] .= '</span>';
$types[0] = __('All');
$table->colspan[1][1] = 2;
$table->data[1][1] = html_print_select ($types,
$table->colspan['form_modules_1'][1] = 2;
$table->data['form_modules_1'][1] = html_print_select ($types,
'module_type', '', false, __('Select'), -1, true, false, true);
$table->data[1][3] = __('Select all modules of this type').' '.html_print_checkbox_extended ("force_type", 'type', '', '', false, '', 'style="margin-right: 40px;"', true);
$table->data['form_modules_1'][3] = __('Select all modules of this type') . ' ' .
html_print_checkbox_extended ("force_type", 'type', '', '', false, '', 'style="margin-right: 40px;"', true);
$modules = array ();
if ($module_type != '') {
@ -241,49 +251,75 @@ foreach ($names as $name) {
$modules[$name['nombre']] = $name['nombre'];
}
$table->rowclass[2] = 'select_agents_row';
$table->data[2][0] = __('Agent group');
$table->rowclass['form_agents_1'] = 'select_agents_row';
$table->data['form_agents_1'][0] = __('Agent group');
$groups = groups_get_all(true);
$groups[0] = __('All');
$table->colspan[2][1] = 2;
$table->data[2][1] = html_print_select ($groups, 'groups_select',
'', true, __('Select'), -1, true, false, true).
' '.__('Group recursion').' '.html_print_checkbox ("recursion", 1, false, true, false);
$table->data[2][3] = __('Select all modules of this group').' '.html_print_checkbox_extended ("force_group", 'group', '', '', false, '', 'style="margin-right: 40px;"', true);
$table->colspan['form_agents_1'][1] = 2;
$table->data['form_agents_1'][1] = html_print_select ($groups, 'groups_select',
'', true, __('Select'), -1, true, false, true) .
' ' . __('Group recursion') . ' ' .
html_print_checkbox ("recursion", 1, false, true, false);
$table->data['form_agents_1'][3] = __('Select all modules of this group') . ' ' .
html_print_checkbox_extended ("force_group", 'group', '', '', false, '', 'style="margin-right: 40px;"', true);
$table->rowstyle[3] = 'vertical-align: top;';
$table->rowclass[3] = 'select_modules_row select_modules_row_2';
$table->data[3][0] = __('Modules');
$table->data[3][1] = html_print_select ($modules, 'module_name[]',
$table->rowstyle['form_modules_2'] = 'vertical-align: top;';
$table->rowclass['form_modules_2'] = 'select_modules_row select_modules_row_2';
$table->data['form_modules_2'][0] = __('Modules');
$table->data['form_modules_2'][1] = html_print_select ($modules, 'module_name[]',
$module_name, false, __('Select'), -1, true, true, true);
$table->data[3][2] = __('When select modules');
$table->data[3][2] .= '<br>';
$table->data[3][2] .= html_print_select (
$table->data['form_modules_2'][2] = __('When select modules');
$table->data['form_modules_2'][2] .= '<br>';
$table->data['form_modules_2'][2] .= html_print_select (
array('common' => __('Show common agents'),
'all' => __('Show all agents')),
'agents_selection_mode',
'common', false, '', '', true);
$table->data[3][3] = html_print_select (array(), 'agents[]',
$table->data['form_modules_2'][3] = html_print_select (array(), 'agents[]',
$agents_select, false, __('None'), 0, true, true, false);
$table->rowstyle[4] = 'vertical-align: top;';
$table->rowclass[4] = 'select_agents_row select_agents_row_2';
$table->data[4][0] = __('Agents');
$table->data[4][1] = html_print_select ($agents, 'id_agents[]',
$table->rowclass['form_agents_2'] = 'select_agents_row';
$table->data['form_agents_2'][0] = __('Status');
$table->colspan['form_agents_2'][1] = 2;
$status_list = array ();
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_STATUS_WARNING] = __('Warning');
$status_list[AGENT_STATUS_CRITICAL] = __('Critical');
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data['form_agents_2'][1] = html_print_select($status_list,
'status_agents', 'selected', '', __('All'), AGENT_STATUS_ALL, true);
$table->data['form_agents_2'][3] = '';
$table->rowstyle['form_agents_3'] = 'vertical-align: top;';
$table->rowclass['form_agents_3'] = 'select_agents_row select_agents_row_2';
$table->data['form_agents_3'][0] = __('Agents');
$table->data['form_agents_3'][1] = html_print_select ($agents, 'id_agents[]',
$agents_id, false, '', '', true, true, false);
$table->data[4][2] = __('When select agents');
$table->data[4][2] .= '<br>';
$table->data[4][2] .= html_print_select (
$table->data['form_agents_3'][2] = __('When select agents');
$table->data['form_agents_3'][2] .= '<br>';
$table->data['form_agents_3'][2] .= html_print_select (
array('common' => __('Show common modules'),
'all' => __('Show all modules')),
'modules_selection_mode',
'common', false, '', '', true);
$table->data[4][3] = html_print_select (array(), 'module[]',
$table->data['form_agents_3'][3] = html_print_select (array(), 'module[]',
$modules_select, false, '', '', true, true, false);
$table->data['edit1'][0] = __('Warning status');
$table->data['edit1'][1] = '<table width="100%">';
$table->data['edit1'][1] .= '<tr>';
@ -787,20 +823,25 @@ $(document).ready (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"recursion" : $("#checkbox-recursion").attr ("checked") ? 1 : 0,
"id_group" : this.value,
"get_agents_group_json" : 1,
"recursion" : $("#checkbox-recursion").attr ("checked") ? 1 : 0,
"id_group" : this.value,
status_agents: function () {
return $("#status_agents").val();
},
// Add a key prefix to avoid auto sorting in js object conversion
"keys_prefix" : "_"
},
function (data, status) {
$("#id_agents").html('');
jQuery.each (data, function (id, value) {
jQuery.each (data, function(id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
option = $("<option></option>").attr ("value", value["id_agente"]).html (value["nombre"]);
option = $("<option></option>")
.attr("value", value["id_agente"])
.html(value["nombre"]);
$("#id_agents").append (option);
});
},
@ -808,6 +849,10 @@ $(document).ready (function () {
);
}
);
$("#status_agents").change(function() {
$("#groups_select").trigger("change");
});
});
/* ]]> */
</script>

View File

@ -48,6 +48,7 @@ if (is_ajax ()) {
$recursion = (int) get_parameter ('recursion', 0);
// Is is possible add keys prefix to avoid auto sorting in js object conversion
$keys_prefix = (string) get_parameter ('keys_prefix', '');
$status_agents = (int)get_parameter('status_agents', AGENT_STATUS_ALL);
if ($id_group > 0) {
$groups = array($id_group);
@ -62,8 +63,34 @@ if (is_ajax ()) {
$groups = array_keys($groups_orig);
}
$filter = " WHERE id_grupo IN (" . implode(',', $groups) . ")
ORDER BY nombre ASC";
$filter = " WHERE id_grupo IN (" . implode(',', $groups) . ") ";
switch ($status_agents) {
case AGENT_STATUS_NORMAL:
$filter .=
" AND normal_count = total_count";
break;
case AGENT_STATUS_WARNING:
$filter .=
" AND critical_count = 0 AND warning_count > 0";
break;
case AGENT_STATUS_CRITICAL:
$filter .=
" AND critical_count > 0";
break;
case AGENT_STATUS_UNKNOWN:
$filter .=
" AND critical_count = 0 AND warning_count = 0
AND unknown_count > 0";
break;
case AGENT_STATUS_NOT_NORMAL:
$filter .= " AND normal_count <> total_count";
break;
case AGENT_STATUS_NOT_INIT:
$filter .= " AND notinit_count = total_count";
break;
}
$filter .= " ORDER BY nombre ASC";
$agents = db_get_all_rows_sql("SELECT id_agente, nombre
FROM tagente" . $filter);
@ -114,7 +141,7 @@ if (is_ajax ()) {
WHERE t1.id_agente = t2.id_agente
AND t2.nombre IN (\'' . implode('\',\'', $nameModules) . '\')';
if($selection_mode == 'common') {
if ($selection_mode == 'common') {
$sql .= 'AND (
SELECT count(t3.nombre)
FROM tagente t3, tagente_modulo t4