agent view rebuilt

This commit is contained in:
fbsanchez 2019-05-27 21:30:46 +02:00
parent 954dd0b43a
commit f1499082fa
6 changed files with 414 additions and 136 deletions

View File

@ -89,7 +89,7 @@ if (is_ajax()) {
$out = false; $out = false;
foreach ($idSNMP as $id) { foreach ($idSNMP as $id) {
foreach ($snmp[$id] as $key => $value) { foreach ($snmp[$id] as $key => $value) {
// Check if it has "ifXXXX" syntax and skip it // Check if it has "ifXXXX" syntax and skip it.
if (! preg_match('/if/', $key)) { if (! preg_match('/if/', $key)) {
continue; continue;
} }
@ -109,7 +109,7 @@ if (is_ajax()) {
echo io_json_mb_encode($out); echo io_json_mb_encode($out);
} }
// And and remove groups use the same function // And and remove groups use the same function.
$add_secondary_groups = get_parameter('add_secondary_groups'); $add_secondary_groups = get_parameter('add_secondary_groups');
$remove_secondary_groups = get_parameter('remove_secondary_groups'); $remove_secondary_groups = get_parameter('remove_secondary_groups');
if ($add_secondary_groups || $remove_secondary_groups) { if ($add_secondary_groups || $remove_secondary_groups) {
@ -125,12 +125,12 @@ if (is_ajax()) {
'agents_update_secondary_groups', 'agents_update_secondary_groups',
[ [
$id_agent, $id_agent,
$add_secondary_groups ? $groups_to_add : [], ($add_secondary_groups) ? $groups_to_add : [],
$remove_secondary_groups ? $groups_to_add : [], ($remove_secondary_groups) ? $groups_to_add : [],
] ]
); );
// Echo 0 in case of error. 0 Otherwise. // Echo 0 in case of error. 0 Otherwise.
echo $ret ? 1 : 0; echo ($ret) ? 1 : 0;
} }
} }
@ -160,7 +160,7 @@ if ($new_agent) {
} }
if (!$new_agent) { if (!$new_agent) {
// Agent remote configuration editor // Agent remote configuration editor.
enterprise_include_once('include/functions_config_agents.php'); enterprise_include_once('include/functions_config_agents.php');
if (enterprise_installed()) { if (enterprise_installed()) {
$filename = config_agents_get_agent_config_filenames($id_agente); $filename = config_agents_get_agent_config_filenames($id_agente);
@ -168,10 +168,10 @@ if (!$new_agent) {
} }
$disk_conf_delete = (bool) get_parameter('disk_conf_delete'); $disk_conf_delete = (bool) get_parameter('disk_conf_delete');
// Agent remote configuration DELETE // Agent remote configuration DELETE.
if ($disk_conf_delete) { if ($disk_conf_delete) {
// TODO: Get this working on computers where the Pandora server(s) are not on the webserver // TODO: Get this working on computers where the Pandora server(s) are not on the webserver
// TODO: Get a remote_config editor working in the open version // TODO: Get a remote_config editor working in the open version.
@unlink($filename['md5']); @unlink($filename['md5']);
@unlink($filename['conf']); @unlink($filename['conf']);
} }
@ -217,7 +217,7 @@ if (!$new_agent && $alias != '') {
$agent_options_update = 'agent_options_update'; $agent_options_update = 'agent_options_update';
// Delete link from here. // Delete link from here.
$table_agent_name .= "<a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'>".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).'</a>'; $table_agent_name .= "<a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=".$id_agente."&search=&offset=0&sort_field=&sort=none'>".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).'</a>';
// Help link. // Help link.
$table_agent_name .= ui_print_help_icon( $table_agent_name .= ui_print_help_icon(
@ -424,43 +424,43 @@ if (enterprise_installed()) {
$table_adv_secondary_groups = '<div class="label_select"><p class="input_label">'.__('Secondary groups').': '.ui_print_help_icon('secondary_groups', true).'</p></div>'; $table_adv_secondary_groups = '<div class="label_select"><p class="input_label">'.__('Secondary groups').': '.ui_print_help_icon('secondary_groups', true).'</p></div>';
$table_adv_secondary_groups_left = html_print_select_groups( $table_adv_secondary_groups_left = html_print_select_groups(
false, false,
// Use the current user to select the groups // Use the current user to select the groups.
'AR', 'AR',
// ACL permission // ACL permission.
false, false,
// Not all group // Not all group.
'secondary_groups', 'secondary_groups',
// HTML id // HTML id.
'', '',
// No select any by default // No select any by default.
'', '',
// Javascript onChange code // Javascript onChange code.
'', '',
// Do not user no selected value // Do not user no selected value.
0, 0,
// Do not use no selected value // Do not use no selected value.
true, true,
// Return HTML (not echo) // Return HTML (not echo).
true, true,
// Multiple selection // Multiple selection.
true, true,
// Sorting by default // Sorting by default.
'', '',
// CSS classnames (default) // CSS classnames (default).
false, false,
// Not disabled (default) // Not disabled (default).
'width:50%; min-width:170px;', 'width:50%; min-width:170px;',
// Inline styles (default) // Inline styles (default).
false, false,
// Option style select (default) // Option style select (default).
false, false,
// Do not truncate the users tree (default) // Do not truncate the users tree (default).
'id_grupo', 'id_grupo',
// Key to get as value (default) // Key to get as value (default).
false, false,
// Not strict user (default) // Not strict user (default).
$secondary_groups_selected['plain'] $secondary_groups_selected['plain']
// Do not show the primary group in this selection // Do not show the primary group in this selection.
); );
$table_adv_secondary_groups_arrows = html_print_input_image( $table_adv_secondary_groups_arrows = html_print_input_image(
@ -489,32 +489,32 @@ if (enterprise_installed()) {
$table_adv_secondary_groups_right .= html_print_select( $table_adv_secondary_groups_right .= html_print_select(
$secondary_groups_selected['for_select'], $secondary_groups_selected['for_select'],
// Values // Values.
'secondary_groups_selected', 'secondary_groups_selected',
// HTML id // HTML id.
'', '',
// Selected // Selected.
'', '',
// Javascript onChange code // Javascript onChange code.
'', '',
// Nothing selected // Nothing selected.
0, 0,
// Nothing selected // Nothing selected.
true, true,
// Return HTML (not echo) // Return HTML (not echo).
true, true,
// Multiple selection // Multiple selection.
true, true,
// Sort // Sort.
'', '',
// Class // Class.
false, false,
// Disabled // Disabled.
'width:50%; min-width:170px;' 'width:50%; min-width:170px;'
// Style // Style.
); );
// safe operation mode // Safe operation mode.
if ($id_agente) { if ($id_agente) {
$sql_modules = db_get_all_rows_sql( $sql_modules = db_get_all_rows_sql(
'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo
@ -538,12 +538,12 @@ if (enterprise_installed()) {
$table_adv_safe .= __('Module').'&nbsp;'.html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true).'</div>'; $table_adv_safe .= __('Module').'&nbsp;'.html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true).'</div>';
} }
// Remote configuration // Remote configuration.
$table_adv_remote = '<div class="label_select"><p class="input_label">'.__('Remote configuration').': </p>'; $table_adv_remote = '<div class="label_select"><p class="input_label">'.__('Remote configuration').': </p>';
if (!$new_agent && isset($filename) && file_exists($filename['md5'])) { if (!$new_agent && isset($filename) && file_exists($filename['md5'])) {
$table_adv_remote .= date('F d Y H:i:s', fileatime($filename['md5'])); $table_adv_remote .= date('F d Y H:i:s', fileatime($filename['md5']));
// Delete remote configuration // Delete remote configuration.
$table_adv_remote .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&disk_conf_delete=1&id_agente='.$id_agente.'">'; $table_adv_remote .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&disk_conf_delete=1&id_agente='.$id_agente.'">';
$table_adv_remote .= html_print_image( $table_adv_remote .= html_print_image(
'images/cross.png', 'images/cross.png',
@ -602,12 +602,25 @@ $params['cascade_protection'] = true;
$table_adv_parent .= '<div class="label_simple_items">'; $table_adv_parent .= '<div class="label_simple_items">';
$table_adv_parent .= ui_print_agent_autocomplete_input($params); $table_adv_parent .= ui_print_agent_autocomplete_input($params);
if (enterprise_installed()) { if (enterprise_installed()) {
$table_adv_parent .= html_print_checkbox_switch('cascade_protection', 1, $cascade_protection, true).__('Cascade protection').'&nbsp;'.ui_print_help_icon('cascade_protection', true); $table_adv_parent .= html_print_checkbox_switch(
'cascade_protection',
1,
$cascade_protection,
true
).__('Cascade protection').'&nbsp;'.ui_print_help_icon('cascade_protection', true);
} }
$table_adv_parent .= __('Module').'&nbsp;'.html_print_select($modules_values, 'cascade_protection_module', $cascade_protection_module, '', '', 0, true).'</div></div>'; $table_adv_parent .= __('Module').'&nbsp;'.html_print_select(
$modules_values,
'cascade_protection_module',
$cascade_protection_module,
'',
'',
0,
true
).'</div></div>';
// Learn mode / Normal mode // Learn mode / Normal mode.
$table_adv_module_mode = '<div class="label_select"><p class="input_label">'.__('Module definition').': '.ui_print_help_icon('module_definition', true).'</p>'; $table_adv_module_mode = '<div class="label_select"><p class="input_label">'.__('Module definition').': '.ui_print_help_icon('module_definition', true).'</p>';
$table_adv_module_mode .= '<div class="switch_radio_button">'; $table_adv_module_mode .= '<div class="switch_radio_button">';
$table_adv_module_mode .= html_print_radio_button_extended( $table_adv_module_mode .= html_print_radio_button_extended(
@ -642,9 +655,14 @@ $table_adv_module_mode .= html_print_radio_button_extended(
); );
$table_adv_module_mode .= '</div></div>'; $table_adv_module_mode .= '</div></div>';
// Status (Disabled / Enabled) // Status (Disabled / Enabled).
$table_adv_status = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Disabled').': '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).'</p>'; $table_adv_status = '<div class="label_select_simple label_simple_one_item"><p class="input_label input_label_simple">'.__('Disabled').': '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).'</p>';
$table_adv_status .= html_print_checkbox_switch('disabled', 1, $disabled, true).'</div>'; $table_adv_status .= html_print_checkbox_switch(
'disabled',
1,
$disabled,
true
).'</div>';
// Url address. // Url address.
if (enterprise_installed()) { if (enterprise_installed()) {
@ -681,11 +699,11 @@ foreach ($listIcons as $index => $value) {
} }
$path = 'images/gis_map/icons/'; $path = 'images/gis_map/icons/';
// TODO set better method the path // TODO set better method the path.
$table_adv_agent_icon = '<div class="label_select"><p class="input_label">'.__('Agent icon').': '.ui_print_help_tip(__('Agent icon for GIS Maps.'), true).'</p>'; $table_adv_agent_icon = '<div class="label_select"><p class="input_label">'.__('Agent icon').': '.ui_print_help_tip(__('Agent icon for GIS Maps.'), true).'</p>';
if ($icon_path == '') { if ($icon_path == '') {
$display_icons = 'none'; $display_icons = 'none';
// Hack to show no icon. Use any given image to fix not found image errors // Hack to show no icon. Use any given image to fix not found image errors.
$path_without = 'images/spinner.png'; $path_without = 'images/spinner.png';
$path_default = 'images/spinner.png'; $path_default = 'images/spinner.png';
$path_ok = 'images/spinner.png'; $path_ok = 'images/spinner.png';

View File

@ -2458,6 +2458,51 @@ function ui_print_status_image($type, $title='', $return=false, $options=false,
} }
/**
* Generates a progress bar CSS based.
* Requires css progress.css
*
* @param integer $progress Progress.
* @param string $width Width.
* @param string $height Height.
* @param string $color Color.
* @param boolean $return Return or paint (if false).
*
* @return string HTML code.
*/
function ui_progress(
$progress,
$width='100%',
$height='2em',
$color='#80ba27',
$return=true
) {
if (!$progress) {
$progress = 0;
}
if ($progress > 100) {
$progress = 100;
}
if ($progress < 0) {
$progress = 0;
}
ui_require_css_file('progress');
$output .= '<div class="progress_main">';
$output .= '<span class="progress_text">'.$progress.'%</span>';
$output .= '<div class="progress" style="width: '.$progress.'%;"></div>';
$output .= '</div>';
if (!$return) {
echo $output;
}
return $output;
}
/** /**
* Print a code into a DIV and enable a toggle to show and hide it * Print a code into a DIV and enable a toggle to show and hide it
* *

View File

@ -5945,6 +5945,43 @@ a#qr_code_agent_view {
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
*/ */
.bullet_modules {
width: 15px;
height: 15px;
border-radius: 50%;
margin-right: 5px;
margin-top: -2px;
}
div#bullets_modules {
display: inline-block;
margin-left: 2em;
}
div#bullets_modules div {
display: inline-block;
margin: 0 0.5em;
}
.orange_background {
background: #ffa631;
}
.red_background {
background: #fc4444;
}
.yellow_background {
background: #fad403;
}
.grey_background {
background: #b2b2b2;
}
.blue_background {
background: #3ba0ff;
}
.green_background {
background: #80ba27;
}
/* First row in agent view */ /* First row in agent view */
#agent_details_first_row { #agent_details_first_row {
display: flex; display: flex;
@ -5960,12 +5997,19 @@ a#qr_code_agent_view {
} }
.agent_details_col_left { .agent_details_col_left {
width: 38%; width: 40%;
min-width: 500px;
}
.agent_details_content .agent_details_bullets {
position: relative;
left: -20%;
} }
.agent_details_col_right { .agent_details_col_right {
width: 62%; width: 62%;
margin-left: 20px; margin-left: 20px;
min-width: 670px;
} }
.buttons_agent_view { .buttons_agent_view {
@ -5985,7 +6029,7 @@ a#qr_code_agent_view {
/* Agent details in agent view */ /* Agent details in agent view */
.agent_details_header { .agent_details_header {
display: flex; display: flex;
justify-content: space-between; justify-content: flex-end;
align-items: center; align-items: center;
border-bottom: 1px solid #e2e2e2; border-bottom: 1px solid #e2e2e2;
padding: 6px 20px; padding: 6px 20px;
@ -6005,6 +6049,7 @@ a#qr_code_agent_view {
.agent_details_graph { .agent_details_graph {
width: 205px; width: 205px;
text-align: center; text-align: center;
margin: 0 auto;
} }
.agent_details_info { .agent_details_info {

View File

@ -0,0 +1,18 @@
span.progress_text {
position: absolute;
font-family: "lato-bolder", "Open Sans", sans-serif;
font-size: 2em;
}
div.progress_main {
text-align: center;
height: 2.5em;
border: 1px solid #80ba27;
}
div.progress {
width: 0%;
background: #80ba27;
height: 100%;
float: left;
}

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* Extension to schedule tasks on Pandora FMS Console
*
* @category Agent view status.
* @package Pandora FMS
* @subpackage Classic agent management view.
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 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 General Public License
* as published by the Free Software Foundation for 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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2010 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 General Public License
// as published by the Free Software Foundation for 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.
// Load global vars
global $config; global $config;
require_once 'include/functions_agents.php'; require_once 'include/functions_agents.php';
@ -27,7 +42,12 @@ require_once $config['homedir'].'/include/functions_clippy.php';
check_login(); check_login();
$strict_user = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); $strict_user = (bool) db_get_value(
'strict_acl',
'tusuario',
'id_user',
$config['id_user']
);
$id_agente = get_parameter_get('id_agente', -1); $id_agente = get_parameter_get('id_agente', -1);
@ -50,7 +70,10 @@ if ($is_extra === ENTERPRISE_NOT_HOOK) {
$is_extra = false; $is_extra = false;
} }
if (! check_acl_one_of_groups($config['id_user'], $all_groups, 'AR') && ! check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') && !$is_extra) { if (! check_acl_one_of_groups($config['id_user'], $all_groups, 'AR')
&& ! check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')
&& !$is_extra
) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
'Trying to access Agent General Information' 'Trying to access Agent General Information'
@ -59,8 +82,17 @@ if (! check_acl_one_of_groups($config['id_user'], $all_groups, 'AR') && ! check_
return; return;
} }
// START: TABLE AGENT BUILD /*
$agent_name = ui_print_agent_name($agent['id_agente'], true, 500, 'font-size: medium;font-weight:bold', true); * START: TABLE AGENT BUILD.
*/
$agent_name = ui_print_agent_name(
$agent['id_agente'],
true,
500,
'font-size: medium;font-weight:bold',
true
);
$in_planned_downtime = db_get_sql( $in_planned_downtime = db_get_sql(
'SELECT executed FROM tplanned_downtime 'SELECT executed FROM tplanned_downtime
INNER JOIN tplanned_downtime_agents INNER JOIN tplanned_downtime_agents
@ -86,17 +118,31 @@ if ($agent['disabled']) {
} }
if ($in_planned_downtime && !$agent['disabled'] && !$agent['quiet']) { if ($in_planned_downtime && !$agent['disabled'] && !$agent['quiet']) {
$agent_name .= '<em>'.'&nbsp;'.ui_print_help_tip(__('Agent in planned downtime'), true, 'images/minireloj-16.png').'</em>'; $agent_name .= '<em>&nbsp;'.ui_print_help_tip(
} else if (($in_planned_downtime && !$agent['disabled']) || ($in_planned_downtime && !$agent['quiet'])) { __('Agent in planned downtime'),
$agent_name .= '&nbsp;'.ui_print_help_tip(__('Agent in planned downtime'), true, 'images/minireloj-16.png').'</em>'; true,
'images/minireloj-16.png'
).'</em>';
} else if (($in_planned_downtime && !$agent['disabled'])
|| ($in_planned_downtime && !$agent['quiet'])
) {
$agent_name .= '&nbsp;'.ui_print_help_tip(
__('Agent in planned downtime'),
true,
'images/minireloj-16.png'
).'</em>';
} }
$table_agent_header = '<div class="agent_details_agent_name">'; $table_agent_header = '<div class="agent_details_agent_name">';
if (!$config['show_group_name']) { if (!$config['show_group_name']) {
$table_agent_header .= ui_print_group_icon($agent['id_grupo'], true, 'groups_small', 'padding-right: 6px;'); $table_agent_header .= ui_print_group_icon(
$agent['id_grupo'],
true,
'groups_small',
'padding-right: 6px;'
);
} }
$table_agent_header .= $agent_name;
$table_agent_header .= '</div>'; $table_agent_header .= '</div>';
$status_img = agents_detail_view_status_img( $status_img = agents_detail_view_status_img(
@ -109,16 +155,33 @@ $status_img = agents_detail_view_status_img(
$table_agent_header .= '<div class="icono_right">'.$status_img.'</div>'; $table_agent_header .= '<div class="icono_right">'.$status_img.'</div>';
// Fixed width non interactive charts // Fixed width non interactive charts.
$status_chart_width = 180; $status_chart_width = 180;
$graph_width = 180; $graph_width = 180;
$table_agent_graph = '<div id="status_pie" style="width: '.$status_chart_width.'px;">'; $table_agent_graph = '<div id="status_pie" style="width: '.$status_chart_width.'px;">';
$table_agent_graph .= graph_agent_status($id_agente, $graph_width, $graph_width, true, false, false, true); $table_agent_graph .= graph_agent_status(
$id_agente,
$graph_width,
$graph_width,
true,
false,
false,
true
);
$table_agent_graph .= '</div>'; $table_agent_graph .= '</div>';
$table_agent_os = '<p>'.ui_print_os_icon($agent['id_os'], false, true, true, false, false, false, ['title' => __('OS').': '.get_os_name($agent['id_os'])]); $table_agent_os = '<p>'.ui_print_os_icon(
$table_agent_os .= empty($agent['os_version']) ? get_os_name((int) $agent['id_os']) : $agent['os_version'].'</p>'; $agent['id_os'],
false,
true,
true,
false,
false,
false,
['title' => __('OS').': '.get_os_name($agent['id_os'])]
);
$table_agent_os .= (empty($agent['os_version'])) ? get_os_name((int) $agent['id_os']) : $agent['os_version'].'</p>';
$addresses = agents_get_addresses($id_agente); $addresses = agents_get_addresses($id_agente);
$address = agents_get_address($id_agente); $address = agents_get_address($id_agente);
@ -158,8 +221,15 @@ $table_agent = '<div class="agent_details_header">'.$table_agent_header.'</div>
<div class="agent_details_bullets">'.$table_agent_count_modules.'</div> <div class="agent_details_bullets">'.$table_agent_count_modules.'</div>
</div> </div>
<div class="agent_details_info">'.$table_agent_os.$table_agent_ip.$table_agent_version.$table_agent_description.'</div>'; <div class="agent_details_info">'.$table_agent_os.$table_agent_ip.$table_agent_version.$table_agent_description.'</div>';
// END: TABLE AGENT BUILD
// START: TABLE CONTACT BUILD /*
* END: TABLE AGENT BUILD.
*/
/*
*START: TABLE CONTACT BUILD.
*/
$table_contact = new stdClass(); $table_contact = new stdClass();
$table_contact->id = 'agent_contact_main'; $table_contact->id = 'agent_contact_main';
$table_contact->width = '100%'; $table_contact->width = '100%';
@ -168,7 +238,7 @@ $table_contact->cellpadding = 0;
$table_contact->class = 'white_table white_table_no_border'; $table_contact->class = 'white_table white_table_no_border';
$table_contact->style[0] = 'width: 30%;'; $table_contact->style[0] = 'width: 30%;';
$table_contact->style[1] = 'width: 70%;'; $table_contact->style[1] = 'width: 70%;';
$table_contact->headstyle[1] = 'padding-top:6px; padding-bottom:6px'; $table_contact->headstyle[1] = 'padding-top:6px; padding-bottom:6px;padding-right: 10px;';
$table_contact->head[0] = ' <span>'.__('Agent contact').'</span>'; $table_contact->head[0] = ' <span>'.__('Agent contact').'</span>';
@ -210,8 +280,8 @@ $table_contact->data[] = $data;
$data = []; $data = [];
$table_contact->colspan[3][0] = 2; $table_contact->colspan[3][0] = 2;
$data[0] = progress_bar($progress, 500, 30, '', 1, false, '#82b92e'); $data[0] = ui_progress($progress);
// modo 1 para que muestre texto
if ($progress > 100) { if ($progress > 100) {
$data[0] .= clippy_context_help('agent_out_of_limits'); $data[0] .= clippy_context_help('agent_out_of_limits');
} }
@ -239,8 +309,14 @@ if (!$secondary_groups) {
$table_contact->data[] = $data; $table_contact->data[] = $data;
// END: TABLE CONTACT BUILD /*
// START: TABLE DATA BUILD * END: TABLE CONTACT BUILD
*/
/*
* START: TABLE DATA BUILD
*/
$table_data = new stdClass(); $table_data = new stdClass();
$table_data->id = 'agent_data_main'; $table_data->id = 'agent_data_main';
$table_data->width = '100%'; $table_data->width = '100%';
@ -249,11 +325,18 @@ $table_data->cellpadding = 0;
$table_data->class = 'white_table white_table_droppable'; $table_data->class = 'white_table white_table_droppable';
$table_data->style = array_fill(0, 3, 'width: 25%;'); $table_data->style = array_fill(0, 3, 'width: 25%;');
$table_data->head[0] = html_print_image('images/arrow_down_green.png', true, $options); $table_data->head[0] = html_print_image(
'images/arrow_down_green.png',
true,
$options
);
$table_data->head[0] .= ' <span style="vertical-align: middle; font-weight:bold; padding-left:20px">'.__('Agent info').'</span>'; $table_data->head[0] .= ' <span style="vertical-align: middle; font-weight:bold; padding-left:20px">'.__('Agent info').'</span>';
$table_data->head_colspan[0] = 4; $table_data->head_colspan[0] = 4;
$has_remote_conf = enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']]); $has_remote_conf = enterprise_hook(
'config_agents_has_remote_configuration',
[$agent['id_agente']]
);
if (enterprise_installed()) { if (enterprise_installed()) {
$data = []; $data = [];
@ -276,12 +359,14 @@ if (enterprise_installed()) {
$table_data->data[] = $data; $table_data->data[] = $data;
} }
// Gis and url address // Gis and url address.
$data_opcional = []; $data_opcional = [];
// Position Information // Position Information.
if ($config['activate_gis']) { if ($config['activate_gis']) {
$data_opcional[] = '<b>'.__('Position (Long, Lat)').'</b>'; $data_opcional[] = '<b>'.__('Position (Long, Lat)').'</b>';
$dataPositionAgent = gis_get_data_last_position_agent($agent['id_agente']); $dataPositionAgent = gis_get_data_last_position_agent(
$agent['id_agente']
);
if ($dataPositionAgent === false) { if ($dataPositionAgent === false) {
$data_opcional[] = __('There is no GIS data.'); $data_opcional[] = __('There is no GIS data.');
@ -299,7 +384,7 @@ if ($config['activate_gis']) {
array_push($data_opcional); array_push($data_opcional);
} }
// If the url description is setted // If the url description is set.
if ($agent['url_address'] != '') { if ($agent['url_address'] != '') {
// $data_opcional = []; // $data_opcional = [];
$data_opcional[] = '<b>'.__('Url address').'</b>'; $data_opcional[] = '<b>'.__('Url address').'</b>';
@ -311,7 +396,7 @@ if ($agent['url_address'] != '') {
} }
// Other IP address and timezone offset // Other IP address and timezone offset.
if (!empty($addresses)) { if (!empty($addresses)) {
// $data_opcional = []; // $data_opcional = [];
$data_opcional[] = '<b>'.__('Other IP addresses').'</b>'; $data_opcional[] = '<b>'.__('Other IP addresses').'</b>';
@ -322,7 +407,7 @@ if (!empty($addresses)) {
array_push($data_opcional); array_push($data_opcional);
} }
// Timezone Offset // Timezone Offset.
if ($agent['timezone_offset'] != 0) { if ($agent['timezone_offset'] != 0) {
$data_opcional[] = '<b>'.__('Timezone Offset').'</b>'; $data_opcional[] = '<b>'.__('Timezone Offset').'</b>';
if ($agent['timezone_offset'] != 0) { if ($agent['timezone_offset'] != 0) {
@ -339,7 +424,7 @@ foreach ($data_opcional as $key => $value) {
} }
// Custom fields // Custom fields.
$fields = db_get_all_rows_filter( $fields = db_get_all_rows_filter(
'tagent_custom_fields', 'tagent_custom_fields',
['display_on_front' => 1] ['display_on_front' => 1]
@ -392,28 +477,52 @@ for ($i = 0; $i <= $custom_fields_count; $i++) {
$i++; $i++;
} }
// END: TABLE DATA BUILD /*
// START: ACCESS RATE GRAPH * END: TABLE DATA BUILD
*/
/*
* START: ACCESS RATE GRAPH
*/
$access_agent = db_get_value_sql( $access_agent = db_get_value_sql(
'SELECT COUNT(id_agent) 'SELECT COUNT(id_agent)
FROM tagent_access FROM tagent_access
WHERE id_agent = '.$id_agente WHERE id_agent = '.$id_agente
); );
if ($config['agentaccess'] && $access_agent > 0) { if ($config['agentaccess'] && $access_agent > 0) {
$table_access_rate = '<div class="white_table_graph" id="table_access_rate"> $table_access_rate = '<div class="white_table_graph" id="table_access_rate">
<div class="white_table_graph_header">'.html_print_image('images/arrow_down_green.png', true).'<span>'.__('Agent access rate (24h)').'</span></div> <div class="white_table_graph_header">'.html_print_image(
<div class="white_table_graph_content">'.graphic_agentaccess($id_agente, '95%', 100, SECONDS_1DAY, true).'</div> 'images/arrow_down_green.png',
</div>'; true
).'<span>'.__('Agent access rate (24h)').'</span></div>
<div class="white_table_graph_content">'.graphic_agentaccess(
$id_agente,
'95%',
100,
SECONDS_1DAY,
true
).'</div>
</div>';
} }
// END: ACCESS RATE GRAPH /*
// START: TABLE INCIDENTS * END: ACCESS RATE GRAPH
*/
/*
* START: TABLE INCIDENTS
*/
$last_incident = db_get_row_sql( $last_incident = db_get_row_sql(
" sprintf(
SELECT * FROM tincidencia 'SELECT * FROM tincidencia
WHERE estado IN (0,1) WHERE estado IN (0,1)
AND id_agent = $id_agente AND id_agent = %d
ORDER BY actualizacion DESC" ORDER BY actualizacion DESC',
$id_agente
)
); );
if ($last_incident != false) { if ($last_incident != false) {
@ -424,7 +533,7 @@ if ($last_incident != false) {
$table_incident->class = 'white_table'; $table_incident->class = 'white_table';
$table_incident->style = array_fill(0, 3, 'width: 25%;'); $table_incident->style = array_fill(0, 3, 'width: 25%;');
$table_incident->head[0] = ' <span><a href="index.php?sec=incidencias&amp;sec2=operation/incidents/incident_detail&amp;id='.$last_incident['id_incidencia'].'">'.__('Active incident on this agent').'</a>'.'</span>'; $table_incident->head[0] = ' <span><a href="index.php?sec=incidencias&amp;sec2=operation/incidents/incident_detail&amp;id='.$last_incident['id_incidencia'].'">'.__('Active incident on this agent').'</a></span>';
$table_incident->head_colspan[0] = 4; $table_incident->head_colspan[0] = 4;
$data = []; $data = [];
@ -442,8 +551,14 @@ if ($last_incident != false) {
$table_incident->data[] = $data; $table_incident->data[] = $data;
} }
// END: TABLE INCIDENTS /*
// START: TABLE INTERFACES * END: TABLE INCIDENTS
*/
/*
* START: TABLE INTERFACES
*/
$network_interfaces_by_agents = agents_get_network_interfaces([$agent]); $network_interfaces_by_agents = agents_get_network_interfaces([$agent]);
$network_interfaces = []; $network_interfaces = [];
@ -476,7 +591,11 @@ if (!empty($network_interfaces)) {
'class' => 'closed', 'class' => 'closed',
'style' => 'cursor:pointer;', 'style' => 'cursor:pointer;',
]; ];
$table_interface->head[0] = html_print_image('images/arrow_down_green.png', true, $options).'&nbsp;&nbsp;'; $table_interface->head[0] = html_print_image(
'images/arrow_down_green.png',
true,
$options
).'&nbsp;&nbsp;';
$table_interface->head[0] .= '<span style="vertical-align: middle; font-weight:bold;">'.__('Interface information').' (SNMP)</span>'; $table_interface->head[0] .= '<span style="vertical-align: middle; font-weight:bold;">'.__('Interface information').' (SNMP)</span>';
$table_interface->head_colspan = []; $table_interface->head_colspan = [];
$table_interface->head_colspan[0] = 8; $table_interface->head_colspan[0] = 8;
@ -497,7 +616,7 @@ if (!empty($network_interfaces)) {
$params_json = json_encode($params); $params_json = json_encode($params);
$params_encoded = base64_encode($params_json); $params_encoded = base64_encode($params_json);
$win_handle = dechex(crc32($interface['status_module_id'].$interface_name)); $win_handle = dechex(crc32($interface['status_module_id'].$interface_name));
$graph_link = "<a href=\"javascript:winopeng('operation/agentes/interface_traffic_graph_win.php?params=$params_encoded','$win_handle')\">".html_print_image('images/chart_curve.png', true, ['title' => __('Interface traffic')]).'</a>'; $graph_link = "<a href=\"javascript:winopeng('operation/agentes/interface_traffic_graph_win.php?params=".$params_encoded."','".$win_handle."')\">".html_print_image('images/chart_curve.png', true, ['title' => __('Interface traffic')]).'</a>';
} else { } else {
$graph_link = ''; $graph_link = '';
} }
@ -520,9 +639,9 @@ if (!empty($network_interfaces)) {
$status_condition = ' AND (estado = 0 OR estado = 1) '; $status_condition = ' AND (estado = 0 OR estado = 1) ';
$unixtime = (get_system_time() - SECONDS_1DAY); $unixtime = (get_system_time() - SECONDS_1DAY);
// last hour // Last hour.
$time_condition = 'AND (utimestamp > '.$unixtime.')'; $time_condition = 'AND (utimestamp > '.$unixtime.')';
// Tags ACLS // Tags ACLs.
if ($id_group > 0 && in_array(0, $user_groups_ids)) { if ($id_group > 0 && in_array(0, $user_groups_ids)) {
$group_array = (array) $id_group; $group_array = (array) $id_group;
} else { } else {
@ -545,18 +664,16 @@ if (!empty($network_interfaces)) {
$id_modules_array[] = $interface['status_module_id']; $id_modules_array[] = $interface['status_module_id'];
$unixtime = (get_system_time() - SECONDS_1DAY); $unixtime = (get_system_time() - SECONDS_1DAY);
// last hour // Last hour.
$time_condition = 'WHERE (te.utimestamp > '.$unixtime.')'; $time_condition = 'WHERE (te.utimestamp > '.$unixtime.')';
$sqlEvents = sprintf( $sqlEvents = sprintf(
' 'SELECT *
SELECT *
FROM tevento te FROM tevento te
INNER JOIN tagente_estado tae INNER JOIN tagente_estado tae
ON te.id_agentmodule = tae.id_agente_modulo ON te.id_agentmodule = tae.id_agente_modulo
AND tae.id_agente_modulo IN (%s) AND tae.id_agente_modulo IN (%s)
%s %s',
',
implode(',', $id_modules_array), implode(',', $id_modules_array),
$time_condition $time_condition
); );
@ -600,8 +717,12 @@ if (!empty($network_interfaces)) {
} }
} }
// END: TABLE INTERFACES /*
// This javascript piece of code is used to make expandible the body of the table * END: TABLE INTERFACES
*/
// This javascript piece of code is used to make expandible
// the body of the table.
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready (function () { $(document).ready (function () {
@ -654,24 +775,51 @@ if (!empty($network_interfaces)) {
}); });
</script> </script>
<?php <?php
$table_events = '<div class="white_table_graph" id="table_events"> /*
<div class="white_table_graph_header">'.html_print_image('images/arrow_down_green.png', true).'<span>'.__('Events (24h)').'</span></div> * EVENTS.
<div class="white_table_graph_content">'.graph_graphic_agentevents($id_agente, 100, 45, SECONDS_1DAY, '', true, true).'</div> */
</div>';
$table_events = '<div class="white_table_graph" id="table_events">
<div class="white_table_graph_header">'.html_print_image(
'images/arrow_down_green.png',
true
).'<span>'.__('Events (24h)').'</span></div>
<div class="white_table_graph_content">'.graph_graphic_agentevents(
$id_agente,
100,
45,
SECONDS_1DAY,
'',
true,
true
).'</div>
</div>';
$agent_contact = html_print_table($table_contact, true); /*
* EVENTS TABLE END.
*/
$agent_info = empty($table_data->data) ? '' : html_print_table($table_data, true); $agent_contact = html_print_table($table_contact, true);
$agent_incidents = !isset($table_incident) ? '' : html_print_table($table_incident, true); $agent_info = empty($table_data->data) ? '' : html_print_table($table_data, true);
echo '<div id="agent_details_first_row"> $agent_incidents = !isset($table_incident) ? '' : html_print_table($table_incident, true);
<div class="agent_details_col agent_details_col_left">'.$table_agent.'</div>
<div class="agent_details_col agent_details_col_right">'.$agent_contact.'</div>
</div>'.$agent_info.'<div style="display:grid; grid-template-columns: 1fr 1fr; grid-column-gap: 20px;">'.$table_access_rate.$table_events.'</div>'.$agent_incidents;
if (isset($table_interface)) { echo '<div id="agent_details_first_row">
echo html_print_table($table_interface, true); <div class="agent_details_col agent_details_col_left">'.$table_agent.'</div>
} <div class="agent_details_col agent_details_col_right">'.$agent_contact.'</div>
</div>'.$agent_info;
// Show both graphs, events and access rate.
if ($table_access_rate) {
echo '<div style="display:grid; grid-template-columns: 1fr 1fr; grid-column-gap: 20px;">'.$table_access_rate.$table_events.'</div>';
} else {
echo '<div style="width: 100%">'.$table_events.'</div>';
}
echo $agent_incidents;
if (isset($table_interface)) {
echo html_print_table($table_interface, true);
}

View File

@ -134,7 +134,12 @@ $sort = get_parameter('sort', 'up');
echo "<h4 style='padding-top:0px !important;'>"; echo "<h4 style='padding-top:0px !important;'>";
echo ui_print_help_tip(__('To see the list of modules paginated, enable this option in the Styles Configuration.'), true).__('Full list of monitors').'&nbsp;'.reporting_tiny_stats($agent, true, 'modules'); echo ui_print_help_tip(
__('To see the list of modules paginated, enable this option in the Styles Configuration.'),
true
);
echo '<span>'.__('Full list of monitors').'</span>';
echo reporting_tiny_stats($agent, true, 'modules');
$modules_not_init = agents_monitor_notinit($id_agente); $modules_not_init = agents_monitor_notinit($id_agente);
if (!empty($modules_not_init)) { if (!empty($modules_not_init)) {
@ -514,4 +519,3 @@ function print_form_filter_monitors(
echo $form_text; echo $form_text;
} }