Add search bar to cluster list - #1748
This commit is contained in:
parent
3c1025a146
commit
dcb7c92cea
|
@ -22,45 +22,135 @@ if (! check_acl ($config['id_user'], 0, "AR")) {
|
|||
return;
|
||||
}
|
||||
|
||||
ui_pagination (count($clusters));
|
||||
ui_print_page_header (__('Monitoring')." » ".__('Clusters'), "images/chart.png", false, "", false, $buttons);
|
||||
|
||||
// $graphs = custom_graphs_get_user ($config['id_user'], false, true, $access);
|
||||
// $offset = (int) get_parameter ("offset");
|
||||
$group_id = (int) get_parameter ("cluster_group_id", 0);
|
||||
$search = trim(get_parameter ("search", ""));
|
||||
$offset = (int)get_parameter('offset', 0);
|
||||
$refr = get_parameter('refr', 0);
|
||||
$recursion = get_parameter('recursion', 0);
|
||||
$status = (int) get_parameter ('status', -1);
|
||||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
$agent_a = (bool) check_acl ($config['id_user'], 0, "AR");
|
||||
$agent_w = (bool) check_acl ($config['id_user'], 0, "AW");
|
||||
$access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
|
||||
|
||||
|
||||
if ($group_id > 0) {
|
||||
$groups = array($group_id);
|
||||
if ($recursion) {
|
||||
$groups = groups_get_id_recursive($group_id, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$groups = array();
|
||||
$user_groups = users_get_groups($config["id_user"], $access);
|
||||
$groups = array_keys($user_groups);
|
||||
}
|
||||
|
||||
$groups_sql = '';
|
||||
|
||||
foreach ($groups as $value) {
|
||||
if ($value === end($groups)) {
|
||||
$groups_sql .= $value;
|
||||
}
|
||||
else{
|
||||
$groups_sql .= $value.',';
|
||||
}
|
||||
}
|
||||
|
||||
if($status == -1){
|
||||
$status = '0,1,2,3,4,5,6';
|
||||
}
|
||||
|
||||
$clusters = db_process_sql('select tcluster.id,tcluster.name,tcluster.cluster_type,tcluster.description,tcluster.group,tcluster.id_agent,tagente_estado.known_status from tcluster
|
||||
INNER JOIN tagente_modulo ON tcluster.id_agent = tagente_modulo.id_agente
|
||||
INNER JOIN tagente_estado ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo and tagente_modulo.nombre = "Cluster status"
|
||||
AND `group` in ('.$groups_sql.') and name like "%'.$search.'%" and known_status in ('.$status.')');
|
||||
|
||||
echo '<form method="post" action="?sec=estado&sec2=godmode/reporting/cluster_list">';
|
||||
|
||||
echo '<table cellpadding="4" cellspacing="4" class="databox filters" width="100%" style="font-weight: bold; margin-bottom: 10px;">';
|
||||
|
||||
echo '<tr><td style="white-space:nowrap;">';
|
||||
|
||||
echo __('Group') . ' ';
|
||||
|
||||
$groups = users_get_groups (false, $access);
|
||||
|
||||
html_print_select_groups($config['id_user'], "AR", $groups, "cluster_group_id", $group_id, 'this.form.submit();', '', 0, false, false, true, '', false);
|
||||
|
||||
|
||||
echo '</td><td style="white-space:nowrap;">';
|
||||
|
||||
echo __("Recursion") . ' ';
|
||||
html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()');
|
||||
|
||||
echo '</td><td style="white-space:nowrap;">';
|
||||
|
||||
echo __('Search') . ' ';
|
||||
html_print_input_text ("search", $search, '', 15);
|
||||
|
||||
echo '</td><td style="white-space:nowrap;">';
|
||||
|
||||
$fields = array ();
|
||||
$fields[AGENT_STATUS_NORMAL] = __('Normal');
|
||||
$fields[AGENT_STATUS_WARNING] = __('Warning');
|
||||
$fields[AGENT_STATUS_CRITICAL] = __('Critical');
|
||||
$fields[AGENT_STATUS_UNKNOWN] = __('Unknown');
|
||||
$fields[AGENT_STATUS_NOT_INIT] = __('Not init');
|
||||
|
||||
echo __('Status') . ' ';
|
||||
html_print_select ($fields, "status", $status, 'this.form.submit()', __('All'), AGENT_STATUS_ALL, false, false, true, '', false, 'width: 90px;');
|
||||
|
||||
echo '</td>
|
||||
|
||||
<td style="white-space:nowrap;">';
|
||||
|
||||
html_print_submit_button (__('Search'), "srcbutton", '',
|
||||
array ("class" => "sub search"));
|
||||
|
||||
echo '</td><td style="width:5%;"> </td>';
|
||||
|
||||
echo '</tr></table></form>';
|
||||
|
||||
// ui_pagination (count($graphs));
|
||||
|
||||
if($clusters){
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox data';
|
||||
$table->align = array ();
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Cluster name') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=name&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=name&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=name&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=name&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
$table->head[1] = __('Description') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=description&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=description&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=description&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=description&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
$table->head[2] = __('Group') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=group&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=group&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=group&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=group&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
$table->head[3] = __('Type') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=type&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=type&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=type&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=type&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
|
||||
$table->head[4] = __('Nodes') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=nodes&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=nodes&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=nodes&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=nodes&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
$table->head[5] = __('Status') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=status&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=status&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=status&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=status&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
$table->head[6] = __('Actions') . ' ' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=actions&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=actions&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=actions&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
|
||||
'<a href="index.php?sec=estado&sec2=enterprise/operation/cluster/cluster&offset=' . $offset . '&cluster_group_id=' . $group_id . '&recursion=' . $recursion . '&search=' . $search . '&status='. $status . '&sort_field=actions&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
|
||||
|
||||
$table->size[0] = '25%';
|
||||
$table->size[1] = '25%';
|
||||
|
@ -80,7 +170,7 @@ ui_pagination (count($clusters));
|
|||
$data[0] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id='.$cluster["id"].'">'.$cluster["name"].'</a>';
|
||||
$data[1] = ui_print_truncate_text($cluster["description"], 70);
|
||||
|
||||
$data[2] = ui_print_group_icon($cluster['group'],true);
|
||||
$data[2] = ui_print_group_icon($cluster['group'],true,'groups_small','',false);
|
||||
|
||||
$data[3] = $cluster["cluster_type"];
|
||||
|
||||
|
@ -149,6 +239,8 @@ ui_pagination (count($clusters));
|
|||
}
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
}
|
||||
|
||||
echo '<form method="post" style="float:right;" action="index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=1">';
|
||||
html_print_submit_button (__('Create cluster'), 'create', false, 'class="sub next" style="margin-right:5px;"');
|
||||
|
|
|
@ -65,9 +65,9 @@ echo "<table style='width:100%;'>";
|
|||
|
||||
echo "<div style='float:left;width:100px;margin-left:25px;margin-top:25px;font-size:2em;text-align:center;'>".__('CLUSTER STATUS')."</div>";
|
||||
|
||||
$cluster_module = db_process_sql('select id_agente_modulo from tagente_modulo where id_agente = (select id_agent from tcluster where id = '.$id_cluster.') and nombre = "Cluster status"');
|
||||
$cluster_module_central = db_process_sql('select id_agente_modulo from tagente_modulo where id_agente = (select id_agent from tcluster where id = '.$id_cluster.') and nombre = "Cluster status"');
|
||||
|
||||
$cluster_module_status = modules_get_agentmodule_last_status($cluster_module[0]['id_agente_modulo']);
|
||||
$cluster_module_status = modules_get_agentmodule_last_status($cluster_module_central[0]['id_agente_modulo']);
|
||||
|
||||
switch ($cluster_module_status) {
|
||||
case 1:
|
||||
|
@ -175,12 +175,73 @@ echo "<table style='width:100%;'>";
|
|||
|
||||
echo "<div style='width:50%;min-width:390px;max-width:390px;float:left;'>";
|
||||
|
||||
$last_update = db_process_sql('select timestamp from tagente_estado where id_agente_modulo = '.$cluster_module[0]['id_agente_modulo']);
|
||||
$last_update = db_process_sql('select timestamp,id_agente_modulo from tagente_estado where id_agente_modulo = '.$cluster_module_central[0]['id_agente_modulo']);
|
||||
|
||||
$last_update_value = $last_update[0]['timestamp'];
|
||||
|
||||
|
||||
$last_update_value_unix = strtotime($last_update_value);
|
||||
|
||||
$last_run_difference = '';
|
||||
|
||||
$diferencia = time() - $last_update_value_unix;
|
||||
|
||||
$last_run_difference_months = 0;
|
||||
$last_run_difference_weeks = 0;
|
||||
$last_run_difference_days = 0;
|
||||
$last_run_difference_minutos = 0;
|
||||
$last_run_difference_seconds = 0;
|
||||
|
||||
while($diferencia >= 2419200){
|
||||
$diferencia -= 2419200;
|
||||
$last_run_difference_months++;
|
||||
}
|
||||
|
||||
while($diferencia >= 604800){
|
||||
$diferencia -= 604800;
|
||||
$last_run_difference_weeks++;
|
||||
}
|
||||
|
||||
while($diferencia >= 86400){
|
||||
$diferencia -= 86400;
|
||||
$last_run_difference_days++;
|
||||
}
|
||||
|
||||
while($diferencia >= 3600){
|
||||
$diferencia -= 3600;
|
||||
$last_run_difference_hours++;
|
||||
}
|
||||
|
||||
while($diferencia >= 60){
|
||||
$diferencia -= 60;
|
||||
$last_run_difference_minutes++;
|
||||
}
|
||||
|
||||
$last_run_difference_seconds = $diferencia;
|
||||
|
||||
if($last_run_difference_months > 0){
|
||||
$last_run_difference .= $last_run_difference_months.'month/s ';
|
||||
}
|
||||
|
||||
if ($last_run_difference_weeks > 0) {
|
||||
$last_run_difference .= $last_run_difference_weeks.' week/s ';
|
||||
}
|
||||
|
||||
if ($last_run_difference_days > 0) {
|
||||
$last_run_difference .= $last_run_difference_days.' day/s ';
|
||||
}
|
||||
|
||||
if ($last_run_difference_hours > 0) {
|
||||
$last_run_difference .= $last_run_difference_hours.' hour/s ';
|
||||
}
|
||||
|
||||
if ($last_run_difference_minutes > 0) {
|
||||
$last_run_difference .= $last_run_difference_minutes.' minute/s ';
|
||||
}
|
||||
|
||||
$last_run_difference .= $last_run_difference_seconds.' second/s ago';
|
||||
|
||||
echo "<div style='float:left;width:100px;px;margin-left:20px;margin-top:25px;font-size:2em;text-align:center;'>".__('LAST UPDATE')."</div>";
|
||||
echo "<div style='float:left;width:220px;margin-left:20px;margin-top:40px;font-size:1.5em;text-align:center;'>".$last_update_value."</div>";
|
||||
echo "<div style='float:left;width:220px;margin-left:20px;margin-top:40px;font-size:1.5em;text-align:center;'>".$last_run_difference."</div>";
|
||||
|
||||
echo "<div style='border:1px solid lightgray;float:left;width:350px;margin-left:20px;margin-right:20px;margin-top:20px;height:200px;margin-bottom:20px;'>";
|
||||
|
||||
|
|
Loading…
Reference in New Issue