Working in the improves of agent view. Ticket: #1285

This commit is contained in:
mdtrooper 2014-12-03 16:30:11 +01:00
parent e45b8183d8
commit f25440d68a
4 changed files with 1025 additions and 698 deletions

669
pandora_console/include/ajax/module.php Normal file → Executable file
View File

@ -30,6 +30,7 @@ $add_module_relation = (bool) get_parameter('add_module_relation');
$remove_module_relation = (bool) get_parameter('remove_module_relation');
$change_module_relation_updates = (bool) get_parameter('change_module_relation_updates');
$get_id_tag = (bool) get_parameter('get_id_tag', 0);
$list_modules = (bool) get_parameter('list_modules', 0);
if ($get_plugin_macros) {
$id_plugin = get_parameter('id_plugin', 0);
@ -446,5 +447,673 @@ if ($get_id_tag) {
echo $tag_id;
return;
}
if ($list_modules) {
include_once($config['homedir'] . "/include/functions_modules.php");
include_once($config['homedir'] . "/include/functions_servers.php");
include_once($config['homedir'] . "/include/functions_tags.php");
include_once($config['homedir'] . "/include/functions_clippy.php");
$id_agente = $id_agent = (int)get_parameter('id_agente', 0);
$url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agent;
$selectTypeUp = '';
$selectTypeDown = '';
$selectNameUp = '';
$selectNameDown = '';
$selectStatusUp = '';
$selectStatusDown = '';
$selectDataUp = '';
$selectDataDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$sortField = get_parameter('sort_field');
$sort = get_parameter('sort', 'none');
$selected = 'border: 1px solid black;';
switch ($sortField) {
case 'type':
switch ($sort) {
case 'up':
$selectTypeUp = $selected;
$order = array('field' => 'tagente_modulo.id_tipo_modulo', 'order' => 'ASC');
break;
case 'down':
$selectTypeDown = $selected;
$order = array('field' => 'tagente_modulo.id_tipo_modulo', 'order' => 'DESC');
break;
}
break;
case 'name':
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
case 'down':
$selectNameDown = $selected;
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC');
break;
}
break;
case 'status':
switch ($sort) {
case 'up':
$selectStatusUp = $selected;
$order = array('field' => 'tagente_estado.estado', 'order' => 'ASC');
break;
case 'down':
$selectStatusDown = $selected;
$order = array('field' => 'tagente_estado.estado', 'order' => 'DESC');
break;
}
break;
case 'data':
switch ($sort) {
case 'up':
$selectDataUp = $selected;
$order = array('field' => 'tagente_estado.datos', 'order' => 'ASC');
break;
case 'down':
$selectDataDown = $selected;
$order = array('field' => 'tagente_estado.datos', 'order' => 'DESC');
break;
}
break;
case 'last_contact':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'tagente_estado.utimestamp', 'order' => 'ASC');
break;
case 'down':
$selectLastContactDown = $selected;
$order = array('field' => 'tagente_estado.utimestamp', 'order' => 'DESC');
break;
}
break;
default:
$selectTypeUp = '';
$selectTypeDown = '';
$selectNameUp = $selected;
$selectNameDown = '';
$selectStatusUp = '';
$selectStatusDown = '';
$selectDataUp = '';
$selectDataDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
}
switch ($config["dbtype"]) {
case "oracle":
if (isset($order['field']) && $order['field'] == 'tagente_modulo.nombre') {
$order['field'] = 'dbms_lob.substr(tagente_modulo.nombre,4000,1)';
}
break;
}
// Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!)
$groups = users_get_groups($config["id_user"]);
$tags_sql = tags_get_acl_tags($config['id_user'],
array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo');
$status_filter_monitor = (int)get_parameter('status_filter_monitor', -1);
$status_text_monitor = get_parameter('status_text_monitor', '');
$filter_monitors = (bool)get_parameter('filter_monitors', false);
$monitors_change_filter = (bool)get_parameter('monitors_change_filter', false);
$status_filter_sql = '1 = 1';
if ($status_filter_monitor == AGENT_MODULE_STATUS_NOT_NORMAL) { //Not normal
$status_filter_sql = " tagente_estado.estado <> 0";
}
elseif ($status_filter_monitor != -1) {
$status_filter_sql = 'tagente_estado.estado = ' . $status_filter_monitor;
}
$status_text_monitor_sql = '%';
if (!empty($status_text_monitor)) {
$status_text_monitor_sql .= $status_text_monitor . '%';
}
//Count monitors/modules
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf("
SELECT COUNT(*)
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE \"%s\" AND delete_pending = 0
AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
break;
case "postgresql":
$sql = sprintf("
SELECT COUNT(DISTINCT tagente_modulo.id_module_group)
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE '%s'
AND delete_pending = 0
AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
GROUP BY tagente_modulo.id_module_group,
tagente_modulo.nombre
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql, $status_filter_sql,
$tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'],
$order['order']);
break;
case "oracle":
$sql = sprintf ("
SELECT COUNT(*)" .
" FROM tagente_estado, tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente = %d
AND tagente_modulo.nombre LIKE '%s'
AND %s %s
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.estado != %d
ORDER BY tagente_modulo.id_module_group , %s %s
", $id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
break;
}
$count_modules = db_get_all_rows_sql($sql);
if (isset($count_modules[0]))
$count_modules = reset($count_modules[0]);
else
$count_modules = 0;
//Get monitors/modules
// Get all module from agent
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf("
SELECT *
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE \"%s\" AND delete_pending = 0
AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
break;
case "postgresql":
$sql = sprintf("
SELECT *
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE '%s' AND delete_pending = 0
AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
break;
// If Dbms is Oracle then field_list in sql statement has to be recoded. See oracle_list_all_field_table()
case "oracle":
$fields_tagente_estado = oracle_list_all_field_table('tagente_estado', 'string');
$fields_tagente_modulo = oracle_list_all_field_table('tagente_modulo', 'string');
$fields_tmodule_group = oracle_list_all_field_table('tmodule_group', 'string');
$sql = sprintf ("
SELECT " . $fields_tagente_estado . ', ' . $fields_tagente_modulo . ', ' . $fields_tmodule_group .
" FROM tagente_estado, tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente = %d
AND tagente_modulo.nombre LIKE '%s'
AND %s %s
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.estado != %d
ORDER BY tagente_modulo.id_module_group , %s %s
", $id_agente, $status_text_monitor_sql, $tags_sql, $status_filter_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
break;
}
if ($monitors_change_filter) {
$limit = " LIMIT " . $config['block_size'] . " OFFSET 0";
}
else {
$limit = " LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
}
$paginate_module = false;
if (isset($config['paginate_module']))
$paginate_module = $config['paginate_module'];
if ($paginate_module) {
$modules = db_get_all_rows_sql ($sql . $limit);
}
else {
$modules = db_get_all_rows_sql ($sql);
}
if (empty ($modules)) {
$modules = array ();
}
$table->width = "98%";
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->class = "databox";
$table->head = array ();
$table->data = array ();
$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php');
$table->head[0] = "<span title='" . __('Force execution') . "'>" . __('F.') . "</span>";
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
$table->head[1] = "<span title='" . __('Policy') . "'>" . __('P.') . "</span>";
}
$table->head[2] = __('Type') . ' ' .
'<a href="' . $url . '&sort_field=type&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectTypeUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&sort_field=type&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectTypeDown, "alt" => "down")) . '</a>';
$table->head[3] = __('Module name') . ' ' .
'<a href="javascript: order_module_list(\'name\', \'up\');">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
'<a href="javascript: order_module_list(\'name\', \'down\');">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
$table->head[4] = __('Description');
$table->head[5] = __('Status') . ' ' .
'<a href="' . $url . '&sort_field=status&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectStatusUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&sort_field=status&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectStatusDown, "alt" => "down")) . '</a>';
$table->head[6] = __('Warn');
$table->head[7] = __('Data') . ' ' .
'<a href="' . $url . '&sort_field=data&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectDataUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&sort_field=data&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectDataDown, "alt" => "down")) . '</a>';
$table->head[8] = __('Graph');
$table->head[9] = __('Last contact') . ' ' .
'<a href="' . $url . '&sort_field=last_contact&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectLastContactUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&sort_field=last_contact&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectLastContactDown, "alt" => "down")) . '</a>';
$table->align = array("left", "left", "center", "left", "left", "center");
$last_modulegroup = 0;
$rowIndex = 0;
$id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo',
'nombre', 'web_content_string');
$show_context_help_first_time = false;
foreach ($modules as $module) {
//The code add the row of 1 cell with title of group for to be more organice the list.
if ($module["id_module_group"] != $last_modulegroup)
{
$table->colspan[$rowIndex][0] = count($table->head);
$table->rowclass[$rowIndex] = 'datos4';
array_push ($table->data, array ('<b>'.$module['name'].'</b>'));
$rowIndex++;
$last_modulegroup = $module["id_module_group"];
}
//End of title of group
//Fixed the goliat sends the strings from web
//without HTML entities
if ($module['id_tipo_modulo'] == $id_type_web_content_string) {
$module['datos'] = io_safe_input($module['datos']);
}
$data = array ();
if (($module["id_modulo"] != 1) && ($module["id_tipo_modulo"] != 100)) {
if ($module["flag"] == 0) {
$data[0] = '<a href="index.php?' .
'sec=estado&amp;' .
'sec2=operation/agentes/ver_agente&amp;' .
'id_agente=' . $id_agente . '&amp;' .
'id_agente_modulo=' . $module["id_agente_modulo"] . '&amp;' .
'flag=1&amp;' .
'refr=60">' . html_print_image("images/target.png", true, array("border" => '0', "title" => __('Force'))) . '</a>';
}
else {
$data[0] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'&amp;id_agente_modulo='.$module["id_agente_modulo"].'&amp;refr=60">' . html_print_image("images/refresh.png", true, array("border" => "0", "title" => __("Refresh"))) . '</a>';
}
}
else {
$data[0] = '';
}
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
if ($module["id_policy_module"] != 0) {
$linked = policies_is_module_linked($module['id_agente_modulo']);
$id_policy = db_get_value_sql('SELECT id_policy FROM tpolicy_modules WHERE id = '.$module["id_policy_module"]);
if ($id_policy != "")
$name_policy = db_get_value_sql('SELECT name FROM tpolicies WHERE id = '.$id_policy);
else
$name_policy = __("Unknown");
$policyInfo = policies_info_module_policy($module["id_policy_module"]);
$adopt = false;
if (policies_is_module_adopt($module['id_agente_modulo'])) {
$adopt = true;
}
if ($linked) {
if ($adopt) {
$img = 'images/policies_brick.png';
$title = '(' . __('Adopted') . ') ' . $name_policy;
}
else {
$img = 'images/policies.png';
$title = $name_policy;
}
}
else {
if ($adopt) {
$img = 'images/policies_not_brick.png';
$title = '(' . __('Unlinked') . ') (' . __('Adopted') . ') ' . $name_policy;
}
else {
$img = 'images/unlinkpolicy.png';
$title = '(' . __('Unlinked') . ') ' . $name_policy;
}
}
$data[1] = '<a href="?sec=gpolicies&amp;sec2=enterprise/godmode/policies/policies&amp;id=' . $id_policy . '">' .
html_print_image($img,true, array('title' => $title)) .
'</a>';
}
else {
$data[1] = "";
}
}
$data[2] = servers_show_type ($module['id_modulo']) . '&nbsp;';
if (check_acl ($config['id_user'], $id_grupo, "AW"))
$data[2] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$id_agente.'&amp;tab=module&amp;id_agent_module='.$module["id_agente_modulo"].'&amp;edit_module='.$module["id_modulo"].'">' . html_print_image("images/config.png", true, array("alt" => '0', "border" => "", "title" => __('Edit'))) . '</a>';
$data[3] = "";
if ($module['quiet']) {
$data[3] .= html_print_image("images/dot_green.disabled.png", true,
array("border" => '0', "title" => __('Quiet'), "alt" => ""))
. "&nbsp;";
}
$data[3] .= ui_print_truncate_text($module["nombre"], 'module_medium');
if (!empty($module["extended_info"])) {
if ($module["extended_info"] != "") {
$data[3] .= ui_print_help_tip ($module["extended_info"], true, '/images/default_list.png');
}
}
//Adds tag context information
if (tags_get_modules_tag_count($module['id_agente_modulo']) > 0) {
$data[3] .= ' <a class="tag_details" href="ajax.php?page=operation/agentes/estado_monitores&get_tag_tooltip=1&id_agente_modulo='.$module['id_agente_modulo'].'">' .
html_print_image("images/tag_red.png", true, array("id" => 'tag-details-'.$module['id_agente_modulo'], "class" => "img_help")) . '</a> ';
}
//Adds relations context information
if (modules_relation_exists($module['id_agente_modulo'])) {
$data[3] .= ' <a class="relations_details" href="ajax.php?page=operation/agentes/estado_monitores&get_relations_tooltip=1&id_agente_modulo='.$module['id_agente_modulo'].'">' .
html_print_image("images/link2.png", true, array("id" => 'relations-details-'.$module['id_agente_modulo'], "class" => "img_help")) . '</a> ';
}
$data[4] = ui_print_string_substr ($module["descripcion"], 60, true, 8);
if ($module["datos"] != strip_tags($module["datos"])) {
$module_value = io_safe_input($module["datos"]);
}
else {
$module_value = io_safe_output($module["datos"]);
}
modules_get_status($module['id_agente_modulo'], $module['estado'],
$module_value, $status, $title);
$data[5] = ui_print_status_image($status, $title, true);
if (!$show_context_help_first_time) {
$show_context_help_first_time = true;
if ($module['estado'] == AGENT_MODULE_STATUS_UNKNOWN) {
$data[5] .= clippy_context_help("module_unknow");
}
}
if ($module["id_tipo_modulo"] == 24) {
// log4x
switch($module["datos"]) {
case 10:
$salida = "TRACE";
$style="font-weight:bold; color:darkgreen;";
break;
case 20:
$salida = "DEBUG";
$style="font-weight:bold; color:darkgreen;";
break;
case 30:
$salida = "INFO";
$style="font-weight:bold; color:darkgreen;";
break;
case 40:
$salida = "WARN";
$style="font-weight:bold; color:darkorange;";
break;
case 50:
$salida = "ERROR";
$style="font-weight:bold; color:red;";
break;
case 60:
$salida = "FATAL";
$style="font-weight:bold; color:red;";
break;
}
$salida = "<span style='$style'>$salida</span>";
}
else {
if (is_numeric($module["datos"]) && !modules_is_string_type($module['id_tipo_modulo'])){
$salida = format_numeric($module["datos"]);
// Show units ONLY in numeric data types
if (isset($module["unit"])){
$salida .= "&nbsp;" . '<i>'. io_safe_output($module["unit"]) . '</i>';
}
}
else {
//Fixed the goliat sends the strings from web
//without HTML entities
if ($module['id_tipo_modulo'] == $id_type_web_content_string) {
$module_value = $module["datos"];
}
else {
$module_value = io_safe_output($module["datos"]);
}
// If carriage returns present... then is a "Snapshot" data (full command output)
$is_snapshot = is_snapshot_data ( $module_value );
if (($config['command_snapshot']) && ($is_snapshot)) {
$handle = "snapshot" . "_" . $module["id_agente_modulo"];
$url = 'include/procesos.php?agente=' . $module["id_agente_modulo"];
$win_handle = dechex(crc32($handle));
$link ="winopeng_var('operation/agentes/snapshot_view.php?" .
"id=" . $module["id_agente_modulo"] .
"&refr=" . $module["current_interval"] .
"&label=" . rawurlencode(urlencode(io_safe_output($module["nombre"]))) . "','".$win_handle."', 700,480)";
$salida = '<a href="javascript:'.$link.'">' .
html_print_image("images/default_list.png", true,
array(
"border" => '0',
"alt" => "",
"title" => __("Snapshot view"))) . '</a> &nbsp;&nbsp;';
}
else {
//Fixed the goliat sends the strings from web
//without HTML entities
if ($module['id_tipo_modulo'] == $id_type_web_content_string) {
$sub_string = substr($module_value, 0, 12);
}
else {
//Fixed the data from Selenium Plugin
if ($module_value != strip_tags($module_value)) {
$module_value = io_safe_input($module_value);
$sub_string = substr($module_value, 0, 12);
}
else {
$sub_string = substr(io_safe_output($module_value),0, 12);
}
}
if ($module_value == $sub_string) {
$salida = $module_value;
}
else {
$salida = "<span " .
"id='hidden_value_module_" . $module["id_agente_modulo"] . "'
style='display: none;'>" .
$module_value .
"</span>" .
"<span " .
"id='value_module_" . $module["id_agente_modulo"] . "'
title='" . $module_value . "' " .
"style='white-space: nowrap;'>" .
'<span id="value_module_text_' . $module["id_agente_modulo"] . '">' .
$sub_string . '</span> ' .
"<a href='javascript: toggle_full_value(" . $module["id_agente_modulo"] . ")'>" .
html_print_image("images/rosette.png", true) . "</a>" . "</span>";
}
}
}
}
$data[6] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]);
$data[7] = $salida;
$graph_type = return_graphtype ($module["id_tipo_modulo"]);
$data[8] = " ";
if ($module['history_data'] == 1) {
$nombre_tipo_modulo = modules_get_moduletype_name ($module["id_tipo_modulo"]);
$handle = "stat".$nombre_tipo_modulo."_".$module["id_agente_modulo"];
$url = 'include/procesos.php?agente='.$module["id_agente_modulo"];
$win_handle=dechex(crc32($module["id_agente_modulo"].$module["nombre"]));
# Show events for boolean modules by default.
if ($graph_type == 'boolean') {
$draw_events = 1;
} else {
$draw_events = 0;
}
$link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&amp;period=86400&amp;id=".$module["id_agente_modulo"]."&amp;label=".rawurlencode(urlencode(base64_encode($module["nombre"])))."&amp;refresh=600&amp;draw_events=$draw_events','day_".$win_handle."')";
$data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;';
$server_name = '';
$data[8] .= "<a href='javascript: show_module_detail_dialog(" . $module["id_agente_modulo"] . ", ". $id_agente.", \"" . $server_name . "\", 0, 86400)'>". html_print_image ("images/binary.png", true, array ("border" => "0", "alt" => "")) . "</a>";
}
if ($module['estado'] == 3) {
$data[9] = '<span class="redb">';
}
else {
$data[9] = '<span>';
}
$data[9] .= ui_print_timestamp ($module["utimestamp"], true, array('style' => 'font-size: 7pt'));
$data[9] .= '</span>';
array_push ($table->data, $data);
$rowIndex++;
}
?>
<script type="text/javascript">
function toggle_full_value(id) {
text = $("#hidden_value_module_" + id).html();
old_text = $("#value_module_text_" + id).html();
$("#hidden_value_module_" + id).html(old_text);
$("#value_module_text_" + id).html(text);
}
</script>
<?php
if (empty ($table->data)) {
if ($filter_monitors) {
echo '<div class="nf">' .
__('Any monitors aren\'t with this filter.') . '</div>';
}
else {
echo '<div class="nf">' .
__('This agent doesn\'t have any active monitors.') . '</div>';
}
}
else {
$url = "index.php?" .
"sec=estado&" .
"sec2=operation/agentes/ver_agente&" .
"id_agente=" . $id_agente . "&" .
"refr=&filter_monitors=1&" .
"status_filter_monitor=" . $status_filter_monitor . "&" .
"status_text_monitor=" . $status_text_monitor;
if ($paginate_module) {
ui_pagination ($count_modules, false, 0, 0, false, 'offset',
true, '',
"pagination_list_modules(offset_param)",
array('count' => '', 'offset' => 'offset_param'));
}
html_print_table ($table);
if ($paginate_module) {
ui_pagination ($count_modules, false, 0, 0, false, 'offset',
true, '',
"pagination_list_modules(offset_param)",
array('count' => '', 'offset' => 'offset_param'));
}
}
unset ($table);
unset ($table_data);
}
?>

78
pandora_console/include/functions_ui.php Normal file → Executable file
View File

@ -1550,7 +1550,9 @@ function ui_process_page_body ($string, $bitfield) {
*/
function ui_pagination ($count, $url = false, $offset = 0,
$pagination = 0, $return = false, $offset_name = 'offset',
$print_total_items = true, $other_class = '') {
$print_total_items = true, $other_class = '',
$script = "",
$parameter_script = array('count' => '', 'offset' => 'offset_param')) {
global $config;
@ -1624,10 +1626,25 @@ function ui_pagination ($count, $url = false, $offset = 0,
// Show GOTO FIRST PAGE button
if ($number_of_pages > $block_limit) {
if (!empty($script)) {
$script_modified = $script;
$script_modified = str_replace(
$parameter_script['count'], $count, $script_modified);
$script_modified = str_replace(
$parameter_script['offset'], 0, $script_modified);
$output .= "<a class='pagination $other_class offset_0'
href='javascript: $script_modified;'>" .
html_print_image ("images/go_first.png", true, array ("class" => "bot")) .
"</a>&nbsp;";
}
else {
$output .= "<a class='pagination $other_class offset_0' href='$url&amp;$offset_name=0'>" .
html_print_image ("images/go_first.png", true, array ("class" => "bot")) .
"</a>&nbsp;";
}
}
// Show PREVIOUS PAGE GROUP OF PAGES
// For example
@ -1637,10 +1654,25 @@ function ui_pagination ($count, $url = false, $offset = 0,
// Result << < 5 - 6 - 7 - 8 - [9] > >>
if ($ini_page >= $block_limit) {
$offset_previous_page = ($ini_page - 1) * $pagination;
if (!empty($script)) {
$script_modified = $script;
$script_modified = str_replace(
$parameter_script['count'], $count, $script_modified);
$script_modified = str_replace(
$parameter_script['offset'], $offset_previous_page, $script_modified);
$output .= "<a class='pagination $other_class offset_$offset_previous_page'
href='javacript: $script_modified;'>" .
html_print_image ("images/go_previous.png", true, array ("class" => "bot")) .
"</a>";
}
else {
$output .= "<a class='pagination $other_class offset_$offset_previous_page' href='$url&amp;$offset_name=$offset_previous_page'>" .
html_print_image ("images/go_previous.png", true, array ("class" => "bot")) .
"</a>";
}
}
// Show pages
@ -1657,8 +1689,22 @@ function ui_pagination ($count, $url = false, $offset = 0,
$offset_page = $iterator * $pagination;
if (!empty($script)) {
$script_modified = $script;
$script_modified = str_replace(
$parameter_script['count'], $count, $script_modified);
$script_modified = str_replace(
$parameter_script['offset'], $offset_page, $script_modified);
$output .= "<a class='pagination $other_class offset_$offset_page'
href='javascript: $script_modified;'>";
}
else {
$output .= "<a class='pagination $other_class offset_$offset_page' href='$url&amp;$offset_name=$offset_page'>";
}
$output .= "[ $iterator ]";
$output .= '</a></span>';
@ -1674,19 +1720,49 @@ function ui_pagination ($count, $url = false, $offset = 0,
// Result << < [15] - 16 - 17 - 18 - 19 > >>
if ($number_of_pages - $ini_page > $block_limit) {
$offset_next_page = ($end_page + 1) * $pagination;
if (!empty($script)) {
$script_modified = $script;
$script_modified = str_replace(
$parameter_script['count'], $count, $script_modified);
$script_modified = str_replace(
$parameter_script['offset'], $offset_next_page, $script_modified);
$output .= "<a class='pagination $other_class offset_$offset_next_page'
href='javascript: $script_modified;'>" .
html_print_image ("images/go_next.png", true, array ("class" => "bot")) .
"</a>";
}
else {
$output .= "<a class='pagination $other_class offset_$offset_next_page' href='$url&amp;$offset_name=$offset_next_page'>" .
html_print_image ("images/go_next.png", true, array ("class" => "bot")) .
"</a>";
}
}
//Show GOTO LAST PAGE button
if ($number_of_pages > $block_limit) {
$offset_lastpage = ($number_of_pages - 1) * $pagination;
if (!empty($script)) {
$script_modified = $script;
$script_modified = str_replace(
$parameter_script['count'], $count, $script_modified);
$script_modified = str_replace(
$parameter_script['offset'], $offset_lastpage, $script_modified);
$output .= "<a class='pagination $other_class offset_$offset_lastpage'
href='javascript: $script_modified;'>" .
html_print_image ("images/go_last.png", true, array ("class" => "bot")) .
"</a>";
}
else {
$output .= "<a class='pagination $other_class offset_$offset_lastpage' href='$url&amp;$offset_name=$offset_lastpage'>" .
html_print_image ("images/go_last.png", true, array ("class" => "bot")) .
"</a>";
}
}
// End div and layout
$output .= "</div>";

116
pandora_console/operation/agentes/alerts_status.php Normal file → Executable file
View File

@ -136,22 +136,70 @@ if ($free_search != '') {
switch ($config["dbtype"]) {
case "mysql":
$whereAlertSimple = 'AND (' .
'id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE "%' . $free_search . '%") OR ' .
'id_alert_template IN (SELECT id FROM talert_templates WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%")) OR ' .
'talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE "%' . $free_search . '%")) OR ' .
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE "%' . $free_search . '%") OR ' .
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN (SELECT id_agente FROM tagente WHERE nombre LIKE "%' . $free_search . '%"))' .
'id_alert_template IN (
SELECT id
FROM talert_templates
WHERE name LIKE "%' . $free_search . '%") OR ' .
'id_alert_template IN (
SELECT id
FROM talert_templates
WHERE id_alert_action IN (
SELECT id
FROM talert_actions
WHERE name LIKE "%' . $free_search . '%")) OR ' .
'talert_template_modules.id IN (
SELECT id_alert_template_module
FROM talert_template_module_actions
WHERE id_alert_action IN (
SELECT id
FROM talert_actions
WHERE name LIKE "%' . $free_search . '%")) OR ' .
'id_agent_module IN (
SELECT id_agente_modulo
FROM tagente_modulo
WHERE nombre LIKE "%' . $free_search . '%") OR ' .
'id_agent_module IN (
SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_agente IN (
SELECT id_agente
FROM tagente
WHERE nombre LIKE "%' . $free_search . '%"))' .
')';
break;
case "postgresql":
case "oracle":
$whereAlertSimple = 'AND (' .
'id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE \'%' . $free_search . '%\') OR ' .
'id_alert_template IN (SELECT id FROM talert_templates WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE \'%' . $free_search . '%\')) OR ' .
'talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action IN (SELECT id FROM talert_actions WHERE name LIKE \'%' . $free_search . '%\')) OR ' .
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE nombre LIKE \'%' . $free_search . '%\') OR ' .
'id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN (SELECT id_agente FROM tagente WHERE nombre LIKE \'%' . $free_search . '%\'))' .
'id_alert_template IN (
SELECT id
FROM talert_templates
WHERE name LIKE \'%' . $free_search . '%\') OR ' .
'id_alert_template IN (
SELECT id
FROM talert_templates
WHERE id_alert_action IN (
SELECT id
FROM talert_actions
WHERE name LIKE \'%' . $free_search . '%\')) OR ' .
'talert_template_modules.id IN (
SELECT id_alert_template_module
FROM talert_template_module_actions
WHERE id_alert_action IN (
SELECT id
FROM talert_actions
WHERE name LIKE \'%' . $free_search . '%\')) OR ' .
'id_agent_module IN (
SELECT id_agente_modulo
FROM tagente_modulo
WHERE nombre LIKE \'%' . $free_search . '%\') OR ' .
'id_agent_module IN (
SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_agente IN (
SELECT id_agente
FROM tagente
WHERE nombre LIKE \'%' . $free_search . '%\'))' .
')';
break;
@ -333,7 +381,10 @@ if ($pure) {
// Filter form
if ($print_agent) {
echo '<br>';
ui_toggle(printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby, true),__('Alert control filter'), __('Toggle filter(s)'));
ui_toggle(
printFormFilterAlert(
$id_group, $filter, $free_search, $url, $filter_standby, true),
__('Alert control filter'), __('Toggle filter(s)'));
}
$table->width = '100%';
@ -377,14 +428,26 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
// Sort buttons are only for normal console
if (!defined('METACONSOLE')) {
$table->head[3] .= ' ' .
'<a href="' . $url . '&sort_field=agent&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectAgentUp)) . '</a>' .
'<a href="' . $url . '&sort_field=agent&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectAgentDown)) . '</a>';
'<a href="' . $url . '&sort_field=agent&sort=up">' .
html_print_image("images/sort_up.png", true,
array("style" => $selectAgentUp)) . '</a>' .
'<a href="' . $url . '&sort_field=agent&sort=down">' .
html_print_image("images/sort_down.png", true,
array("style" => $selectAgentDown)) . '</a>';
$table->head[4] .= ' ' .
'<a href="' . $url . '&sort_field=module&sort=up">' . html_print_image("images/sort_up.png", true, array("style" =>$selectModuleUp)) . '</a>' .
'<a href="' . $url . '&sort_field=module&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleDown)) . '</a>';
'<a href="' . $url . '&sort_field=module&sort=up">' .
html_print_image("images/sort_up.png", true,
array("style" =>$selectModuleUp)) . '</a>' .
'<a href="' . $url . '&sort_field=module&sort=down">' .
html_print_image("images/sort_down.png", true,
array("style" => $selectModuleDown)) . '</a>';
$table->head[5] .= ' ' .
'<a href="' . $url . '&sort_field=template&sort=up">' . html_print_image("images/sort_up.png", true, array("style" =>$selectTemplateUp)) . '</a>' .
'<a href="' . $url . '&sort_field=template&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectTemplateDown)) . '</a>';
'<a href="' . $url . '&sort_field=template&sort=up">' .
html_print_image("images/sort_up.png", true,
array("style" =>$selectTemplateUp)) . '</a>' .
'<a href="' . $url . '&sort_field=template&sort=down">' .
html_print_image("images/sort_down.png", true,
array("style" => $selectTemplateDown)) . '</a>';
}
}
else {
@ -414,16 +477,23 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
// Sort buttons are only for normal console
if (!defined('METACONSOLE')) {
$table->head[3] .= ' ' .
'<a href="' . $url . '&sort_field=module&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectModuleUp)) . '</a>' .
'<a href="' . $url . '&sort_field=module&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleDown)) . '</a>';
'<a href="' . $url . '&sort_field=module&sort=up">' .
html_print_image("images/sort_up.png", true,
array("style" => $selectModuleUp)) . '</a>' .
'<a href="' . $url . '&sort_field=module&sort=down">' .
html_print_image("images/sort_down.png", true,
array("style" => $selectModuleDown)) . '</a>';
$table->head[4] .= ' ' .
'<a href="' . $url . '&sort_field=template&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectTemplateUp)) . '</a>' .
'<a href="' . $url . '&sort_field=template&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectTemplateDown)) . '</a>';
'<a href="' . $url . '&sort_field=template&sort=up">' .
html_print_image("images/sort_up.png", true,
array("style" => $selectTemplateUp)) . '</a>' .
'<a href="' . $url . '&sort_field=template&sort=down">' .
html_print_image("images/sort_down.png", true,
array("style" => $selectTemplateDown)) . '</a>';
}
}
}
else
{
else {
if ($print_agent) {
$table->head[0] = "<span title='" . __('Standby') . "'>" . __('S.') . "</span>";
if (!defined('METACONSOLE')) {

View File

@ -99,632 +99,16 @@ if (!isset ($id_agente)) {
exit;
}
include_once($config['homedir'] . "/include/functions_modules.php");
include_once($config['homedir'] . "/include/functions_servers.php");
include_once($config['homedir'] . "/include/functions_tags.php");
include_once($config['homedir'] . "/include/functions_clippy.php");
$id_agent = get_parameter('id_agente');
$url = 'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=' . $id_agent;
$selectTypeUp = '';
$selectTypeDown = '';
$selectNameUp = '';
$selectNameDown = '';
$selectStatusUp = '';
$selectStatusDown = '';
$selectDataUp = '';
$selectDataDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$sortField = get_parameter('sort_field');
$sort = get_parameter('sort', 'none');
$selected = 'border: 1px solid black;';
switch ($sortField) {
case 'type':
switch ($sort) {
case 'up':
$selectTypeUp = $selected;
$order = array('field' => 'tagente_modulo.id_tipo_modulo', 'order' => 'ASC');
break;
case 'down':
$selectTypeDown = $selected;
$order = array('field' => 'tagente_modulo.id_tipo_modulo', 'order' => 'DESC');
break;
}
break;
case 'name':
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
case 'down':
$selectNameDown = $selected;
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'DESC');
break;
}
break;
case 'status':
switch ($sort) {
case 'up':
$selectStatusUp = $selected;
$order = array('field' => 'tagente_estado.estado', 'order' => 'ASC');
break;
case 'down':
$selectStatusDown = $selected;
$order = array('field' => 'tagente_estado.estado', 'order' => 'DESC');
break;
}
break;
case 'data':
switch ($sort) {
case 'up':
$selectDataUp = $selected;
$order = array('field' => 'tagente_estado.datos', 'order' => 'ASC');
break;
case 'down':
$selectDataDown = $selected;
$order = array('field' => 'tagente_estado.datos', 'order' => 'DESC');
break;
}
break;
case 'last_contact':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'tagente_estado.utimestamp', 'order' => 'ASC');
break;
case 'down':
$selectLastContactDown = $selected;
$order = array('field' => 'tagente_estado.utimestamp', 'order' => 'DESC');
break;
}
break;
default:
$selectTypeUp = '';
$selectTypeDown = '';
$selectNameUp = $selected;
$selectNameDown = '';
$selectStatusUp = '';
$selectStatusDown = '';
$selectDataUp = '';
$selectDataDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$order = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
break;
}
switch ($config["dbtype"]) {
case "oracle":
if (isset($order['field']) && $order['field'] == 'tagente_modulo.nombre') {
$order['field'] = 'dbms_lob.substr(tagente_modulo.nombre,4000,1)';
}
break;
}
// Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!)
$groups = users_get_groups($config["id_user"]);
$tags_sql = tags_get_acl_tags($config['id_user'],
array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo');
$id_agent = (int)get_parameter('id_agente');
$status_filter_monitor = (int)get_parameter('status_filter_monitor', -1);
$status_text_monitor = get_parameter('status_text_monitor', '');
$filter_monitors = (bool)get_parameter('filter_monitors', false);
$monitors_change_filter = (bool)get_parameter('monitors_change_filter', false);
$status_filter_sql = '1 = 1';
if ($status_filter_monitor == AGENT_MODULE_STATUS_NOT_NORMAL) { //Not normal
$status_filter_sql = " tagente_estado.estado <> 0";
}
elseif ($status_filter_monitor != -1) {
$status_filter_sql = 'tagente_estado.estado = ' . $status_filter_monitor;
}
$status_text_monitor_sql = '%';
if (!empty($status_text_monitor)) {
$status_text_monitor_sql .= $status_text_monitor . '%';
}
//Count monitors/modules
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf("
SELECT COUNT(*)
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE \"%s\" AND delete_pending = 0
AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
break;
case "postgresql":
$sql = sprintf("
SELECT COUNT(DISTINCT tagente_modulo.id_module_group)
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE '%s'
AND delete_pending = 0
AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
GROUP BY tagente_modulo.id_module_group,
tagente_modulo.nombre
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql, $status_filter_sql,
$tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'],
$order['order']);
break;
case "oracle":
$sql = sprintf ("
SELECT COUNT(*)" .
" FROM tagente_estado, tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente = %d
AND tagente_modulo.nombre LIKE '%s'
AND %s %s
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.estado != %d
ORDER BY tagente_modulo.id_module_group , %s %s
", $id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
break;
}
$count_modules = db_get_all_rows_sql($sql);
if (isset($count_modules[0]))
$count_modules = reset($count_modules[0]);
else
$count_modules = 0;
//Get monitors/modules
// Get all module from agent
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf("
SELECT *
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE \"%s\" AND delete_pending = 0
AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
break;
case "postgresql":
$sql = sprintf("
SELECT *
FROM tagente_estado,
(SELECT *
FROM tagente_modulo
WHERE id_agente = %d AND nombre LIKE '%s' AND delete_pending = 0
AND disabled = 0) tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND %s %s
AND tagente_estado.estado != %d
ORDER BY tagente_modulo.id_module_group , %s %s",
$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
break;
// If Dbms is Oracle then field_list in sql statement has to be recoded. See oracle_list_all_field_table()
case "oracle":
$fields_tagente_estado = oracle_list_all_field_table('tagente_estado', 'string');
$fields_tagente_modulo = oracle_list_all_field_table('tagente_modulo', 'string');
$fields_tmodule_group = oracle_list_all_field_table('tmodule_group', 'string');
$sql = sprintf ("
SELECT " . $fields_tagente_estado . ', ' . $fields_tagente_modulo . ', ' . $fields_tmodule_group .
" FROM tagente_estado, tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente = %d
AND tagente_modulo.nombre LIKE '%s'
AND %s %s
AND tagente_modulo.delete_pending = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.estado != %d
ORDER BY tagente_modulo.id_module_group , %s %s
", $id_agente, $status_text_monitor_sql, $tags_sql, $status_filter_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
break;
}
if ($monitors_change_filter) {
$limit = " LIMIT " . $config['block_size'] . " OFFSET 0";
}
else {
$limit = " LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
}
$paginate_module = false;
if (isset($config['paginate_module']))
$paginate_module = $config['paginate_module'];
if ($paginate_module) {
$modules = db_get_all_rows_sql ($sql . $limit);
}
else {
$modules = db_get_all_rows_sql ($sql);
}
if (empty ($modules)) {
$modules = array ();
}
$table->width = "98%";
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->class = "databox";
$table->head = array ();
$table->data = array ();
$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php');
$table->head[0] = "<span title='" . __('Force execution') . "'>" . __('F.') . "</span>";
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
$table->head[1] = "<span title='" . __('Policy') . "'>" . __('P.') . "</span>";
}
$table->head[2] = __('Type') . ' ' .
'<a href="' . $url . '&sort_field=type&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectTypeUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&sort_field=type&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectTypeDown, "alt" => "down")) . '</a>';
$table->head[3] = __('Module name') . ' ' .
'<a href="' . $url . '&sort_field=name&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&sort_field=name&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
$table->head[4] = __('Description');
$table->head[5] = __('Status') . ' ' .
'<a href="' . $url . '&sort_field=status&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectStatusUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&sort_field=status&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectStatusDown, "alt" => "down")) . '</a>';
$table->head[6] = __('Warn');
$table->head[7] = __('Data') . ' ' .
'<a href="' . $url . '&sort_field=data&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectDataUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&sort_field=data&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectDataDown, "alt" => "down")) . '</a>';
$table->head[8] = __('Graph');
$table->head[9] = __('Last contact') . ' ' .
'<a href="' . $url . '&sort_field=last_contact&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectLastContactUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&sort_field=last_contact&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectLastContactDown, "alt" => "down")) . '</a>';
$table->align = array("left", "left", "center", "left", "left", "center");
$last_modulegroup = 0;
$rowIndex = 0;
$id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo',
'nombre', 'web_content_string');
$show_context_help_first_time = false;
foreach ($modules as $module) {
//The code add the row of 1 cell with title of group for to be more organice the list.
if ($module["id_module_group"] != $last_modulegroup)
{
$table->colspan[$rowIndex][0] = count($table->head);
$table->rowclass[$rowIndex] = 'datos4';
array_push ($table->data, array ('<b>'.$module['name'].'</b>'));
$rowIndex++;
$last_modulegroup = $module["id_module_group"];
}
//End of title of group
//Fixed the goliat sends the strings from web
//without HTML entities
if ($module['id_tipo_modulo'] == $id_type_web_content_string) {
$module['datos'] = io_safe_input($module['datos']);
}
$data = array ();
if (($module["id_modulo"] != 1) && ($module["id_tipo_modulo"] != 100)) {
if ($module["flag"] == 0) {
$data[0] = '<a href="index.php?' .
'sec=estado&amp;' .
'sec2=operation/agentes/ver_agente&amp;' .
'id_agente=' . $id_agente . '&amp;' .
'id_agente_modulo=' . $module["id_agente_modulo"] . '&amp;' .
'flag=1&amp;' .
'refr=60">' . html_print_image("images/target.png", true, array("border" => '0', "title" => __('Force'))) . '</a>';
}
else {
$data[0] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'&amp;id_agente_modulo='.$module["id_agente_modulo"].'&amp;refr=60">' . html_print_image("images/refresh.png", true, array("border" => "0", "title" => __("Refresh"))) . '</a>';
}
}
else {
$data[0] = '';
}
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
if ($module["id_policy_module"] != 0) {
$linked = policies_is_module_linked($module['id_agente_modulo']);
$id_policy = db_get_value_sql('SELECT id_policy FROM tpolicy_modules WHERE id = '.$module["id_policy_module"]);
if ($id_policy != "")
$name_policy = db_get_value_sql('SELECT name FROM tpolicies WHERE id = '.$id_policy);
else
$name_policy = __("Unknown");
$policyInfo = policies_info_module_policy($module["id_policy_module"]);
$adopt = false;
if (policies_is_module_adopt($module['id_agente_modulo'])) {
$adopt = true;
}
if ($linked) {
if ($adopt) {
$img = 'images/policies_brick.png';
$title = '(' . __('Adopted') . ') ' . $name_policy;
}
else {
$img = 'images/policies.png';
$title = $name_policy;
}
}
else {
if ($adopt) {
$img = 'images/policies_not_brick.png';
$title = '(' . __('Unlinked') . ') (' . __('Adopted') . ') ' . $name_policy;
}
else {
$img = 'images/unlinkpolicy.png';
$title = '(' . __('Unlinked') . ') ' . $name_policy;
}
}
$data[1] = '<a href="?sec=gpolicies&amp;sec2=enterprise/godmode/policies/policies&amp;id=' . $id_policy . '">' .
html_print_image($img,true, array('title' => $title)) .
'</a>';
}
else {
$data[1] = "";
}
}
$data[2] = servers_show_type ($module['id_modulo']) . '&nbsp;';
if (check_acl ($config['id_user'], $id_grupo, "AW"))
$data[2] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$id_agente.'&amp;tab=module&amp;id_agent_module='.$module["id_agente_modulo"].'&amp;edit_module='.$module["id_modulo"].'">' . html_print_image("images/config.png", true, array("alt" => '0', "border" => "", "title" => __('Edit'))) . '</a>';
$data[3] = "";
if ($module['quiet']) {
$data[3] .= html_print_image("images/dot_green.disabled.png", true,
array("border" => '0', "title" => __('Quiet'), "alt" => ""))
. "&nbsp;";
}
$data[3] .= ui_print_truncate_text($module["nombre"], 'module_medium');
if (!empty($module["extended_info"])) {
if ($module["extended_info"] != "") {
$data[3] .= ui_print_help_tip ($module["extended_info"], true, '/images/default_list.png');
}
}
//Adds tag context information
if (tags_get_modules_tag_count($module['id_agente_modulo']) > 0) {
$data[3] .= ' <a class="tag_details" href="ajax.php?page=operation/agentes/estado_monitores&get_tag_tooltip=1&id_agente_modulo='.$module['id_agente_modulo'].'">' .
html_print_image("images/tag_red.png", true, array("id" => 'tag-details-'.$module['id_agente_modulo'], "class" => "img_help")) . '</a> ';
}
//Adds relations context information
if (modules_relation_exists($module['id_agente_modulo'])) {
$data[3] .= ' <a class="relations_details" href="ajax.php?page=operation/agentes/estado_monitores&get_relations_tooltip=1&id_agente_modulo='.$module['id_agente_modulo'].'">' .
html_print_image("images/link2.png", true, array("id" => 'relations-details-'.$module['id_agente_modulo'], "class" => "img_help")) . '</a> ';
}
$data[4] = ui_print_string_substr ($module["descripcion"], 60, true, 8);
if ($module["datos"] != strip_tags($module["datos"])) {
$module_value = io_safe_input($module["datos"]);
}
else {
$module_value = io_safe_output($module["datos"]);
}
modules_get_status($module['id_agente_modulo'], $module['estado'],
$module_value, $status, $title);
$data[5] = ui_print_status_image($status, $title, true);
if (!$show_context_help_first_time) {
$show_context_help_first_time = true;
if ($module['estado'] == AGENT_MODULE_STATUS_UNKNOWN) {
$data[5] .= clippy_context_help("module_unknow");
}
}
if ($module["id_tipo_modulo"] == 24) {
// log4x
switch($module["datos"]) {
case 10:
$salida = "TRACE";
$style="font-weight:bold; color:darkgreen;";
break;
case 20:
$salida = "DEBUG";
$style="font-weight:bold; color:darkgreen;";
break;
case 30:
$salida = "INFO";
$style="font-weight:bold; color:darkgreen;";
break;
case 40:
$salida = "WARN";
$style="font-weight:bold; color:darkorange;";
break;
case 50:
$salida = "ERROR";
$style="font-weight:bold; color:red;";
break;
case 60:
$salida = "FATAL";
$style="font-weight:bold; color:red;";
break;
}
$salida = "<span style='$style'>$salida</span>";
}
else {
if (is_numeric($module["datos"]) && !modules_is_string_type($module['id_tipo_modulo'])){
$salida = format_numeric($module["datos"]);
// Show units ONLY in numeric data types
if (isset($module["unit"])){
$salida .= "&nbsp;" . '<i>'. io_safe_output($module["unit"]) . '</i>';
}
}
else {
//Fixed the goliat sends the strings from web
//without HTML entities
if ($module['id_tipo_modulo'] == $id_type_web_content_string) {
$module_value = $module["datos"];
}
else {
$module_value = io_safe_output($module["datos"]);
}
// If carriage returns present... then is a "Snapshot" data (full command output)
$is_snapshot = is_snapshot_data ( $module_value );
if (($config['command_snapshot']) && ($is_snapshot)) {
$handle = "snapshot" . "_" . $module["id_agente_modulo"];
$url = 'include/procesos.php?agente=' . $module["id_agente_modulo"];
$win_handle = dechex(crc32($handle));
$link ="winopeng_var('operation/agentes/snapshot_view.php?" .
"id=" . $module["id_agente_modulo"] .
"&refr=" . $module["current_interval"] .
"&label=" . rawurlencode(urlencode(io_safe_output($module["nombre"]))) . "','".$win_handle."', 700,480)";
$salida = '<a href="javascript:'.$link.'">' .
html_print_image("images/default_list.png", true,
array(
"border" => '0',
"alt" => "",
"title" => __("Snapshot view"))) . '</a> &nbsp;&nbsp;';
}
else {
//Fixed the goliat sends the strings from web
//without HTML entities
if ($module['id_tipo_modulo'] == $id_type_web_content_string) {
$sub_string = substr($module_value, 0, 12);
}
else {
//Fixed the data from Selenium Plugin
if ($module_value != strip_tags($module_value)) {
$module_value = io_safe_input($module_value);
$sub_string = substr($module_value, 0, 12);
}
else {
$sub_string = substr(io_safe_output($module_value),0, 12);
}
}
if ($module_value == $sub_string) {
$salida = $module_value;
}
else {
$salida = "<span " .
"id='hidden_value_module_" . $module["id_agente_modulo"] . "'
style='display: none;'>" .
$module_value .
"</span>" .
"<span " .
"id='value_module_" . $module["id_agente_modulo"] . "'
title='" . $module_value . "' " .
"style='white-space: nowrap;'>" .
'<span id="value_module_text_' . $module["id_agente_modulo"] . '">' .
$sub_string . '</span> ' .
"<a href='javascript: toggle_full_value(" . $module["id_agente_modulo"] . ")'>" .
html_print_image("images/rosette.png", true) . "</a>" . "</span>";
}
}
}
}
$data[6] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]);
$data[7] = $salida;
$graph_type = return_graphtype ($module["id_tipo_modulo"]);
$data[8] = " ";
if ($module['history_data'] == 1) {
$nombre_tipo_modulo = modules_get_moduletype_name ($module["id_tipo_modulo"]);
$handle = "stat".$nombre_tipo_modulo."_".$module["id_agente_modulo"];
$url = 'include/procesos.php?agente='.$module["id_agente_modulo"];
$win_handle=dechex(crc32($module["id_agente_modulo"].$module["nombre"]));
# Show events for boolean modules by default.
if ($graph_type == 'boolean') {
$draw_events = 1;
} else {
$draw_events = 0;
}
$link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&amp;period=86400&amp;id=".$module["id_agente_modulo"]."&amp;label=".rawurlencode(urlencode(base64_encode($module["nombre"])))."&amp;refresh=600&amp;draw_events=$draw_events','day_".$win_handle."')";
$data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;';
$server_name = '';
$data[8] .= "<a href='javascript: show_module_detail_dialog(" . $module["id_agente_modulo"] . ", ". $id_agente.", \"" . $server_name . "\", 0, 86400)'>". html_print_image ("images/binary.png", true, array ("border" => "0", "alt" => "")) . "</a>";
}
if ($module['estado'] == 3) {
$data[9] = '<span class="redb">';
}
else {
$data[9] = '<span>';
}
$data[9] .= ui_print_timestamp ($module["utimestamp"], true, array('style' => 'font-size: 7pt'));
$data[9] .= '</span>';
array_push ($table->data, $data);
$rowIndex++;
}
?>
<script type="text/javascript">
function toggle_full_value(id) {
text = $("#hidden_value_module_" + id).html();
old_text = $("#value_module_text_" + id).html();
$("#hidden_value_module_" + id).html(old_text);
$("#value_module_text_" + id).html(text);
}
</script>
<?php
echo "<h4 style='padding-top:0px !important;'>";
ui_print_help_tip(__('For to view the list modules paginated, set in setup visuals.'));
echo __('Full list of monitors') . '&nbsp;' . reporting_tiny_stats ($agent, true, 'modules');
echo ui_print_help_tip(__('For to view the list modules paginated, set in setup visuals.'), true) .
__('Full list of monitors') . '&nbsp;' .
reporting_tiny_stats ($agent, true, 'modules');
$modules_not_init = agents_monitor_notinit($id_agente);
if (!empty($modules_not_init)) {
echo clippy_context_help("modules_not_init");
@ -732,45 +116,175 @@ if (!empty($modules_not_init)) {
echo "</h4>";
ob_start();
print_form_filter_monitors($id_agente, $status_filter_monitor, $status_text_monitor);
if (empty ($table->data)) {
if ($filter_monitors) {
echo '<div class="nf">' .
__('Any monitors aren\'t with this filter.') . '</div>';
}
else {
echo '<div class="nf">' .
__('This agent doesn\'t have any active monitors.') . '</div>';
}
}
else {
$url = "index.php?" .
"sec=estado&" .
"sec2=operation/agentes/ver_agente&" .
"id_agente=" . $id_agente . "&" .
"refr=&filter_monitors=1&" .
"status_filter_monitor=" . $status_filter_monitor . "&" .
"status_text_monitor=" . $status_text_monitor;
if ($paginate_module) {
ui_pagination ($count_modules, $url);
echo "<div id='module_list_loading'>" .
html_print_image('images/spinner.gif', true) .
'</div>';
echo "<div id='module_list'>" .
"</div>";
$html_toggle = ob_get_clean();
ui_toggle($html_toggle,
__('List of modules'),
'status_monitor_agent',
false);
?>
<script type="text/javascript">
var sort_field = 'name';
var sort_rows = 'up';
var filter_status = -1;
var filter_text = "";
$(document).ready(function() {
var parameters = {};
parameters["list_modules"] = 1;
parameters["id_agente"] = <?php echo $id_agente; ?>;
parameters["page"] = "include/ajax/module";
jQuery.ajax ({
data: parameters,
type: 'POST',
url: "ajax.php",
timeout: 10000,
dataType: 'html',
async: false,
success: function (data) {
$("#module_list_loading").hide();
$("#module_list").empty();
$("#module_list").html(data);
}
});
});
function order_module_list(sort_field_param, sort_rows_param) {
sort_field = sort_field_param;
sort_rows = sort_rows_param;
var parameters = {};
parameters["list_modules"] = 1;
parameters["id_agente"] = <?php echo $id_agente; ?>;
parameters["sort_field"] = sort_field;
parameters["sort"] = sort_rows;
parameters["status_filter_monitor"] = filter_status;
parameters["status_text_monitor"] = filter_text;
parameters["page"] = "include/ajax/module";
$("#module_list").empty();
$("#module_list_loading").show();
jQuery.ajax ({
data: parameters,
type: 'POST',
url: "ajax.php",
timeout: 10000,
dataType: 'html',
async: false,
success: function (data) {
$("#module_list_loading").hide();
$("#module_list").empty();
$("#module_list").html(data);
}
});
}
html_print_table ($table);
function filter_modules() {
filter_status = $("#status_filter_monitor").val();
filter_text = $("input[name='status_text_monitor']").val();
if ($paginate_module) {
ui_pagination ($count_modules, $url);
var parameters = {};
parameters["list_modules"] = 1;
parameters["id_agente"] = <?php echo $id_agente; ?>;
parameters["sort_field"] = sort_field;
parameters["sort"] = sort_rows;
parameters["status_filter_monitor"] = filter_status;
parameters["status_text_monitor"] = filter_text;
parameters["filter_monitors"] = 1;
parameters["monitors_change_filter"] = 1;
parameters["page"] = "include/ajax/module";
$("#module_list").empty();
$("#module_list_loading").show();
jQuery.ajax ({
data: parameters,
type: 'POST',
url: "ajax.php",
timeout: 10000,
dataType: 'html',
async: false,
success: function (data) {
$("#module_list_loading").hide();
$("#module_list").empty();
$("#module_list").html(data);
}
});
}
}
unset ($table);
unset ($table_data);
function reset_filter_modules() {
$("#status_filter_monitor").val(-1);
$("input[name='status_text_monitor']").val("");
filter_modules();
}
function pagination_list_modules(offset) {
var parameters = {};
parameters["list_modules"] = 1;
parameters["id_agente"] = <?php echo $id_agente; ?>;
parameters["offset"] = offset;
parameters["sort_field"] = sort_field;
parameters["sort"] = sort_rows;
parameters["status_filter_monitor"] = filter_status;
parameters["status_text_monitor"] = filter_text;
parameters["filter_monitors"] = 0;
parameters["monitors_change_filter"] = 0;
parameters["page"] = "include/ajax/module";
$("#module_list").empty();
$("#module_list_loading").show();
jQuery.ajax ({
data: parameters,
type: 'POST',
url: "ajax.php",
timeout: 10000,
dataType: 'html',
async: false,
success: function (data) {
$("#module_list_loading").hide();
$("#module_list").empty();
$("#module_list").html(data);
}
});
}
</script>
<?php
ui_require_css_file ('cluetip');
ui_require_jquery_file ('cluetip');
echo "<div id='module_details_dialog'></div>";
echo "<div id='module_details_dialog' style='display: none;'></div>";
ui_include_time_picker();
ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/");
@ -880,7 +394,7 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
function print_form_filter_monitors($id_agent, $status_filter_monitor = -1,
$status_text_monitor = '') {
$form_text = '<form action="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agent . '" method="post">';
$form_text = '';
$table->data[0][0] = html_print_input_hidden('filter_monitors', 1, true);
$table->data[0][0] .= html_print_input_hidden('monitors_change_filter', 1, true);
@ -893,20 +407,18 @@ function print_form_filter_monitors($id_agent, $status_filter_monitor = -1,
AGENT_MODULE_STATUS_NOT_NORMAL => __('Not Normal'),
AGENT_MODULE_STATUS_WARNING => __('Warning'),
AGENT_MODULE_STATUS_UNKNOWN => __('Unknown'));
$table->data[0][1] = html_print_select ($status_list,
'status_filter_monitor', $status_filter_monitor, '', '', 0,
true);
$table->data[0][2] = __('Free text for search (*):');
$table->data[0][3] = html_print_input_text('status_text_monitor', $status_text_monitor, '', 30, 100, true);
$table->data[0][4] = html_print_submit_button(__('Filter'), 'filter', false, 'class="sub search"', true);
$table->data[0][4] .= '</form>';
$table->data[0][5] = '<form action="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agent . '" method="post">';
$table->data[0][5] .= html_print_submit_button(__('Reset'), 'reset', false, 'class="sub upd"', true);
$table->data[0][5] .= '</form>';
html_print_submit_button(__('Filter'), 'filter', false, 'class="sub search"', true);
$form_text .= html_print_table($table, true);
$form_text .= '';
$table->data[0][2] = __('Free text for search (*):');
$table->data[0][3] = html_print_input_text('status_text_monitor', $status_text_monitor, '', 30, 100, true);
$table->data[0][4] = html_print_button(__('Filter'), 'filter', false, 'filter_modules();', 'class="sub search"', true);
$table->data[0][4] .= '&nbsp;' . html_print_button(__('Reset'), 'filter', false, 'reset_filter_modules();', 'class="sub upd"', true);
$form_text .= html_print_table($table, true);
$filter_hidden = false;