From 6d86616e7ac34e6bfd7d6da59253616f151f0327 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Sun, 4 Nov 2012 19:10:19 +0000 Subject: [PATCH] 2012-11-04 Miguel de Dios * operation/agentes/status_monitor.php: improved the page status monitor, show in another column the tags and added a select box with the tags in user in the filter form. Pending task: #3581578 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7124 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 + .../operation/agentes/status_monitor.php | 239 ++++++++++++------ 2 files changed, 174 insertions(+), 73 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c7729dc3b4..7c4b883716 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2012-11-04 Miguel de Dios + + * operation/agentes/status_monitor.php: improved the page status + monitor, show in another column the tags and added a select box with + the tags in user in the filter form. + + Pending task: #3581578 + 2012-11-04 Junichi Satoh * godmode/agentes/planned_downtime.editor.php: Fixed that time range diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index fec63ceee0..c341e051cc 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -21,7 +21,8 @@ global $config; check_login(); -if (! check_acl ($config['id_user'], 0, "AR") && ! check_acl ($config['id_user'], 0, "AW")) { +if (! check_acl ($config['id_user'], 0, "AR") + && ! check_acl ($config['id_user'], 0, "AW")) { db_pandora_audit("ACL Violation", "Trying to access Agent Management"); require ('general/noaccess.php'); @@ -45,6 +46,7 @@ $ag_group = (int) get_parameter ('ag_group', 0); $offset = (int) get_parameter ('offset'); $status = (int) get_parameter ('status', 4); $modulegroup = (int) get_parameter ('modulegroup', -1); +$tag_filter = (int) get_parameter('tag_filter', 0); $sql_extra = ''; $refr = get_parameter('refr', 0); // Sort functionality @@ -54,16 +56,23 @@ $sort = get_parameter('sort', 'none'); echo '
'; -echo ''; -echo ''; -echo '
'.__('Group').''; +echo ' + '; -html_print_select_groups(false, "AR", true, "ag_group", $ag_group, '', - '', '0', false, false, false, 'w130', false, 'width:150px;'); -echo ""; -echo " + '; + echo '"; + + + +echo "'; -echo ''; + + +echo ''; echo ''; -echo ''; + + +echo ''; + +echo ''; + + + +echo ''; echo ''; +echo ''; + + +echo ''; +echo ''; + + + +echo ''; echo ''; -echo '"; -echo ""; + + +echo ""; echo "
".__('Monitor status').""; +echo ' + ' . __('Group') . '' . + html_print_select_groups(false, "AR", true, "ag_group", + $ag_group, '', '', '0', true, false, false, 'w130', + false, 'width:150px;') . ' + ' . __('Monitor status') . ""; $fields = array (); $fields[0] = __('Normal'); $fields[1] = __('Warning'); @@ -72,12 +81,16 @@ $fields[3] = __('Unknown'); $fields[4] = __('Not normal'); //default $fields[5] = __('Not init'); -html_print_select ($fields, "status", $status, '', __('All'), -1, false, false, true, '', false, 'width: 125px;'); +html_print_select ($fields, "status", $status, '', __('All'), -1, + false, false, true, '', false, 'width: 125px;'); echo ''.__('Module group').'' . __('Module group') . ''; -$rows = db_get_all_rows_sql("SELECT * FROM tmodule_group ORDER BY name"); +$rows = db_get_all_rows_sql("SELECT * + FROM tmodule_group ORDER BY name"); $rows = io_safe_output($rows); $rows_select = array(); if (!empty($rows)) @@ -87,12 +100,19 @@ if (!empty($rows)) $rows_select[0] = __('Not assigned'); html_print_select($rows_select, 'modulegroup', $modulegroup, '', __('All'), -1); +echo '
'.__('Module name').'
' . __('Module name') . ''; - $user_groups = implode (",", array_keys (users_get_groups ())); - switch ($config["dbtype"]) { case "mysql": case "postgresql": @@ -157,17 +177,19 @@ switch ($config["dbtype"]) { } //The check of is_admin - $flag_is_admin = (bool)db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']); + $flag_is_admin = (bool)db_get_value('is_admin', 'tusuario', + 'id_user', $config['id_user']); - $sql = ' SELECT distinct dbms_lob.substr(nombre,4000,1) as nombre - FROM tagente_modulo - WHERE dbms_lob.substr(nombre,4000,1) <> \'delete_pending\' AND id_agente IN - ( - SELECT id_agente - FROM tagente - WHERE'; + $sql = ' SELECT DISTINCT dbms_lob.substr(nombre,4000,1) AS nombre + FROM tagente_modulo + WHERE dbms_lob.substr(nombre,4000,1) <> \'delete_pending\' + AND id_agente IN + ( + SELECT id_agente + FROM tagente + WHERE'; - $sql .= $extra_sql.'('; + $sql .= $extra_sql . '('; if ($flag_is_admin || $flag_all_group) { $sql .= ' 1 = 1 '; @@ -190,15 +212,47 @@ $modules = db_get_all_rows_sql($sql); html_print_select (index_array ($modules, 'nombre', 'nombre'), "ag_modulename", $ag_modulename, '', __('All'), '', false, false, true, '', false, 'width: 150px;'); -echo ''.__('Search').'' . + __('Tags') . + ui_print_help_tip(__('Only it is show tags in use.'), true) . + ''; +$tags = db_get_all_rows_sql('SELECT id_tag, name + FROM ttag + WHERE id_tag IN (SELECT ttag_module.id_tag + FROM ttag_module)'); + +if (empty($tags)) { + echo __('None tag'); +} +else { + html_print_select (index_array($tags, 'id_tag', 'name'), "tag_filter", + $tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;'); +} +echo '' . + __('Search') . + ''; html_print_input_text ("ag_freestring", $ag_freestring, '', 20,30, false); +echo ''; + + +echo ''; html_print_submit_button (__('Show'), "uptbutton", false, 'class="sub search"'); +echo "
"; echo ""; @@ -321,15 +375,16 @@ switch ($sortField) { $selectDataDown = ''; $selectTimestampUp = ''; $selectTimestampDown = ''; - $order = array('field' => 'tagente.nombre', 'order' => 'ASC'); + $order = array('field' => 'tagente.nombre', + 'order' => 'ASC'); break; } // Begin Build SQL sentences -$sql = " FROM tagente, tagente_modulo, tagente_estado - WHERE $sql_extra (tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.disabled = 0 - AND tagente.disabled = 0 +$sql = " FROM tagente, tagente_modulo, tagente_estado + WHERE $sql_extra (tagente.id_agente = tagente_modulo.id_agente + AND tagente_modulo.disabled = 0 + AND tagente.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo"; // Agent group selector @@ -353,7 +408,10 @@ if ($ag_modulename != "") { // Freestring selector if ($ag_freestring != "") { - $sql .= sprintf (" AND (tagente.nombre LIKE '%%%s%%' OR tagente_modulo.nombre LIKE '%%%s%%' OR tagente_modulo.descripcion LIKE '%%%s%%')", $ag_freestring, $ag_freestring, $ag_freestring); + $sql .= sprintf (" AND (tagente.nombre LIKE '%%%s%%' + OR tagente_modulo.nombre LIKE '%%%s%%' + OR tagente_modulo.descripcion LIKE '%%%s%%')", + $ag_freestring, $ag_freestring, $ag_freestring); } // Status selector @@ -374,14 +432,33 @@ elseif ($status == 3) { //Unknown $sql .= " AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0"; } elseif ($status == 5) { //Not init - $sql .= " AND tagente_estado.utimestamp = 0 AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)"; + $sql .= " AND tagente_estado.utimestamp = 0 + AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)"; +} + +//Filter by tag +if ($tag_filter != 0) { + $sql .= " AND tagente_modulo.id_agente_modulo IN ( + SELECT ttag_module.id_agente_modulo + FROM ttag_module + WHERE ttag_module.id_tag = " . $tag_filter . " + )"; } // Build final SQL sentences -$count = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo)". $sql . ")"); +$count = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) " . + $sql . ")"); switch ($config["dbtype"]) { case "mysql": - $sql = "SELECT tagente_modulo.id_agente_modulo, + $sql = "SELECT + (SELECT GROUP_CONCAT(ttag.name SEPARATOR ',') + FROM ttag + WHERE ttag.id_tag IN ( + SELECT ttag_module.id_tag + FROM ttag_module + WHERE ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo)) + AS tags, + tagente_modulo.id_agente_modulo, tagente.intervalo AS agent_interval, tagente.nombre AS agent_name, tagente_modulo.nombre AS module_name, @@ -411,7 +488,15 @@ switch ($config["dbtype"]) { . " LIMIT ".$offset.",".$config["block_size"]; break; case "postgresql": - $sql = "SELECT tagente_modulo.id_agente_modulo, + $sql = "SELECT + (SELECT STRING_AGG(ttag.name, ',') + FROM ttag + WHERE ttag.id_tag IN ( + SELECT ttag_module.id_tag + FROM ttag_module + WHERE ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo)) + AS tags, + tagente_modulo.id_agente_modulo, tagente.intervalo AS agent_interval, tagente.nombre AS agent_name, tagente_modulo.nombre AS module_name, @@ -443,7 +528,15 @@ switch ($config["dbtype"]) { $set = array(); $set['limit'] = $config["block_size"]; $set['offset'] = $offset; - $sql = "SELECT tagente_modulo.id_agente_modulo, + $sql = "SELECT + (SELECT wmsys.wm_concat(ttag.name) + FROM ttag + WHERE ttag.id_tag IN ( + SELECT ttag_module.id_tag + FROM ttag_module + WHERE ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo)) + AS tags, + tagente_modulo.id_agente_modulo, tagente.intervalo AS agent_interval, tagente.nombre AS agent_name, tagente_modulo.nombre AS module_name, @@ -506,41 +599,38 @@ $table->head[1] = __('Agent') . ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectTypeUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectTypeDown, "alt" => "down")) . ''; - $table->align[2] = "left"; $table->head[3] = __('Module name') . ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectModuleNameUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleNameDown, "alt" => "down")) . ''; +$table->head[4] = __('Tags'); -$table->head[4] = __('Interval') . ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '' . +$table->head[5] = __('Interval') . ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown, "alt" => "down")) . ''; - -$table->align[4] = "center"; - -$table->head[5] = __('Status') . ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectStatusUp, "alt" => "up")) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectStatusDown, "alt" => "down")) . ''; - $table->align[5] = "center"; -$table->head[6] = __('Graph'); +$table->head[6] = __('Status') . ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectStatusUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectStatusDown, "alt" => "down")) . ''; $table->align[6] = "center"; -$table->head[7] = __('Warn'); -$table->align[7] = "left"; - -$table->head[8] = __('Data') . ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectDataUp, "alt" => "up")) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectDataDown, "alt" => "down")) . ''; +$table->head[7] = __('Graph'); +$table->align[7] = "center"; +$table->head[8] = __('Warn'); $table->align[8] = "left"; -$table->head[9] = __('Timestamp') . ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectTimestampUp, "alt" => "up")) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectTimestampDown, "alt" => "down")) . ''; +$table->head[9] = __('Data') . ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectDataUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectDataDown, "alt" => "down")) . ''; +$table->align[9] = "left"; -$table->align[9] = "right"; +$table->head[10] = __('Timestamp') . ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectTimestampUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectTimestampDown, "alt" => "down")) . ''; +$table->align[10] = "right"; $rowPair = true; $iterator = 0; + foreach ($result as $row) { if ($rowPair) $table->rowclass[$iterator] = 'rowPair'; @@ -601,36 +691,39 @@ foreach ($result as $row) { $data[3] .= ui_print_help_tip ($row["extended_info"], true, '/images/comments.png'); } - $data[4] = ($row['module_interval'] == 0) ? human_time_description_raw($row['agent_interval']) : human_time_description_raw($row['module_interval']); + $data[4] = $row['tags']; - if($row['utimestamp'] == 0 && (($row['module_type'] < 21 || $row['module_type'] > 23) && $row['module_type'] != 100)){ - $data[5] = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true); + $data[5] = ($row['module_interval'] == 0) ? human_time_description_raw($row['agent_interval']) : human_time_description_raw($row['module_interval']); + + if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 || + $row['module_type'] > 23) && $row['module_type'] != 100)) { + $data[6] = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true); } elseif ($row["estado"] == 0) { - $data[5] = ui_print_status_image(STATUS_MODULE_OK, __('NORMAL').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_OK, __('NORMAL').": ".$row["datos"], true); } elseif ($row["estado"] == 1) { - $data[5] = ui_print_status_image(STATUS_MODULE_CRITICAL, __('CRITICAL').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_CRITICAL, __('CRITICAL').": ".$row["datos"], true); } elseif ($row["estado"] == 2) { - $data[5] = ui_print_status_image(STATUS_MODULE_WARNING, __('WARNING').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_WARNING, __('WARNING').": ".$row["datos"], true); } else { $last_status = modules_get_agentmodule_last_status($row['id_agente_modulo']); switch($last_status) { case 0: - $data[5] = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL').": ".$row["datos"], true); break; case 1: - $data[5] = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL').": ".$row["datos"], true); break; case 2: - $data[5] = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('UNKNOWN')." - ".__('Last status')." ".__('WARNING').": ".$row["datos"], true); + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('UNKNOWN')." - ".__('Last status')." ".__('WARNING').": ".$row["datos"], true); break; } } - $data[6] = ""; + $data[7] = ""; if ($row['history_data'] == 1) { @@ -643,23 +736,23 @@ foreach ($result as $row) { $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$row["id_agente_modulo"]."&label=".base64_encode($row["module_name"])."&refresh=600','day_".$win_handle."')"; - $data[6] = '' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . ''; - $data[6] .= " " . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . ""; + $data[7] = '' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . ''; + $data[7] .= " " . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . ""; } - $data[7] = ui_print_module_warn_value($row['max_warning'], $row['min_warning'], $row['str_warning'], $row['max_critical'], $row['min_critical'], $row['str_critical']); + $data[8] = ui_print_module_warn_value($row['max_warning'], $row['min_warning'], $row['str_warning'], $row['max_critical'], $row['min_critical'], $row['str_critical']); - if (is_numeric($row["datos"])){ + if (is_numeric($row["datos"])) { $salida = format_numeric($row["datos"]); // Show units ONLY in numeric data types - if (isset($row["unit"])){ + if (isset($row["unit"])) { $salida .= " " . ''. io_safe_output($row["unit"]) . ''; } } else { $module_value = io_safe_output($row["datos"]); - $sub_string = substr(io_safe_output($row["datos"]),0, 12); + $sub_string = substr(io_safe_output($row["datos"]), 0, 12); if ($module_value == $sub_string) { $salida = $module_value; } @@ -677,20 +770,20 @@ foreach ($result as $row) { } } - $data[8] = $salida; + $data[9] = $salida; if ($row["module_interval"] > 0) $interval = $row["module_interval"]; else $interval = $row["agent_interval"]; - if ($row['estado'] == 3){ + if ($row['estado'] == 3) { $option = array ("html_attr" => 'class="redb"'); } else { $option = array (); } - $data[9] = ui_print_timestamp ($row["utimestamp"], true, $option); + $data[10] = ui_print_timestamp ($row["utimestamp"], true, $option); array_push ($table->data, $data); }