Inprove wizard, change modules update - #1748

This commit is contained in:
enriquecd 2018-01-24 19:39:00 +01:00
parent 4358f37e07
commit c14e68e0e8
4 changed files with 61 additions and 16 deletions

View File

@ -285,7 +285,7 @@ elseif ($step == 3) {
echo "</tr>"; echo "</tr>";
echo "<tr>"; echo "<tr>";
echo "<td class='datos'><b>".__('Adding common modules')."</b></td>"; echo "<td class='datos'><b>".__('Adding common modules').ui_print_help_tip('Attention: the cluster is configured using module names,<br> so that in order to add an agent to a cluster later on,<br> you will not have to select its modules one by one,<br> but instead, you only need to have a series of modules<br> that are called the same, so do not rename the names<br> of a module once you configure the cluster.', true)."</b></td>";
echo "</tr>"; echo "</tr>";
echo "<tr>"; echo "<tr>";
@ -362,8 +362,8 @@ elseif ($step == 4) {
echo "<tr>"; echo "<tr>";
echo "<th><b>".__('Common modules')."</b></th>"; echo "<th><b>".__('Common modules')."</b></th>";
echo "<th><b>".__('Critical if')."</b></th>"; echo "<th><b>".__('Critical if more than')."</b></th>";
echo "<th><b>".__('Warning if')."</b></th>"; echo "<th><b>".__('Warning if more than')."</b></th>";
echo "<th><b>".__('Actions')."</b></th>"; echo "<th><b>".__('Actions')."</b></th>";
echo "</tr>"; echo "</tr>";
@ -372,12 +372,11 @@ elseif ($step == 4) {
foreach ($cluster_items as $key => $value) { foreach ($cluster_items as $key => $value) {
echo "<tr>"; echo "<tr>";
echo "<td class='datos'>".$value."</td>"; echo "<td class='datos'>".$value."</td>";
echo "<td class='datos'><input class='zero_hundred' value='".get_item_critical_limit_by_item_id($key)."' name='critical_item_".$key."' type='number' max='100' min='0' style='width:60%;' onkeydown='javascript: return event.keyCode == 69 ? false : true'> &nbsp;&nbsp;are down</td>"; echo "<td class='datos'><input class='zero_hundred' value='".get_item_critical_limit_by_item_id($key)."' name='critical_item_".$key."' type='number' max='100' min='0' style='width:60%;' onkeydown='javascript: return event.keyCode == 69 ? false : true'> &nbsp;&nbsp;% are down</td>";
echo "<td class='datos'><input class='zero_hundred' value='".get_item_warning_limit_by_item_id($key)."' name='warning_item_".$key."' type='number' max='100' min='0' style='width:60%;' onkeydown='javascript: return event.keyCode == 69 ? false : true'> &nbsp;&nbsp;are down</td>"; echo "<td class='datos'><input class='zero_hundred' value='".get_item_warning_limit_by_item_id($key)."' name='warning_item_".$key."' type='number' max='100' min='0' style='width:60%;' onkeydown='javascript: return event.keyCode == 69 ? false : true'> &nbsp;&nbsp;% are down</td>";
echo "<td class='datos'><a href='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=4&delete_module=".$key."&id_cluster=".$id_cluster."'><img src='images/cross.png'></a></td>"; echo "<td class='datos'><a href='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=4&delete_module=".$key."&id_cluster=".$id_cluster."'><img src='images/cross.png'></a></td>";
echo "</tr>"; echo "</tr>";
} }
@ -387,6 +386,12 @@ elseif ($step == 4) {
echo "</form>"; echo "</form>";
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=3&id_cluster=".$id_cluster."'>";
echo "<div style='width:50%'><input style='float:left;' type=submit name='add' class='sub add' value='".__('Add')."'></div>";
echo "</form>";
} }
elseif ($step == 5) { elseif ($step == 5) {
@ -522,6 +527,12 @@ elseif ($step == 6) {
echo "<div style='width:40%'><input style='float:right;' type=submit name='store' class='sub upd' value='".__('Update and Finish')."'></div>"; echo "<div style='width:40%'><input style='float:right;' type=submit name='store' class='sub upd' value='".__('Update and Finish')."'></div>";
echo "</form>"; echo "</form>";
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=5&id_cluster=".$id_cluster."'>";
echo "<div style='width:50%'><input style='float:left;' type=submit name='add' class='sub add' value='".__('Add')."'></div>";
echo "</form>";
} }
?> ?>

View File

@ -159,7 +159,9 @@ elseif ($step == 3) {
continue; continue;
} }
$tcluster_module = db_process_sql('insert into tcluster_item (name,id_cluster) values ("'.$value.'",'.$id_cluster.')'); // $tcluster_module = db_process_sql('insert into tcluster_item (name,id_cluster,critical_limit,warning_limit) values ("'.$value.'",'.$id_cluster.',100,0)');
$tcluster_module = db_process_sql_insert('tcluster_item',array('name'=>$value,'id_cluster'=>$id_cluster,'critical_limit'=>100,'warning_limit'=>0));
$id_agent = db_process_sql('select id_agent from tcluster where id = '.$id_cluster); $id_agent = db_process_sql('select id_agent from tcluster where id = '.$id_cluster);
@ -171,7 +173,8 @@ elseif ($step == 3) {
'prediction_module' => 6, 'prediction_module' => 6,
'id_agente' => $id_agent[0]['id_agent'], 'id_agente' => $id_agent[0]['id_agent'],
'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'], 'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'],
'custom_integer_1' =>$id_cluster 'custom_integer_1' =>$id_cluster,
'custom_integer_2' =>$tcluster_module
); );
$id_module = db_process_sql_insert('tagente_modulo', $values_module); $id_module = db_process_sql_insert('tagente_modulo', $values_module);
@ -271,19 +274,20 @@ elseif ($step == 3) {
$id_parent_modulo = db_process_sql('select id_agente_modulo from tagente_modulo where id_agente = '.$id_agent[0]['id_agent'].' and nombre = "Cluster status"'); $id_parent_modulo = db_process_sql('select id_agente_modulo from tagente_modulo where id_agente = '.$id_agent[0]['id_agent'].' and nombre = "Cluster status"');
$tcluster_balanced_module = db_process_sql_insert('tcluster_item',array('name'=>$value,'id_cluster'=>$id_cluster,'item_type'=>"AP"));
$values_module = array( $values_module = array(
'nombre' => $value, 'nombre' => $value,
'id_modulo' => 5, 'id_modulo' => 5,
'prediction_module' => 7, 'prediction_module' => 7,
'id_agente' => $id_agent[0]['id_agent'], 'id_agente' => $id_agent[0]['id_agent'],
'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'], 'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'],
'custom_integer_1' =>$id_cluster 'custom_integer_1' => $id_cluster,
'custom_integer_2' => $tcluster_balanced_module
); );
$id_module = db_process_sql_insert('tagente_modulo', $values_module); $id_module = db_process_sql_insert('tagente_modulo', $values_module);
$tcluster_balanced_module = db_process_sql('insert into tcluster_item (name,id_cluster,item_type) values ("'.$value.'",'.$id_cluster.',"AP")');
if ($tcluster_balanced_module !== false){ if ($tcluster_balanced_module !== false){
db_pandora_audit("Report management", "Module #$value assigned to cluster #$id_cluster"); db_pandora_audit("Report management", "Module #$value assigned to cluster #$id_cluster");
} }

View File

@ -90,11 +90,41 @@ ui_pagination (count($clusters));
$cluster_agent = db_process_sql('select id_agente from tagente where id_agente = (select id_agent from tcluster where id = '.$cluster['id'].')'); $cluster_agent = db_process_sql('select id_agente from tagente where id_agente = (select id_agent from tcluster where id = '.$cluster['id'].')');
$cluster_agent_status = agents_get_status($cluster_agent[0]['id_agente']); $cluster_agent_status = agents_get_status($cluster_agent[0]['id_agente']);
$data[5] = $cluster_agent_status; switch ($cluster_agent_status) {
case 1:
$data[6] = "<a href='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&delete_cluster=".$cluster["id"]."'><img src='images/cross.png'></a>
$data[5] = '<div title="'.__('Critical').'" style="width:35px;height:20px;background-color:red;"></div>';
break;
case 1:
$data[5] = '<div title="'.__('Warning').'" style="width:35px;height:20px;background-color:red;"></div>';
break;
case 3:
$data[5] = '<div title="'.__('Unknown').'" style="width:35px;height:20px;background-color:gray;"></div>';
break;
case 5:
$data[5] = '<div title="'.__('Not init').'" style="width:35px;height:20px;background-color:blue;"></div>';
break;
case 0:
$data[5] = '<div title="'.__('Normal').'" style="width:35px;height:20px;background-color:green;"></div>';
break;
default:
break;
}
$data[6] = "<a href='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&delete_cluster=".$cluster["id"]."'><img src='images/cross.png'></a>
<a href='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder.cluster_editor&id=".$cluster["id"]."'><img src='images/builder.png'></a>"; <a href='index.php?sec=reporting&sec2=godmode/reporting/cluster_builder.cluster_editor&id=".$cluster["id"]."'><img src='images/builder.png'></a>";
array_push ($table->data, $data); array_push ($table->data, $data);

View File

@ -145,7 +145,7 @@ function get_item_critical_limit_by_item_id ($id){
function get_item_warning_limit_by_item_id ($id){ function get_item_warning_limit_by_item_id ($id){
$warning_limit = (string) db_get_value ('critical_limit', 'tcluster_item', 'id', (int) $id); $warning_limit = (string) db_get_value ('warning_limit', 'tcluster_item', 'id', (int) $id);
return $warning_limit; return $warning_limit;
} }