2013-08-01 Miguel de Dios <miguel.dedios@artica.es>
* enterprise/godmode/agentes/agent_disk_conf_editor.php, enterprise/godmode/agentes/collection_manager.php, enterprise/godmode/policies/policy_agents.php, enterprise/include/functions_collection.php, enterprise/include/functions_policies.php, enterprise/include/functions_config_agents.php, enterprise/operation/agentes/collection_view.php: fixed and unified the code to access the remote config. MERGED FROM BRANCH PANDORA_4 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8619 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
6860129ced
commit
b373b23340
|
@ -1,3 +1,16 @@
|
|||
2013-08-01 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* enterprise/godmode/agentes/agent_disk_conf_editor.php,
|
||||
enterprise/godmode/agentes/collection_manager.php,
|
||||
enterprise/godmode/policies/policy_agents.php,
|
||||
enterprise/include/functions_collection.php,
|
||||
enterprise/include/functions_policies.php,
|
||||
enterprise/include/functions_config_agents.php,
|
||||
enterprise/operation/agentes/collection_view.php: fixed and unified
|
||||
the code to access the remote config.
|
||||
|
||||
MERGED FROM BRANCH PANDORA_4
|
||||
|
||||
2013-08-01 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_filemanager.php
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
// GNU General Public License for more details.
|
||||
|
||||
if (is_ajax ()) {
|
||||
|
||||
global $config;
|
||||
|
||||
$search_parents_2 = (bool) get_parameter ('search_parents_2');
|
||||
|
@ -78,7 +79,7 @@ if (is_ajax ()) {
|
|||
if ($out === false) {
|
||||
$out = $oid_snmp;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$out = array_intersect($out,$oid_snmp);
|
||||
}
|
||||
|
||||
|
@ -117,11 +118,7 @@ echo '<div style="height: 5px"> </div>';
|
|||
|
||||
if (!$new_agent) {
|
||||
// Agent remote configuration editor
|
||||
$agent_md5 = md5 ($nombre_agente, false);
|
||||
$filename['md5'] = $config["remote_config"] . "/md5/" .
|
||||
$agent_md5 . ".md5";
|
||||
$filename['conf'] = $config["remote_config"] . "/conf/" .
|
||||
$agent_md5 . ".conf";
|
||||
$filename = config_agents_get_agent_config_filenames($id_agente);
|
||||
}
|
||||
|
||||
$disk_conf = (bool) get_parameter ('disk_conf');
|
||||
|
@ -155,6 +152,7 @@ $table->data[0][0] = __('Agent name') .
|
|||
$table->data[0][1] = html_print_input_text ('agente', $nombre_agente, '', 50, 100,true);
|
||||
|
||||
if ($id_agente) {
|
||||
|
||||
$table->data[0][1] .= " <b>".__("ID")."</b> $id_agente ";
|
||||
$table->data[0][1] .= ' <a href="index.php?sec=gagente&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'">';
|
||||
$table->data[0][1] .= html_print_image ("images/zoom.png", true, array ("border" => 0, "title" => __('Agent detail')));
|
||||
|
@ -164,6 +162,10 @@ if ($id_agente) {
|
|||
// Remote configuration available
|
||||
if (!$new_agent) {
|
||||
if (file_exists ($filename['md5'])) {
|
||||
$agent_name = agents_get_name($id_agente);
|
||||
$agent_name = io_safe_output($agent_name);
|
||||
$agent_md5 = md5 ($agent_name, false);
|
||||
|
||||
$table->data[0][1] .= ' <a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agente.'&disk_conf='.$agent_md5.'">';
|
||||
$table->data[0][1] .= html_print_image ("images/application_edit.png", true, array ("border" => 0, "title" => __('This agent can be remotely configured')));
|
||||
$table->data[0][1] .= '</a>'.ui_print_help_tip (__('You can remotely edit this agent configuration'), true);
|
||||
|
@ -282,7 +284,8 @@ else
|
|||
$listIcons = gis_get_array_list_icons();
|
||||
|
||||
$arraySelectIcon = array();
|
||||
foreach ($listIcons as $index => $value) $arraySelectIcon[$index] = $index;
|
||||
foreach ($listIcons as $index => $value)
|
||||
$arraySelectIcon[$index] = $index;
|
||||
|
||||
$path = 'images/gis_map/icons/'; //TODO set better method the path
|
||||
$table->data[4][0] = __('Agent icon') . ui_print_help_tip(__('Agent icon for GIS Maps.'), true);
|
||||
|
|
|
@ -488,7 +488,7 @@ if ($delete_conf_file) {
|
|||
$correct = false;
|
||||
// Delete remote configuration
|
||||
if (isset ($config["remote_config"])) {
|
||||
$agent_md5 = md5 (agents_get_name ($id_agente,'none'), FALSE);
|
||||
$agent_md5 = md5(io_safe_output(agents_get_name ($id_agente,'none')), FALSE);
|
||||
|
||||
if (file_exists ($config["remote_config"] . "/md5/" . $agent_md5 . ".md5")) {
|
||||
// Agent remote configuration editor
|
||||
|
|
|
@ -87,10 +87,7 @@ if ($agent_to_delete) {
|
|||
|
||||
// Check if the remote config file still exist
|
||||
if (isset ($config["remote_config"])) {
|
||||
$agent_md5 = md5 (agents_get_name($id_agente, ""), FALSE);
|
||||
|
||||
if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5") ||
|
||||
file_exists ($config["remote_config"]."/conf/".$agent_md5.".conf")) {
|
||||
if (config_agents_has_remote_configuration($id_agente)) {
|
||||
ui_print_error_message(__('Maybe the files conf or md5 could not be deleted'));
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +157,7 @@ echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/agentes
|
|||
echo "</form>";
|
||||
echo "</div>";
|
||||
|
||||
|
||||
$selected = 'border: 1px solid black;';
|
||||
$selectNameUp = '';
|
||||
$selectNameDown = '';
|
||||
|
@ -281,6 +279,7 @@ if ($ag_group > 0) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
|
||||
// Admin user get ANY group, even if they doesnt exist
|
||||
if (check_acl ($config['id_user'], 0, "PM")) {
|
||||
$sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE 1=1 %s', $search_sql);
|
||||
|
@ -397,8 +396,8 @@ if ($agents !== false) {
|
|||
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '</a>' .
|
||||
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . '</a>';
|
||||
echo "</th>";
|
||||
echo "<th>".__('Description')."</th>";
|
||||
echo "<th>".__('Actions')."</th>";
|
||||
echo "<th>" . __('Description') . "</th>";
|
||||
echo "<th>" . __('Actions') . "</th>";
|
||||
$color=1;
|
||||
|
||||
$rowPair = true;
|
||||
|
@ -478,8 +477,7 @@ if ($agents !== false) {
|
|||
|
||||
echo "<td align='center' class='$tdcolor'>";
|
||||
// Has remote configuration ?
|
||||
$agent_md5 = md5 ($agent["nombre"], false);
|
||||
if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) {
|
||||
if (config_agents_has_remote_configuration($agent["id_agente"])) {
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente=".$agent["id_agente"]."&disk_conf=1'>";
|
||||
echo html_print_image("images/application_edit.png", true, array("align" => 'middle', "title" => __('Edit remote config')));
|
||||
echo "</a>";
|
||||
|
@ -530,7 +528,7 @@ if ($agents !== false) {
|
|||
echo "<table width='95%'><tr><td align='right'>";
|
||||
}
|
||||
else {
|
||||
echo "<div class='nf'>".__('There are no defined agents')."</div>";
|
||||
echo "<div class='nf'>" . __('There are no defined agents') . "</div>";
|
||||
echo " </td></tr><tr><td>";
|
||||
}
|
||||
|
||||
|
@ -548,23 +546,23 @@ echo "</td></tr></table>";
|
|||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
$("table#agent_list tr").hover (function () {
|
||||
$(".actions", this).css ("visibility", "");
|
||||
},
|
||||
function () {
|
||||
$(".actions", this).css ("visibility", "hidden");
|
||||
$(document).ready (function () {
|
||||
$("table#agent_list tr").hover (function () {
|
||||
$(".actions", this).css ("visibility", "");
|
||||
},
|
||||
function () {
|
||||
$(".actions", this).css ("visibility", "hidden");
|
||||
});
|
||||
|
||||
$("#ag_group").click (
|
||||
function () {
|
||||
$(this).css ("width", "auto");
|
||||
$(this).css ("min-width", "100px");
|
||||
});
|
||||
|
||||
$("#ag_group").blur (function () {
|
||||
|
||||
$("#ag_group").click (
|
||||
function () {
|
||||
$(this).css ("width", "auto");
|
||||
$(this).css ("min-width", "100px");
|
||||
});
|
||||
|
||||
$("#ag_group").blur (function () {
|
||||
$(this).css ("width", "100px");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -52,7 +52,7 @@ if (is_ajax ()) {
|
|||
|
||||
$id_module_group = (int) get_parameter ('id_module_component_group');
|
||||
$localComponents = local_components_get_local_components(
|
||||
array('id_network_component_group' => $id_module_group),
|
||||
array('id_network_component_group' => $id_module_group),
|
||||
array('id', 'name'));
|
||||
|
||||
echo json_encode($localComponents);
|
||||
|
@ -324,6 +324,7 @@ if($is_function_policies !== ENTERPRISE_NOT_HOOK) {
|
|||
|
||||
db_pandora_audit("Agent management", "Unlink module " . $id_agent_module);
|
||||
}
|
||||
|
||||
}
|
||||
global $__code_from;
|
||||
$__code_from = 'modules';
|
||||
|
@ -334,9 +335,7 @@ switch ($moduletype) {
|
|||
case MODULE_DATA:
|
||||
$moduletype = MODULE_DATA;
|
||||
// Has remote configuration ?
|
||||
$agent_md5 = md5 (agents_get_name($id_agente), false);
|
||||
$remote_conf = file_exists ($config["remote_config"] ."/md5/" .
|
||||
$agent_md5 . ".md5");
|
||||
$remote_conf = config_agents_has_remote_configuration($id_agente);
|
||||
|
||||
/* Categories is an array containing the allowed module types
|
||||
(generic_data, generic_string, etc) from ttipo_modulo (field categoria) */
|
||||
|
@ -391,6 +390,7 @@ switch ($moduletype) {
|
|||
1) forgot to use the database converter<br />
|
||||
2) used a bad version of the database converter (see Bugreport #2124706 for the solution)<br />
|
||||
3) found a new bug - please report a way to duplicate this error');
|
||||
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1669,9 +1669,11 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
|
|||
|
||||
// Delete remote configuration
|
||||
if (isset ($config["remote_config"])) {
|
||||
$agent_md5 = md5 ($agent_name, FALSE);
|
||||
|
||||
if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) {
|
||||
if (config_agents_has_remote_configuration($id_agent)) {
|
||||
$agent_name = agents_get_name($id_agent);
|
||||
$agent_name = io_safe_output($agent_name);
|
||||
$agent_md5 = md5 ($agent_name, false);
|
||||
|
||||
// Agent remote configuration editor
|
||||
$file_name = $config["remote_config"]."/conf/".$agent_md5.".conf";
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
|
|||
if ($id_new_module === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If the module is synthetic we duplicate the operations too
|
||||
|
@ -128,8 +129,9 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
|
|||
|
||||
$id_agente = modules_get_agentmodule_agent($id_agent_module);
|
||||
|
||||
$agent_md5 = md5 (agents_get_name($id_agente), false);
|
||||
$remote_conf = file_exists ($config["remote_config"] . "/md5/" . $agent_md5 . ".md5");
|
||||
$file = config_agents_get_agent_config_filenames($id_agente);
|
||||
$agent_md5 = $file['md5'];
|
||||
$remote_conf = $file['conf'];
|
||||
|
||||
if ($remote_conf) {
|
||||
$result = enterprise_hook('config_agents_copy_agent_module_to_agent',
|
||||
|
@ -309,6 +311,7 @@ function modules_update_agent_module ($id, $values, $onlyNoDeletePending = false
|
|||
}
|
||||
|
||||
$result = @db_process_sql_update ('tagente_modulo', $values, $where);
|
||||
|
||||
if (($result === false) || ($result_disable === ERR_GENERIC)) {
|
||||
return ERR_DB;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ require_once ("include/functions_reporting.php");
|
|||
require_once($config['homedir'] . "/include/functions_agents.php");
|
||||
require_once($config['homedir'] . '/include/functions_users.php');
|
||||
require_once($config['homedir'] . '/include/functions_modules.php');
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
|
||||
check_login ();
|
||||
|
||||
|
@ -109,6 +110,7 @@ if (is_ajax ()) {
|
|||
}
|
||||
ob_end_clean();
|
||||
|
||||
|
||||
// Take some parameters (GET)
|
||||
$group_id = (int) get_parameter ("group_id", 0);
|
||||
$search = trim(get_parameter ("search", ""));
|
||||
|
@ -131,13 +133,13 @@ if (check_acl ($config['id_user'], 0, "AW")) {
|
|||
$setuptab['godmode'] = true;
|
||||
|
||||
$setuptab['active'] = false;
|
||||
|
||||
|
||||
$onheader = array('setup' => $setuptab);
|
||||
}
|
||||
|
||||
ui_print_page_header ( __("Agent detail"), "images/agent_mc.png", false, "agent_status", false, $onheader);
|
||||
|
||||
if(tags_has_user_acl_tags()) {
|
||||
if (tags_has_user_acl_tags()) {
|
||||
ui_print_tags_warning();
|
||||
}
|
||||
|
||||
|
@ -434,7 +436,7 @@ foreach ($agents as $agent) {
|
|||
$status_img = agents_tree_view_status_img ($agent["critical_count"],
|
||||
$agent["warning_count"], $agent["unknown_count"], $agent["total_count"],
|
||||
$agent["notinit_count"]);
|
||||
|
||||
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '';
|
||||
|
@ -464,6 +466,7 @@ foreach ($agents as $agent) {
|
|||
|
||||
$data[5] = reporting_tiny_stats($agent, true);
|
||||
|
||||
|
||||
$data[6] = $status_img;
|
||||
|
||||
$data[7] = $alert_img;
|
||||
|
@ -487,12 +490,12 @@ foreach ($agents as $agent) {
|
|||
if (check_acl ($config["id_user"], $group_id, "AW")) {
|
||||
// Has remote configuration ?
|
||||
$data[9]="";
|
||||
$agent_name = db_get_value("nombre", "tagente", "id_agente", $agent["id_agente"]);
|
||||
$agent_md5 = md5 ($agent_name, false);
|
||||
if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) {
|
||||
|
||||
if (config_agents_has_remote_configuration($agent["id_agente"])) {
|
||||
$data[9] = "<a href='index.php?sec=estado&sec2=godmode/agentes/configurar_agente&tab=main&id_agente=".$agent["id_agente"]."&disk_conf=1'>".
|
||||
html_print_image("images/application_edit.png", true, array("align" => 'middle', "title" => __('Edit remote config')))."</a>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
array_push ($table->data, $data);
|
||||
|
|
Loading…
Reference in New Issue