diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php
index 37fac4ccac..86ea0cb301 100755
--- a/pandora_console/include/ajax/module.php
+++ b/pandora_console/include/ajax/module.php
@@ -55,6 +55,7 @@ if (check_login()) {
$get_id_tag = (bool) get_parameter('get_id_tag', 0);
$get_type = (bool) get_parameter('get_type', 0);
$list_modules = (bool) get_parameter('list_modules', 0);
+ $list_snmp_modules = (bool) get_parameter('list_snmp_modules', 0);
$get_agent_modules_json_by_name = (bool) get_parameter(
'get_agent_modules_json_by_name',
0
@@ -1538,6 +1539,133 @@ if (check_login()) {
unset($table_data);
}
+ if ($list_snmp_modules) {
+ include_once $config['homedir'].'/include/functions_graph.php';
+ $agent = get_parameter('agent');
+ $id_agente = $agent;
+ $paginate_module = false;
+ if (isset($config['paginate_module']) === true) {
+ $paginate_module = (bool) $config['paginate_module'];
+ }
+
+ $network_interfaces_by_agents = agents_get_network_interfaces([$agent], false, $paginate_module, get_parameter('offset', 0));
+ $count_network_incerfaces = agents_get_network_interfaces([$agent], false, false, 0, true);
+ $network_interfaces = [];
+ if (empty($network_interfaces_by_agents) === false && empty($network_interfaces_by_agents[$id_agente]) === false) {
+ $network_interfaces = $network_interfaces_by_agents[$id_agente]['interfaces'];
+ }
+
+ if (empty($network_interfaces) === false) {
+ $table_interface = new stdClass();
+ $table_interface->id = 'agent_interface_info';
+ $table_interface->class = 'info_table';
+ $table_interface->width = '100%';
+ $table_interface->style = [];
+ $table_interface->style['interface_event_graph'] = 'width: 35%;';
+
+ $table_interface->head = [];
+ $options = [
+ 'class' => 'closed',
+ 'style' => 'cursor:pointer;',
+ ];
+ $table_interface->data = [];
+ $event_text_cont = 0;
+
+ foreach ($network_interfaces as $interface_name => $interface) {
+ if (empty($interface['traffic']) === false) {
+ $permission = check_acl_one_of_groups($config['id_user'], $all_groups, 'RR');
+
+ if ($permission) {
+ $params = [
+ '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_link = "";
+ $graph_link .= html_print_image(
+ 'images/chart.png',
+ true,
+ [
+ 'title' => __('Interface traffic'),
+ 'class' => 'invert_filter',
+ ]
+ ).'';
+ } else {
+ $graph_link = '';
+ }
+ } else {
+ $graph_link = '';
+ }
+
+ $content = [
+ 'id_agent_module' => $interface['status_module_id'],
+ 'id_group' => $id_group,
+ 'period' => SECONDS_1DAY,
+ 'time_from' => '00:00:00',
+ 'time_to' => '00:00:00',
+ 'sizeForTicks' => 250,
+ 'height_graph' => 40,
+ [
+ ['id_agent_module' => $interface['status_module_id']],
+ ]
+ ];
+
+ $e_graph = \reporting_module_histogram_graph(
+ ['datetime' => time()],
+ $content
+ );
+
+ $sqlLast_contact = sprintf(
+ '
+ SELECT timestamp
+ FROM tagente_estado
+ WHERE id_agente_modulo = '.$interface['status_module_id']
+ );
+
+ $last_contact = db_get_all_rows_sql($sqlLast_contact);
+ $last_contact = array_shift($last_contact);
+ $last_contact = array_shift($last_contact);
+
+ $data = [];
+ $data['interface_name'] = ''.$interface_name.'';
+ $data['interface_status'] = $interface['status_image'];
+ $data['interface_graph'] = $graph_link;
+ $data['interface_ip'] = $interface['ip'];
+ $data['interface_mac'] = $interface['mac'];
+ $data['last_contact'] = __('Last contact: ').$last_contact;
+ $data['interface_event_graph'] = $e_graph['chart'];
+
+ $table_interface->data[] = $data;
+ }
+
+ if ($paginate_module === true) {
+ ui_pagination(
+ $count_network_incerfaces,
+ false,
+ 0,
+ 0,
+ false,
+ 'offset',
+ true,
+ '',
+ 'change_page_snmp(offset_param)',
+ [
+ 'count' => '',
+ 'offset' => 'offset_param',
+ ]
+ );
+ }
+
+ html_print_table($table_interface);
+ }
+ }
+
if ($get_type === true) {
$id_module = (int) get_parameter('id_module');
$module = modules_get_agentmodule($id_module);
diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index 64550b1452..a2d07a6976 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -1544,7 +1544,9 @@ function agents_get_modules(
$indexed=true,
$get_not_init_modules=true,
$force_tags=false,
- $filter_include_sql=true
+ $filter_include_sql=true,
+ $pagination=false,
+ $offset=0,
) {
global $config;
@@ -1717,7 +1719,17 @@ function agents_get_modules(
$sql_tags_join,
$where
);
- $result = db_get_all_rows_sql($sql);
+
+ $limit = '';
+ if ($pagination === true && isset($config['paginate_module']) === true) {
+ if ($offset === 0) {
+ $limit = ' LIMIT '.$config['block_size'].' OFFSET 0';
+ } else {
+ $limit = ' LIMIT '.$config['block_size'].' OFFSET '.$offset;
+ }
+ }
+
+ $result = db_get_all_rows_sql($sql.$limit);
if (empty($result)) {
return [];
@@ -3333,7 +3345,7 @@ function agents_update_gis(
*
* @return array A list of network interfaces information by agents.
*/
-function agents_get_network_interfaces($agents=false, $agents_filter=false)
+function agents_get_network_interfaces($agents=false, $agents_filter=false, $pagination=false, $offset=0, $count=false)
{
global $config;
@@ -3432,8 +3444,17 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false)
$columns,
$filter,
true,
- false
+ false,
+ false,
+ true,
+ $pagination,
+ $offset
);
+
+ if ($count === true) {
+ return (count($modules) ?? 0);
+ }
+
if (!empty($modules)) {
$interfaces = [];
diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php
index 82aa8376d1..e50a5b174f 100755
--- a/pandora_console/operation/agentes/estado_generalagente.php
+++ b/pandora_console/operation/agentes/estado_generalagente.php
@@ -374,111 +374,6 @@ for ($i = 0; $i < $custom_fields_count; $i++) {
/*
* END: TABLE DATA BUILD
- */
-
-/*
- * START: TABLE INTERFACES
- */
-
-$network_interfaces_by_agents = agents_get_network_interfaces([$agent]);
-
-$network_interfaces = [];
-if (empty($network_interfaces_by_agents) === false && empty($network_interfaces_by_agents[$id_agente]) === false) {
- $network_interfaces = $network_interfaces_by_agents[$id_agente]['interfaces'];
-}
-
-if (empty($network_interfaces) === false) {
- $table_interface = new stdClass();
- $table_interface->id = 'agent_interface_info';
- $table_interface->class = 'info_table';
- $table_interface->width = '100%';
- $table_interface->style = [];
- $table_interface->style['interface_event_graph'] = 'width: 35%;';
-
- $table_interface->head = [];
- $options = [
- 'class' => 'closed',
- 'style' => 'cursor:pointer;',
- ];
- $table_interface->data = [];
- $event_text_cont = 0;
-
- foreach ($network_interfaces as $interface_name => $interface) {
- if (empty($interface['traffic']) === false) {
- $permission = check_acl_one_of_groups($config['id_user'], $all_groups, 'RR');
-
- if ($permission) {
- $params = [
- '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_link = "";
- $graph_link .= html_print_image(
- 'images/chart.png',
- true,
- [
- 'title' => __('Interface traffic'),
- 'class' => 'invert_filter',
- ]
- ).'';
- } else {
- $graph_link = '';
- }
- } else {
- $graph_link = '';
- }
-
- $content = [
- 'id_agent_module' => $interface['status_module_id'],
- 'id_group' => $id_group,
- 'period' => SECONDS_1DAY,
- 'time_from' => '00:00:00',
- 'time_to' => '00:00:00',
- 'sizeForTicks' => 250,
- 'height_graph' => 40,
- [
- ['id_agent_module' => $interface['status_module_id']],
- ]
- ];
-
- $e_graph = \reporting_module_histogram_graph(
- ['datetime' => time()],
- $content
- );
-
- $sqlLast_contact = sprintf(
- '
- SELECT timestamp
- FROM tagente_estado
- WHERE id_agente_modulo = '.$interface['status_module_id']
- );
-
- $last_contact = db_get_all_rows_sql($sqlLast_contact);
- $last_contact = array_shift($last_contact);
- $last_contact = array_shift($last_contact);
-
- $data = [];
- $data['interface_name'] = ''.$interface_name.'';
- $data['interface_status'] = $interface['status_image'];
- $data['interface_graph'] = $graph_link;
- $data['interface_ip'] = $interface['ip'];
- $data['interface_mac'] = $interface['mac'];
- $data['last_contact'] = __('Last contact: ').$last_contact;
- $data['interface_event_graph'] = $e_graph['chart'];
-
- $table_interface->data[] = $data;
- }
-}
-
-/*
- * END: TABLE INTERFACES
*/
// This javascript piece of code is used to make expandible
@@ -651,16 +546,23 @@ if (empty($agentIncidents) === false) {
);
}
-if (isset($table_interface) === true) {
+$count_network_incerfaces = agents_get_network_interfaces([$agent], false, false, 0, true);
+if ($count_network_incerfaces > 0) {
ui_toggle(
- html_print_table($table_interface, true),
+ html_print_div(
+ [
+ 'id' => 'agent_interface_info',
+ 'content' => '',
+ 'class' => 'w100p',
+ ],
+ true
+ ),
''.__('Interface information (SNMP)').'',
'',
'interface-table-status-agent',
true
);
}
-
?>