Cluster monitoring 2 - #2007

This commit is contained in:
enriquecd 2018-03-19 10:05:29 +01:00
parent 25efa085ce
commit 8690aa908a
8 changed files with 235 additions and 17 deletions

View File

@ -495,6 +495,8 @@ if ($agents !== false) {
$id_grupo = $agent["id_grupo"];
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']);
if (! check_acl ($config["id_user"], $id_grupo, "AW", $agent['id_agente']) && ! check_acl ($config["id_user"], $id_grupo, "AD", $agent['id_agente']))
continue;
@ -564,22 +566,38 @@ if ($agents !== false) {
echo '</span><div class="left actions" style="visibility: hidden; clear: left">';
if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=main&
id_agente='.$agent["id_agente"].'">'.__('Edit').'</a>';
echo ' | ';
if($agent["id_os"] == 21){
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']);
echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.__('Edit').'</a>';
echo ' | ';
}
else{
echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=main&
id_agente='.$agent["id_agente"].'">'.__('Edit').'</a>';
echo ' | ';
}
}
if($agent["id_os"] != 21){
echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=module&
id_agente='.$agent["id_agente"].'">'.__('Modules').'</a>';
echo ' | ';
}
echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=alert&
id_agente='.$agent["id_agente"].'">'.__('Alerts').'</a>';
echo ' | ';
echo '<a href="index.php?sec=estado
if($agent["id_os"] == 21){
echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id='.$cluster['id'].'">'.__('View').'</a>';
}
else{
echo '<a href="index.php?sec=estado
&sec2=operation/agentes/ver_agente
&id_agente='.$agent["id_agente"].'">'.__('View').'</a>';
}
echo '</div>';
echo "</td>";
@ -628,19 +646,41 @@ if ($agents !== false) {
if ($agent['disabled']) {
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
enable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled''>".
html_print_image('images/lightbulb_off.png', true, array('alt' => __('Enable agent'), 'title' => __('Enable agent'))) ."</a>";
enable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'";
if($agent["id_os"] != 21){
echo ">";
}
else{
echo ' onClick="if (!confirm(\' '.__('You are going to enable a cluster agent. Are you sure?').'\')) return false;">';
}
echo html_print_image('images/lightbulb_off.png', true, array('alt' => __('Enable agent'), 'title' => __('Enable agent'))) ."</a>";
}
else {
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
disable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'>".
html_print_image('images/lightbulb.png', true, array('alt' => __('Disable agent'), 'title' => __('Disable agent'))) ."</a>";
disable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'";
if($agent["id_os"] != 21){
echo ">";
}
else{
echo ' onClick="if (!confirm(\' '.__('You are going to disable a cluster agent. Are you sure?').'\')) return false;">';
}
echo html_print_image('images/lightbulb.png', true, array('alt' => __('Disable agent'), 'title' => __('Disable agent'))) ."</a>";
}
if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
echo "&nbsp;&nbsp;<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'";
echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
if($agent["id_os"] != 21){
echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
}
else{
echo ' onClick="if (!confirm(\' '.__('You are going to delete a cluster agent. Are you sure?').'\')) return false;">';
}
echo html_print_image('images/cross.png', true, array("border" => '0')) . "</a>";
}

View File

@ -141,6 +141,12 @@ echo '<form class="add_alert_form" method="post">';
html_print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if($id_cluster){
echo "<input onclick='window.location.replace(\"index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id=".$id_cluster."\");' type=button style='float:right;margin-left:20px;' name='store' class='sub upd' value='".__('Finish and view cluster')."'>";
}
html_print_submit_button (__('Add alert'), 'add', false, 'class="sub wand"');
html_print_input_hidden ('create_alert', 1);
echo '</div></form>';

View File

@ -159,8 +159,14 @@ else {
$form_filter .= "</form>";
if ( defined("METACONSOLE"))
echo "<br>";
if(!$id_cluster){
ui_toggle($form_filter, __('Alert control filter'), __('Toggle filter(s)'));
}
else{
unset($form_filter);
}
ui_toggle($form_filter, __('Alert control filter'), __('Toggle filter(s)'));
$simple_alerts = array();
@ -737,7 +743,7 @@ if (isset($dont_display_alert_create_bttn))
if ($dont_display_alert_create_bttn)
$display_create = false;
if ($display_create && (check_acl ($config['id_user'], 0, "LW") || check_acl ($config['id_user'], $template_group, "LM"))) {
if ($display_create && (check_acl ($config['id_user'], 0, "LW") || check_acl ($config['id_user'], $template_group, "LM")) && !$id_cluster) {
echo '<div class="action-buttons" style="width: ' . $table->width . '">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_list&tab=builder&pure='.$pure.'">';
html_print_submit_button (__('Create'), 'crtbtn', false, 'class="sub next"');

View File

@ -143,6 +143,20 @@ if ($delete_alert) {
$messageAction = ui_print_result_message ($result,
__('Successfully deleted'), __('Could not be deleted'), '', true);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if($id_cluster){
if($id_cluster[0]['cluster_type'] == 'AA'){
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_delete_alert='.$result);
}
else{
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_delete_alert='.$result);
}
}
}
if ($add_action) {
@ -211,6 +225,20 @@ if ($delete_action) {
$messageAction = ui_print_result_message ($result,
__('Successfully deleted'), __('Could not be deleted'), '', true);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if($id_cluster){
if($id_cluster[0]['cluster_type'] == 'AA'){
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_delete_action='.$result);
}
else{
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_delete_action='.$result);
}
}
}
if ($enable_alert) {
@ -228,6 +256,19 @@ if ($enable_alert) {
$messageAction = ui_print_result_message ($result,
__('Successfully enabled'), __('Could not be enabled'), '', true);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if($id_cluster){
if($id_cluster[0]['cluster_type'] == 'AA'){
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_enable_alert='.$result);
}
else{
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_enable_alert='.$result);
}
}
}
if ($disable_alert) {
@ -245,6 +286,20 @@ if ($disable_alert) {
$messageAction = ui_print_result_message ($result,
__('Successfully disabled'), __('Could not be disabled'), '', true);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if($id_cluster){
if($id_cluster[0]['cluster_type'] == 'AA'){
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_disable_alert='.$result);
}
else{
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_disable_alert='.$result);
}
}
}
if ($standbyon_alert) {
@ -262,6 +317,19 @@ if ($standbyon_alert) {
$messageAction = ui_print_result_message ($result,
__('Successfully set standby'), __('Could not be set standby'), '', true);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if($id_cluster){
if($id_cluster[0]['cluster_type'] == 'AA'){
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_standbyon='.$result);
}
else{
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_standbyon='.$result);
}
}
}
if ($standbyoff_alert) {
@ -279,6 +347,19 @@ if ($standbyoff_alert) {
$messageAction = ui_print_result_message ($result,
__('Successfully set off standby'), __('Could not be set off standby'), '', true);
$id_cluster = db_get_all_rows_sql('select id,cluster_type from tcluster where id_agent = '.$id_agente);
if($id_cluster){
if($id_cluster[0]['cluster_type'] == 'AA'){
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=5&update=1&message_standbyoff='.$result);
}
else{
header('Location: index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$id_cluster[0]['id'].'&step=7&update=1&message_standbyoff='.$result);
}
}
}
if ($id_agente) {

View File

@ -105,8 +105,64 @@ if ($correctLogin) {
}
else {
$function_name = 'api_' . $op . '_' . $op2;
if ($op == "set" && $id){
switch ($op2) {
case "update_agent":
case "add_module_in_conf":
case "update_module_in_conf":
case "delete_module_in_conf":
$id_os = db_get_value_sql('select id_os from tagente where id_agente = '.$id);
if($id_os == 21){
returnError('not_allowed_operation_cluster', $returnType);
return false;
}
break;
case "create_network_module":
case "create_plugin_module":
case "create_data_module":
case "create_synthetic_module":
case "create_snmp_module":
case "delete_module":
case "delete_agent":
$id_os = db_get_value_sql('select id_os from tagente where nombre = "'.$id.'"');
html_debug($id_os);
if($id_os == 21){
returnError('not_allowed_operation_cluster', $returnType);
return false;
}
break;
case "update_network_module":
case "update_plugin_module":
case "update_data_module":
case "update_snmp_module":
$id_os = db_get_value_sql('select id_os from tagente where id_agente = (select id_agente from tagente_modulo where id_agente_modulo ='.$id.')');
if($id_os == 21){
returnError('not_allowed_operation_cluster', $returnType);
return false;
}
break;
default:
// break;
}
}
}
// Check if the function exists
if (function_exists($function_name)) {
if (!DEBUG) {

View File

@ -85,6 +85,10 @@ function returnError($typeError, $returnType = 'string') {
returnData($returnType,
array('type' => 'string', 'data' => __('Id does not exist in BD.')));
break;
case 'not_allowed_operation_cluster':
returnData($returnType,
array('type' => 'string', 'data' => __('This operation can not be used in cluster elements.')));
break;
default:
returnData("string",
array('type' => 'string', 'data' => __($returnType)));

View File

@ -622,8 +622,17 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
if ( $user_access_node && check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
$go_to_agent = '<div style="text-align: right;">';
$go_to_agent .= '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">';
$go_to_agent .= html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
if($agent["id_os"] != 21){
$go_to_agent .= '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">';
$go_to_agent .= html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
}
else{
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$id_agente);
$go_to_agent .= '<a target=_blank href="' . $console_url . 'index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1='.$id_agente.'">';
$go_to_agent .= html_print_submit_button (__('Edit cluster'), 'upd_button', false, 'class="sub config"', true);
}
$go_to_agent .= '</a>';
$go_to_agent .= '</div>';

View File

@ -599,6 +599,9 @@ $table->data = array ();
$rowPair = true;
$iterator = 0;
foreach ($agents as $agent) {
$cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']);
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
@ -637,11 +640,24 @@ foreach ($agents as $agent) {
}
$data[0] .= '<div class="agentleft_' . $agent["id_agente"] . '" style="visibility: hidden; clear: left;">';
$data[0] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].'">'.__('View').'</a>';
if($agent["id_os"] == 21){
$data[0] .= '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id='.$cluster['id'].'">'.__('View').'</a>';
}
else{
$data[0] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].'">'.__('View').'</a>';
}
if (check_acl ($config['id_user'], $agent["id_grupo"], "AW")) {
$data[0] .= ' | ';
$data[0] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$agent["id_agente"].'">'.__('Edit').'</a>';
if($agent["id_os"] == 21){
$data[0] .= '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.__('Edit').'</a>';
}
else{
$data[0] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$agent["id_agente"].'">'.__('Edit').'</a>';
}
}
$data[0] .= '</div></div>';