pandorafms/pandora_console/include/functions_treeview.php

598 lines
19 KiB
PHP
Raw Normal View History

<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
function treeview_printModuleTable($id_module, $server_data = false) {
global $config;
if (empty($server_data)) {
$server_name = '';
$server_id = '';
$url_hash = '';
$console_url = '';
}
else {
$server_name = $server_data['server_name'];
$server_id = $server_data['id'];
$console_url = $server_data['server_url'] . '/';
$url_hash = metaconsole_get_servers_url_hash($server_data);
}
require_once ($config["homedir"] . "/include/functions_agents.php");
require_once ($config["homedir"] . "/include/functions_graph.php");
include_graphs_dependencies($config['homedir'].'/');
require_once ($config['homedir'] . "/include/functions_groups.php");
require_once ($config['homedir'] . "/include/functions_servers.php");
enterprise_include_once ('meta/include/functions_modules_meta.php');
enterprise_include_once ('meta/include/functions_ui_meta.php');
enterprise_include_once ('meta/include/functions_metaconsole.php');
$filter["id_agente_modulo"] = $id_module;
$module = db_get_row_filter ("tagente_modulo", $filter);
if ($module === false) {
2013-05-23 Sergio Martin <sergio.martin@artica.es> * include/functions_html.php include/styles/pandora_minimal.css include/styles/dialog.css include/styles/menu.css include/styles/jquery-ui-1.10.0.custom.css include/functions_events.php operation/events/events_list.php include/functions_snmp_browser.php include/styles/pandora.css: A lot of graphic changes including events form and snmp browser layout * include/ajax/module.php include/functions_ui.php include/functions.php include/functions_agents.php include/functions_graph.php include/graphs/functions_gd.php include/graphs/fgraph.php include/functions_reporting.php include/functions_filemanager.php include/javascript/pandora_snmp_browser.js include/functions_treeview.php include/constants.php index.php extensions/net_tools.php extensions/pandora_logs.php extensions/ssh_gateway.php extensions/update_manager/settings.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/visual_console/render_view.php operation/users/user_edit.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/estado_monitores.php operation/agentes/agent_fields.php operation/agentes/stat_win.php operation/servers/recon_view.php operation/integria_incidents/incident_detail.php operation/netflow/nf_live_view.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/db/db_refine.php godmode/db/db_event.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/modificar_agente.php godmode/agentes/module_manager_editor.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/setup/news.php godmode/setup/links.php godmode/setup/gis.php godmode/users/configure_profile.php godmode/massive/massive_add_alerts.php godmode/massive/massive_delete_profiles.php godmode/modules/module_list.php godmode/reporting/visual_console_builder.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/tag/tag.php godmode/tag/edit_tag.php: Changing the old way of print errors to encapsulated UI function to unify styles * images/status_sets/color_text/agent_no_monitors.png images/status_sets/color_text/agent_no_monitors_ball.pn images/status_sets/color_text/agent_down_ball.png images/status_sets/color_text/agent_down.png images/status_sets/default/agent_no_monitors.png images/status_sets/default/agent_no_monitors_ball.png images/status_sets/default/agent_down_ball.png images/status_sets/default/agent_down.png: Modify some status set images * images/gis_map/icons/star.default.png images/gis_map/icons/cross.warning.png images/gis_map/icons/star.bad.png images/gis_map/icons/cross.ok.png images/gis_map/icons/marker.default.png images/gis_map/icons/square_marker.warning.png images/gis_map/icons/circle.warning.png images/gis_map/icons/marker.bad.png images/gis_map/icons/square_marker.ok.png images/gis_map/icons/circle.ok.png images/gis_map/icons/triangle.warning.png images/gis_map/icons/cross.default.png images/gis_map/icons/star.warning.png images/gis_map/icons/triangle.ok.png images/gis_map/icons/cross.bad.png images/gis_map/icons/star.ok.png images/gis_map/icons/square_marker.default.png images/gis_map/icons/circle.default.png images/gis_map/icons/marker.warning.png images/gis_map/icons/square_marker.bad.png images/gis_map/icons/circle.bad.png images/gis_map/icons/triangle.default.png images/gis_map/icons/marker.ok.png images/gis_map/icons/triangle.bad.png: Change whole the gis icons by new ones * images/os_icons/so_win.png images/os_icons/so_linux.png images/os_icons/so_mac.png images/os_icons/so_cisco.png images/os_icons/so_vmware.png images/os_icons/so_bsd.png images/os_icons/android.png images/os_icons/so_aix.png images/os_icons/so_other.png images/os_icons/so_hpux.png images/os_icons/network.png images/os_icons/embedded.png: Reduce the operating system icons size * images/vnc.png images/op_inventory.png images/refresh_mc.png images/heart.png images/service.png images/go.png images/graphmenu_arrow_hide.png images/submenu_tree_first.png images/config_mc.png images/cross_double.png images/wand.png images/expand.png images/submenu_tree_middle.png images/visual_console.png images/down.png images/chart_curve_threshold.png images/people_1.png images/cancel.png images/graphmenu_arrow.png images/people_2.png images/collapse.png images/camera_mc.png: Improve a lot of icons git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8198 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-05-23 17:42:32 +02:00
ui_print_error_message(__('There was a problem loading module'));
return;
}
if (! check_acl ($config["id_user"], $module["id_grupo"], "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access Module Information");
require_once ("general/noaccess.php");
return;
}
$table = new StdClass();
$table->width = "100%";
$table->style = array();
$table->style['title'] = 'font-weight: bold;';
$table->head = array();
$table->head[] = __('Module');
$table->head_colspan[] = 2;
$table->data = array();
//Module name
if ($module["disabled"])
$cellName = "<em>" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[&hellip;]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . "<em>";
else
$cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[&hellip;]',"text-transform: uppercase;");
$row = array();
$row['title'] = __('Name');
$row['data'] = "<b>".$cellName."</b>";
$table->data['name'] = $row;
// Interval
$row = array();
$row['title'] = __('Interval');
$row['data'] = human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true);
$table->data['interval'] = $row;
// Warning Min/Max
if (modules_is_string_type($module['id_tipo_modulo'])) {
$warning_status_str = __('Str.') . ': ' . $module['str_warning'];
}
else {
$warning_status_str = __('Min.') . ': ' . $module['min_warning'] . '<br>' . __('Max.') . ': ' . $module['max_warning'];
}
$row = array();
$row['title'] = __('Warning status');
$row['data'] = $warning_status_str;
$table->data['watning_status'] = $row;
// Critical Min/Max
if (modules_is_string_type($module['id_tipo_modulo'])) {
$critical_status_str = __('Str.') . ': ' . $module['str_warning'];
}
else {
$critical_status_str = __('Min.') . ': ' . $module['min_critical'] . '<br>' . __('Max.') . ': ' . $module['max_critical'];
}
$row = array();
$row['title'] = __('Critical status');
$row['data'] = $critical_status_str;
$table->data['critical_status'] = $row;
// Module group
$module_group = modules_get_modulegroup_name($module['id_module_group']);
if ($module_group === false)
$module_group = __('Not assigned');
else
$module_group = __("$module_group");
$row = array();
$row['title'] = __('Module group');
$row['data'] = $module_group;
$table->data['module_group'] = $row;
// Description
$row = array();
$row['title'] = __('Description');
$row['data'] = ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[&hellip;]');
$table->data['description'] = $row;
// Tags
$tags = tags_get_module_tags($module['id_agente_modulo']);
if (empty($tags)) {
$tags = array();
}
$user_tags = tags_get_user_tags($config["id_user"]);
foreach ($tags as $k => $v) {
if (!array_key_exists($v, $user_tags)) { //only show user's tags.
unset($tags[$k]);
} else {
$tag_name = tags_get_name($v);
if (empty($tag_name)) {
unset($tags[$k]);
}
else {
$tags[$k] = $tag_name;
}
}
}
if (empty($tags)) {
$tags = '<i>' . __('N/A') . '</i>';
}
else {
$tags = implode(', ' , $tags);
}
$row = array();
$row['title'] = __('Tags');
$row['data'] = $tags;
$table->data['tags'] = $row;
// Data
$last_data = db_get_row_filter ('tagente_estado', array('id_agente_modulo' => $module['id_agente_modulo'], 'order' => array('field' => 'id_agente_estado', 'order' => 'DESC')));
if (is_numeric($last_data["datos"]))
$data = "<span style='height: 20px; display: inline-table; vertical-align: top;'>" . format_numeric($last_data["datos"]) . "</span>";
else
$data = "<span title='" . $last_data["datos"] . "' style='white-space: nowrap;'>" . substr(io_safe_output($last_data['datos']),0,12) . "</span>";
if (!empty($last_data['utimestamp'])) {
$last_data_str = $data;
if ($module['unit'] != '') {
$last_data_str .= "&nbsp;";
$last_data_str .= '('.$module['unit'].')';
}
$last_data_str .= "&nbsp;";
$last_data_str .= html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px'));
}
else {
$last_data_str = '<i>' . __('No data') . '</i>';
}
$row = array();
$row['title'] = __('Last data');
$row['data'] = $last_data_str;
$table->data['last_data'] = $row;
//End of table
html_print_table($table);
$id_group = agents_get_agent_group($module['id_agente']);
$group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group);
$agent_name = db_get_value('nombre', 'tagente', 'id_agente', $module['id_agente']);
if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'AW')) {
// Actions table
echo '<div style="width:100%; text-align: right; min-width: 300px;">';
echo '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $module['id_agente'] . '&tab=module&edit_module=1&id_agent_module=' . $module['id_agente_modulo'] . $url_hash . '">';
html_print_submit_button (__('Go to module edition'), 'upd_button', false, 'class="sub config"');
echo '</a>';
echo '</div>';
}
//id_module and id_agent hidden
echo '<div id="ids" style="display:none;">';
html_print_input_text('id_module', $id_module);
html_print_input_text('id_agent', $module['id_agente']);
html_print_input_text('server_name', $server_name);
echo '</div>';
return;
}
function treeview_printAlertsTable($id_module, $server_data = array()) {
global $config;
if (empty($server_data)) {
$server_name = '';
$server_id = '';
$url_hash = '';
$console_url = '';
}
else {
$server_name = $server_data['server_name'];
$server_id = $server_data['id'];
$console_url = $server_data['server_url'] . '/';
$url_hash = metaconsole_get_servers_url_hash($server_data);
}
$module_alerts = alerts_get_alerts_agent_module($id_module);
$module_name = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_module);
$agent_id = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_module);
$id_group = agents_get_agent_group($agent_id);
if ($module_alerts === false) {
2013-05-23 Sergio Martin <sergio.martin@artica.es> * include/functions_html.php include/styles/pandora_minimal.css include/styles/dialog.css include/styles/menu.css include/styles/jquery-ui-1.10.0.custom.css include/functions_events.php operation/events/events_list.php include/functions_snmp_browser.php include/styles/pandora.css: A lot of graphic changes including events form and snmp browser layout * include/ajax/module.php include/functions_ui.php include/functions.php include/functions_agents.php include/functions_graph.php include/graphs/functions_gd.php include/graphs/fgraph.php include/functions_reporting.php include/functions_filemanager.php include/javascript/pandora_snmp_browser.js include/functions_treeview.php include/constants.php index.php extensions/net_tools.php extensions/pandora_logs.php extensions/ssh_gateway.php extensions/update_manager/settings.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/visual_console/render_view.php operation/users/user_edit.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/estado_monitores.php operation/agentes/agent_fields.php operation/agentes/stat_win.php operation/servers/recon_view.php operation/integria_incidents/incident_detail.php operation/netflow/nf_live_view.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/db/db_refine.php godmode/db/db_event.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/modificar_agente.php godmode/agentes/module_manager_editor.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/setup/news.php godmode/setup/links.php godmode/setup/gis.php godmode/users/configure_profile.php godmode/massive/massive_add_alerts.php godmode/massive/massive_delete_profiles.php godmode/modules/module_list.php godmode/reporting/visual_console_builder.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/tag/tag.php godmode/tag/edit_tag.php: Changing the old way of print errors to encapsulated UI function to unify styles * images/status_sets/color_text/agent_no_monitors.png images/status_sets/color_text/agent_no_monitors_ball.pn images/status_sets/color_text/agent_down_ball.png images/status_sets/color_text/agent_down.png images/status_sets/default/agent_no_monitors.png images/status_sets/default/agent_no_monitors_ball.png images/status_sets/default/agent_down_ball.png images/status_sets/default/agent_down.png: Modify some status set images * images/gis_map/icons/star.default.png images/gis_map/icons/cross.warning.png images/gis_map/icons/star.bad.png images/gis_map/icons/cross.ok.png images/gis_map/icons/marker.default.png images/gis_map/icons/square_marker.warning.png images/gis_map/icons/circle.warning.png images/gis_map/icons/marker.bad.png images/gis_map/icons/square_marker.ok.png images/gis_map/icons/circle.ok.png images/gis_map/icons/triangle.warning.png images/gis_map/icons/cross.default.png images/gis_map/icons/star.warning.png images/gis_map/icons/triangle.ok.png images/gis_map/icons/cross.bad.png images/gis_map/icons/star.ok.png images/gis_map/icons/square_marker.default.png images/gis_map/icons/circle.default.png images/gis_map/icons/marker.warning.png images/gis_map/icons/square_marker.bad.png images/gis_map/icons/circle.bad.png images/gis_map/icons/triangle.default.png images/gis_map/icons/marker.ok.png images/gis_map/icons/triangle.bad.png: Change whole the gis icons by new ones * images/os_icons/so_win.png images/os_icons/so_linux.png images/os_icons/so_mac.png images/os_icons/so_cisco.png images/os_icons/so_vmware.png images/os_icons/so_bsd.png images/os_icons/android.png images/os_icons/so_aix.png images/os_icons/so_other.png images/os_icons/so_hpux.png images/os_icons/network.png images/os_icons/embedded.png: Reduce the operating system icons size * images/vnc.png images/op_inventory.png images/refresh_mc.png images/heart.png images/service.png images/go.png images/graphmenu_arrow_hide.png images/submenu_tree_first.png images/config_mc.png images/cross_double.png images/wand.png images/expand.png images/submenu_tree_middle.png images/visual_console.png images/down.png images/chart_curve_threshold.png images/people_1.png images/cancel.png images/graphmenu_arrow.png images/people_2.png images/collapse.png images/camera_mc.png: Improve a lot of icons git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8198 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-05-23 17:42:32 +02:00
ui_print_error_message(__('There was a problem loading alerts'));
return;
}
$table = new StdClass();
$table->width = "100%";
$table->style = array();
$table->style['titles'] = 'font-weight: bold; background: #B3B3B3;';
$table->head = array();
$table->head[] = __('Alerts') . ": " . $module_name;
$table->head_colspan[] = 2;
$table->data = array();
$row = array();
$row['template'] = __('Template');
$row['actions'] = __('Actions');
$table->data['titles'] = $row;
foreach($module_alerts as $module_alert) {
//Template name
$template_name = db_get_value('name','talert_templates','id',$module_alert['id_alert_template']);
$actions = alerts_get_alert_agent_module_actions($module_alert['id']);
if (empty($actions)) {
$actions_list = '<i>'.__('N/A').'</i>';
}
else {
$actions_list = '<ul>';
foreach($actions_list as $act) {
$actions_list .= '<li>';
$actions_list .= $act['name'];
$actions_list .= '</li>';
}
$actions_list .= '</ul>';
}
$row = array();
$row['template'] = $template_name;
$row['actions'] = $actions_list;
$table->data['last_data'] = $row;
}
html_print_table($table);
if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) {
// Actions table
echo '<div style="width:100%; text-align: right; min-width: 300px;">';
echo '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name=' . $module_name . '&id_agente=' . $agent_id . $url_hash . '" target="_blank">';
html_print_submit_button (__('Go to alerts edition'), 'upd_button', false, 'class="sub search"');
echo '</a>';
echo '</div>';
}
}
function treeview_printTable($id_agente, $server_data = array()) {
global $config;
if (empty($server_data)) {
$server_name = '';
$server_id = '';
$url_hash = '';
$console_url = '';
}
else {
$server_name = $server_data['server_name'];
$server_id = $server_data['id'];
$console_url = $server_data['server_url'] . '/';
$url_hash = metaconsole_get_servers_url_hash($server_data);
}
require_once ($config["homedir"] . "/include/functions_agents.php");
require_once ($config["homedir"] . '/include/functions_graph.php');
require_once ($config['homedir'] . '/include/functions_groups.php');
require_once ($config['homedir'] . '/include/functions_gis.php');
2015-02-26 19:16:29 +01:00
enterprise_include_once ('meta/include/functions_ui_meta.php');
include_graphs_dependencies();
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente));
if ($is_extra === ENTERPRISE_NOT_HOOK) {
$is_extra = false;
}
if (! check_acl ($config["id_user"], $agent["id_grupo"], "AR") && !$is_extra) {
db_pandora_audit("ACL Violation",
"Trying to access Agent General Information");
require_once ("general/noaccess.php");
return;
}
$agent = db_get_row ("tagente", "id_agente", $id_agente);
if ($agent === false) {
ui_print_error_message(__('There was a problem loading agent'));
return;
}
$table = new StdClass();
$table->width = "100%";
$table->style = array();
$table->style['title'] = 'font-weight: bold;';
$table->head = array();
$table->data = array();
// Agent name
if ($agent['disabled']) {
$cellName = "<em>";
}
else {
$cellName = '';
}
$cellName .= ui_print_agent_name ($agent["id_agente"], true, 500, "text-transform: uppercase;", true, $console_url, $url_hash, false, can_user_access_node ());
if ($agent['disabled']) {
$cellName .= ui_print_help_tip(__('Disabled'), true) . "</em>";
}
$row = array();
$row['title'] = __('Agent name');
$row['data'] = $cellName;
$table->data['name'] = $row;
//Addresses
$ips = array();
$addresses = agents_get_addresses ($id_agente);
$address = agents_get_address($id_agente);
foreach ($addresses as $k => $add) {
if ($add == $address) {
unset($addresses[$k]);
}
}
if (!empty($addresses)) {
$address .= ui_print_help_tip(__('Other IP addresses').': <br>'.implode('<br>',$addresses), true);
}
$row = array();
$row['title'] = __('IP Address');
$row['data'] = $address;
$table->data['address'] = $row;
// Agent Interval
$row = array();
$row['title'] = __('Interval');
$row['data'] = human_time_description_raw ($agent["intervalo"]);
$table->data['interval'] = $row;
// Comments
$row = array();
$row['title'] = __('Description');
$row['data'] = $agent["comentarios"];
$table->data['description'] = $row;
// Last contact
$last_contact = ui_print_timestamp($agent["ultimo_contacto"], true);
if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") {
$last_remote_contact = __('Never');
}
else {
$last_remote_contact = ui_print_timestamp ($agent["ultimo_contacto_remoto"], true);
}
$row = array();
$row['title'] = __('Last contact') . " / " . __('Remote');
$row['data'] = "$last_contact / $last_remote_contact";
$table->data['contact'] = $row;
// Next contact (agent)
$progress = agents_get_next_contact($id_agente);
$row = array();
$row['title'] = __('Next agent contact');
$row['data'] = progress_bar($progress, 150, 20);
$table->data['next_contact'] = $row;
//End of table
$agent_table = html_print_table($table, true);
if (can_user_access_node () && check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
$go_to_agent = '<div style="text-align: right;">';
$go_to_agent .= '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">';
$go_to_agent .= html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
$go_to_agent .= '</a>';
$go_to_agent .= '</div>';
$agent_table .= $go_to_agent;
}
$agent_table .= "<br>";
// print agent data toggle
ui_toggle($agent_table, __('Agent data'), '', false);
// Advanced data
$table = new StdClass();
$table->width = "100%";
$table->style = array();
$table->style['title'] = 'font-weight: bold;';
$table->head = array();
$table->data = array();
// Agent version
$row = array();
$row['title'] = __('Agent Version');
$row['data'] = $agent["agent_version"];
$table->data['agent_version'] = $row;
// Position Information
if ($config['activate_gis']) {
$dataPositionAgent = gis_get_data_last_position_agent($agent['id_agente']);
if ($dataPositionAgent !== false) {
$position = '<a href="' . $console_url . 'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;tab=gis&amp;id_agente='.$id_agente.'">';
if ($dataPositionAgent['description'] != "")
$position .= $dataPositionAgent['description'];
else
$position .= $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude'];
$position .= "</a>";
$row = array();
$row['title'] = __('Position (Long, Lat)');
$row['data'] = $position;
$table->data['agent_position'] = $row;
}
}
// If the url description is setted
if ($agent['url_address'] != '') {
$row = array();
$row['title'] = __('Url address');
$row['data'] = '<a href='.$agent["url_address"].'>'.$agent["url_address"].'</a>';
$table->data['agent_address'] = $row;
}
// Timezone Offset
if ($agent['timezone_offset'] != 0) {
$row = array();
$row['title'] = __('Timezone Offset');
$row['data'] = $agent["timezone_offset"];
$table->data['agent_timezone_offset'] = $row;
}
// Custom fields
$fields = db_get_all_rows_filter('tagent_custom_fields', array('display_on_front' => 1));
if ($fields === false) {
$fields = array ();
}
if ($fields) {
foreach ($fields as $field) {
$custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
if (!empty($custom_value)) {
$row = array();
$row['title'] = $field['name'] . ui_print_help_tip (__('Custom field'), true);
$row['data'] = $custom_value;
$table->data['custom_field_'.$field['id_field']] = $row;
}
}
}
//End of table advanced
$table_advanced = html_print_table($table, true);
$table_advanced .= "<br>";
ui_toggle($table_advanced, __('Advanced information'));
// Blank space below title, DONT remove this, this
// Breaks the layout when Flash charts are enabled :-o
//echo '<div id="id_div" style="height: 10px">&nbsp;</div>';
if ($config["agentaccess"]) {
$access_graph = '<div style="margin-left: 10px;">';
$access_graph .= graphic_agentaccess($id_agente, 290, 110,
SECONDS_1DAY, true);
$access_graph .= '</div><br>';
ui_toggle($access_graph, __('Agent access rate (24h)'));
}
$events_graph = '<div style="margin-left: 10px;">';
$events_graph .= graph_graphic_agentevents ($id_agente, 290, 15,
SECONDS_1DAY, '', true);
$events_graph .= '</div><br>';
ui_toggle($events_graph, __('Events (24h)'));
// Table network interfaces
$network_interfaces_by_agents = agents_get_network_interfaces(array($agent));
$network_interfaces = array();
if (!empty($network_interfaces_by_agents) && !empty($network_interfaces_by_agents[$id_agente])) {
$network_interfaces = $network_interfaces_by_agents[$id_agente]['interfaces'];
}
if (!empty($network_interfaces)) {
$table = new stdClass();
$table->id = 'agent_interface_info';
$table->class = 'databox';
$table->width = '100%';
$table->style = array();
$table->style['interface_status'] = 'width: 30px;';
$table->style['interface_graph'] = 'width: 20px;';
$table->head = array();
$table->data = array();
foreach ($network_interfaces as $interface_name => $interface) {
if (!empty($interface['traffic'])) {
$params = array(
'interface_name' => $interface_name,
'agent_id' => $id_agente,
'traffic_module_in' => $interface['traffic']['in'],
'traffic_module_out' => $interface['traffic']['out']
);
$params_json = json_encode($params);
$params_encoded = base64_encode($params_json);
$win_handle = dechex(crc32($interface['status_module_id'].$interface_name));
$graph_url = '';
if (!defined('METACONSOLE')) {
$graph_url = $config['homeurl'] .
"operation/agentes/interface_traffic_graph_win.php?" .
"params=$params_encoded";
}
2015-02-26 19:49:08 +01:00
else if (!empty($server_data)) {
$graph_url = ui_meta_get_url_console_child(
2015-02-26 19:16:29 +01:00
$server_data, null, null, null, null,
"operation/agentes/interface_traffic_graph_win.php?" .
"params=$params_encoded");
}
$graph_link = "<a href=\"javascript:winopeng('$graph_url','$win_handle')\">" .
html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . "</a>";
}
else {
$graph_link = "";
}
$data = array();
$data['interface_name'] = "<strong>" . $interface_name . "</strong>";
$data['interface_status'] = $interface['status_image'];
$data['interface_graph'] = $graph_link;
$data['interface_ip'] = $interface['ip'];
$data['interface_mac'] = $interface['mac'];
$table->data[] = $data;
}
//End of table network interfaces
$table_interfaces = html_print_table($table, true);
$table_interfaces .= "<br>";
ui_toggle($table_interfaces, __('Interface information') . ' (SNMP)');
}
return;
}
?>