Merge branch 'ent-3595-discovery-fase-2' into 'develop'

Ent 3595 discovery fase 2

See merge request artica/pandorafms!2230

Former-commit-id: 2d5e2e4ff57612c727f20357bfb9de5b8c29ae72
This commit is contained in:
Alejandro Fraguas 2019-03-27 12:13:06 +01:00
commit edefd16a21
81 changed files with 8257 additions and 5327 deletions

View File

@ -1,8 +1,14 @@
START TRANSACTION;
ALTER TABLE `treport_content` ADD COLUMN `show_extended_events` tinyint(1) default '0';
-- ----------------------------------------------------------------------
-- Add column in table `tagent_custom_fields`
-- ----------------------------------------------------------------------
ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` VARCHAR(255) DEFAULT '';
ALTER TABLE `treport_content` ADD COLUMN `show_extended_events` tinyint(1) default '0';
ALTER TABLE `trecon_task` ADD COLUMN `summary` text;
COMMIT;

View File

@ -1376,6 +1376,7 @@ ALTER TABLE treport_content ADD COLUMN `lapse` int(11) default '300';
ALTER TABLE treport_content ADD COLUMN `visual_format` tinyint(1) default '0';
ALTER TABLE treport_content ADD COLUMN `hide_no_data` tinyint(1) default '0';
ALTER TABLE treport_content ADD COLUMN `recursion` tinyint(1) default NULL;
ALTER TABLE treport_content ADD COLUMN `show_extended_events` tinyint(1) default '0';
-- ---------------------------------------------------------------------
-- Table `tmodule_relationship`
@ -1410,6 +1411,7 @@ ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0';
ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0';
ALTER TABLE trecon_task ADD `auth_strings` text;
ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0';
ALTER TABLE trecon_task ADD `summary` text;
-- ---------------------------------------------------------------------
-- Table `twidget` AND Table `twidget_dashboard`

View File

@ -22,7 +22,7 @@ ui_require_css_file('firts_task');
<?php echo html_print_image('images/icono_grande_reconserver.png', true, ['title' => __('Collections')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Collections'); ?> <p id="description_task">
<h3> <?php echo __('Create Collections'); ?></h3><p id="description_task">
<?php
echo __(
"A file collection is a group of files (e.g. scripts or executables) which are

View File

@ -24,7 +24,7 @@ ui_print_info_message(['no_close' => true, 'message' => __('There are no custom
<?php echo html_print_image('images/firts_task/icono_grande_reconserver.png', true, ['title' => __('Custom Fields')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Custom Fields'); ?> <p id="description_task">
<h3> <?php echo __('Create Custom Fields'); ?></h3><p id="description_task">
<?php
echo __(
"Custom fields are an easy way to personalized agent's information.

View File

@ -24,7 +24,7 @@ ui_print_info_message(['no_close' => true, 'message' => __('There are no custom
<?php echo html_print_image('images/firts_task/icono_grande_custom_reporting.png', true, ['title' => __('Custom Graphs')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Custom Graph'); ?> <p id="description_task">
<h3> <?php echo __('Create Custom Graph'); ?></h3><p id="description_task">
<?php
echo __(
"Graphs are designed to show the data collected by %s in a temporary scale defined by the user.

View File

@ -22,7 +22,7 @@ ui_require_css_file('firts_task');
<?php echo html_print_image('images/firts_task/icono_grande_reconserver.png', true, ['title' => __('Fields Manager')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Fields Manager'); ?> <p id="description_task">
<h3> <?php echo __('Create Fields Manager'); ?></h3><p id="description_task">
<?php
echo __(
"Custom fields are an easy way to personalized agent's information.

View File

@ -28,7 +28,7 @@ if ($incident_w || $incident_m) {
<?php echo html_print_image('images/firts_task/icono_grande_incidencia.png', true, ['title' => __('Incidents')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Incidents'); ?> <p id="description_task">
<h3> <?php echo __('Create Incidents'); ?></h3><p id="description_task">
<?php
echo __(
"Besides receiving and processing data to monitor systems or applications,

View File

@ -31,7 +31,7 @@ if ($vconsoles_write || $vconsoles_manage) {
<?php echo html_print_image('images/firts_task/icono_grande_visualconsole.png', true, ['title' => __('Visual Console')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Visual Console'); ?> <p id="description_task">
<h3> <?php echo __('Create Visual Console'); ?></h3><p id="description_task">
<?php
echo __(
'%s allows users to create visual maps on which each user is able to create his or her '.'own monitoring map. The new visual console editor is much more practical, although the prior '."visual console editor had its advantages. On the new visual console, we've been successful in "."imitating the sensation and touch of a drawing application like GIMP. We've also simplified the "."editor by dividing it into several subject-divided tabs named 'Data', 'Preview', 'Wizard', 'List of "."Elements' and 'Editor'. The items the %s Visual Map was designed to handle are "."'static images', 'percentage bars', 'module graphs' and 'simple values'.",

View File

@ -26,7 +26,7 @@ $networkmap_types = networkmap_get_types($strict_user);
<?php echo html_print_image('images/firts_task/icono_grande_reconserver.png', true, ['title' => __('Network Map')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Network Map'); ?> <p id="description_task">
<h3> <?php echo __('Create Network Map'); ?></h3><p id="description_task">
<?php
echo __(
'There is also an open-source version of the network map.

View File

@ -22,7 +22,7 @@ ui_require_css_file('firts_task');
<?php echo html_print_image('images/firts_task/icono_grande_visualconsole.png', true, ['title' => __('Planned Downtime')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Planned Downtime'); ?> <p id="description_task">
<h3> <?php echo __('Create Planned Downtime'); ?></h3><p id="description_task">
<?php
echo __(
"%s contains a scheduled downtime management system.

View File

@ -22,7 +22,7 @@ ui_require_css_file('firts_task');
<?php echo html_print_image('images/firts_task/icono_grande_reconserver.png', true, ['title' => __('Discovery server')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Discovery Task'); ?><p id="description_task">
<h3> <?php echo __('Create Discovery Task'); ?></h3><p id="description_task">
<?php
echo __(
'Discovery Task are used to find new elements in the network.

View File

@ -25,7 +25,7 @@ ui_require_css_file('firts_task');
<?php echo html_print_image('images/firts_task/icono_grande_servicios.png', true, ['title' => __('Services')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Services'); ?> <p id="description_task">
<h3> <?php echo __('Create Services'); ?></h3><p id="description_task">
<?php
echo __(
"A service is a way to group your IT resources based on their functionalities.

View File

@ -22,7 +22,7 @@ ui_require_css_file('firts_task');
<?php echo html_print_image('images/firts_task/icono_grande_reconserver.png', true, ['title' => __('SNMP Filter')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create SNMP Filter'); ?> <p id="description_task">
<h3> <?php echo __('Create SNMP Filter'); ?></h3><p id="description_task">
<?php
echo __(
"Some systems receive a high number of traps.

View File

@ -22,7 +22,7 @@ ui_require_css_file('firts_task');
<?php echo html_print_image('images/firts_task/icono_grande_gestiondetags.png', true, ['title' => __('Tags')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Tags'); ?> <p id="description_task">
<h3> <?php echo __('Create Tags'); ?></h3><p id="description_task">
<?php
echo __(
"Access to modules can be configured by a tagging system.

View File

@ -28,7 +28,7 @@ if ($networkmaps_write || $networkmaps_manage) {
<?php echo html_print_image('images/firts_task/icono_grande_topology.png', true, ['title' => __('Transactions')]); ?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Transactions'); ?> <p id="description_task">
<h3> <?php echo __('Create Transactions'); ?></h3><p id="description_task">
<?php
echo __(
'The new transactional server allows you to execute tasks dependent on the others following a user-defined design. This means that it is possible to coordinate several executions to check a target at a given time.

View File

@ -305,12 +305,12 @@ if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) {
echo '<div class ="img_banner_login">';
if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) {
if (isset($config['custom_splash_login'])) {
html_print_image('enterprise/images/custom_splash_login/'.$config['custom_splash_login'], false, [ 'alt' => 'splash', 'border' => 0, 'title' => $splash_title], false, true);
html_print_image('enterprise/images/custom_splash_login/'.$config['custom_splash_login'], false, [ 'alt' => 'splash', 'border' => 0], false, true);
} else {
html_print_image('enterprise/images/custom_splash_login/splash_image_default.png', false, ['alt' => 'logo', 'border' => 0, 'title' => $splash_title], false, true);
html_print_image('enterprise/images/custom_splash_login/splash_image_default.png', false, ['alt' => 'logo', 'border' => 0], false, true);
}
} else {
html_print_image('images/splash_image_default.png', false, ['alt' => 'logo', 'border' => 0, 'title' => $splash_title], false, true);
html_print_image('images/splash_image_default.png', false, ['alt' => 'logo', 'border' => 0], false, true);
}
echo '</div>';

View File

@ -1,26 +1,39 @@
<?php
/**
* Extension to self monitor Pandora FMS Console
*
* @category Main page
* @package Pandora FMS
* @subpackage Introduction
* @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
// ==================================================
// 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 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.
// Config functions.
require_once 'include/config.php';
// This solves problems in enterprise load
// This solves problems in enterprise load.
global $config;
check_login();
/*
Call all extensions login function */
// extensions_call_login_function ();
require_once 'include/functions_reporting.php';
require_once 'include/functions_tactical.php';
require_once $config['homedir'].'/include/functions_graph.php';
@ -29,8 +42,18 @@ if (tags_has_user_acl_tags()) {
ui_print_tags_warning();
}
$user_strict = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$all_data = tactical_status_modules_agents($config['id_user'], $user_strict, 'AR', $user_strict);
$user_strict = (bool) db_get_value(
'strict_acl',
'tusuario',
'id_user',
$config['id_user']
);
$all_data = tactical_status_modules_agents(
$config['id_user'],
$user_strict,
'AR',
$user_strict
);
$data = [];
$data['monitor_not_init'] = (int) $all_data['_monitors_not_init_'];
@ -79,6 +102,8 @@ if (!empty($all_data)) {
$data['server_sanity'] = format_numeric((100 - $data['module_sanity']), 1);
}
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
@ -88,7 +113,7 @@ if (!empty($all_data)) {
<?php
//
// Overview Table
// Overview Table.
//
$table = new stdClass();
$table->class = 'databox';
@ -101,12 +126,12 @@ if (!empty($all_data)) {
$table->head[0] = '<span>'.__('%s Overview', get_product_name()).'</span>';
$table->head_colspan[0] = 4;
// Indicators
// Indicators.
$tdata = [];
$stats = reporting_get_stats_indicators($data, 120, 10, false);
$status = '<table class="status_tactical">';
foreach ($stats as $stat) {
$status .= '<tr><td><b>'.$stat['title'].'</b>'.'</td><td>'.$stat['graph'].'</td></tr>';
$status .= '<tr><td><b>'.$stat['title'].'</b></td><td>'.$stat['graph'].'</td></tr>';
}
$status .= '</table>';
@ -115,25 +140,25 @@ if (!empty($all_data)) {
$table->data[] = $tdata;
// Alerts
// Alerts.
$tdata = [];
$tdata[0] = reporting_get_stats_alerts($data);
$table->rowclass[] = '';
$table->data[] = $tdata;
// Modules by status
// Modules by status.
$tdata = [];
$tdata[0] = reporting_get_stats_modules_status($data, 180, 100);
$table->rowclass[] = '';
$table->data[] = $tdata;
// Total agents and modules
// Total agents and modules.
$tdata = [];
$tdata[0] = reporting_get_stats_agents_monitors($data);
$table->rowclass[] = '';
$table->data[] = $tdata;
// Users
// Users.
if (users_is_admin()) {
$tdata = [];
$tdata[0] = reporting_get_stats_users($data);
@ -160,7 +185,7 @@ if (!empty($all_data)) {
if (!empty($news)) {
// NEWS BOARD/////////////////////////////
// NEWS BOARD.
echo '<div id="news_board">';
echo '<table cellpadding="0" width=100% cellspacing="0" class="databox filters">';
@ -184,20 +209,72 @@ if (!empty($all_data)) {
echo '</table>';
echo '</div>';
// News board
// News board.
echo '<br><br>';
// END OF NEWS BOARD/////////////////////////////
// END OF NEWS BOARD.
}
// LAST ACTIVITY/////////////////////////////
// Show last activity from this user
$nots = messages_get_overview('utimestamp', 'DESC', false);
if (!empty($nots)) {
// Notifications board.
echo '<div id="notifications_board">';
echo '<table cellpadding="0" width=100% cellspacing="0" class="databox filters">';
echo '<tr><th style="text-align:center;"><span >'.__('Pending notifications').'</span></th></tr>';
if ($config['prominent_time'] == 'timestamp') {
$comparation_suffix = '';
} else {
$comparation_suffix = __('ago');
}
foreach ($nots as $msg) {
$conversation = io_safe_output(
messages_get_conversation($msg)
);
if (is_array($conversation)) {
$text = array_pop($conversation)['message'];
} else {
// Skip empty message.
continue;
}
$url = ui_get_full_url(
'index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$msg['id_mensaje']
);
if ($msg['url'] != '') {
$url = $msg['url'];
}
echo '<tr><th class="green_title">'.$msg['subject'].'</th></tr>';
echo '<tr><td><a href="'.$url.'">';
if ($msg['id_usuario_origen'] != '') {
echo '<b>'.get_user_fullname($msg['id_usuario_origen']).'</b> ';
}
echo '<i>'.ui_print_timestamp($msg['timestamp'], true).'</i> '.$comparation_suffix.'</a></td></tr>';
echo '<tr><td class="datos">';
echo nl2br($text);
echo '</td></tr>';
}
echo '</table>';
echo '</div>';
echo '<br><br>';
// EO Notifications board.
}
// LAST ACTIVITY.
// Show last activity from this user.
echo '<div id="activity">';
$table = new stdClass();
$table->class = 'databox data';
$table->width = '100%';
// Don't specify px
// Don't specify px.
$table->data = [];
$table->size = [];
$table->size[0] = '5%';
@ -212,9 +289,6 @@ if (!empty($all_data)) {
$table->head[3] = __('Source IP');
$table->head[4] = __('Comments');
$table->title = '<span>'.__('This is your last activity performed on the %s console', get_product_name()).'</span>';
switch ($config['dbtype']) {
case 'mysql':
$sql = sprintf(
'SELECT id_usuario,accion, ip_origen,descripcion,utimestamp
FROM tsesion
@ -222,28 +296,7 @@ if (!empty($all_data)) {
AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10",
$config['id_user']
);
break;
case 'postgresql':
$sql = sprintf(
"SELECT \"id_usuario\", accion, \"ip_origen\", descripcion, utimestamp
FROM tsesion
WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_1WEEK.")
AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 10",
$config['id_user']
);
break;
case 'oracle':
$sql = sprintf(
"SELECT id_usuario, accion, ip_origen, descripcion, utimestamp
FROM tsesion
WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_1WEEK.")
AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC",
$config['id_user']
);
break;
}
$sessions = db_get_all_rows_sql($sql);
@ -253,24 +306,17 @@ if (!empty($all_data)) {
foreach ($sessions as $session) {
$data = [];
switch ($config['dbtype']) {
case 'mysql':
case 'oracle':
$session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen'];
break;
case 'postgresql':
$session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen'];
break;
}
$data[0] = '<strong>'.$session_id_usuario.'</strong>';
$data[1] = ui_print_session_action_icon($session['accion'], true).' '.$session['accion'];
$data[2] = ui_print_help_tip(date($config['date_format'], $session['utimestamp']), true).human_time_comparation($session['utimestamp'], 'tiny');
$data[2] = ui_print_help_tip(
date($config['date_format'], $session['utimestamp']),
true
).human_time_comparation($session['utimestamp'], 'tiny');
$data[3] = $session_ip_origen;
$description = str_replace([',', ', '], ', ', $session['descripcion']);
if (strlen($description) > 100) {
@ -287,8 +333,7 @@ if (!empty($all_data)) {
unset($table);
echo '</div>';
echo '</div>';
// activity
// END OF LAST ACTIVIYY/////////////////////////////
// END OF LAST ACTIVIYY.
?>

View File

@ -24,15 +24,15 @@ $menu_godmode['class'] = 'godmode';
if (check_acl($config['id_user'], 0, 'PM')) {
$sub = [];
$sub['godmode/servers/discovery']['text'] = __('Discover');
$sub['godmode/servers/discovery']['id'] = 'Discover';
$sub['godmode/servers/discovery']['text'] = __('Discovery');
$sub['godmode/servers/discovery']['id'] = 'Discovery';
$sub['godmode/servers/discovery']['subsecs'] = ['godmode/servers/discovery'];
// Add to menu.
$menu_godmode['discover']['text'] = __('Discovery');
$menu_godmode['discover']['sec2'] = 'godmode/servers/discovery';
$menu_godmode['discover']['id'] = 'god-discovery';
$menu_godmode['discover']['sub'] = $sub;
$menu_godmode['discovery']['text'] = __('Discovery');
$menu_godmode['discovery']['sec2'] = 'godmode/servers/discovery';
$menu_godmode['discovery']['id'] = 'god-discovery';
$menu_godmode['discovery']['sub'] = $sub;
}
@ -225,15 +225,9 @@ if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, '
if (check_acl($config['id_user'], 0, 'PM')) {
enterprise_hook('ha_cluster');
$sub['godmode/servers/manage_recontask']['text'] = __('Recon task');
$sub['godmode/servers/manage_recontask']['id'] = 'Recon task';
$sub['godmode/servers/plugin']['text'] = __('Plugins');
$sub['godmode/servers/plugin']['id'] = 'Plugins';
$sub['godmode/servers/recon_script']['text'] = __('Recon script');
$sub['godmode/servers/recon_script']['id'] = 'Recon script';
enterprise_hook('export_target_submenu');
enterprise_hook('manage_satellite_submenu');

View File

@ -450,6 +450,7 @@ switch ($action) {
case 'event_report_agent':
case 'event_report_group':
$recursion = $item['recursion'];
$include_extended_events = $item['show_extended_events'];
break;
case 'event_report_module':
@ -471,6 +472,8 @@ switch ($action) {
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
$filter_search = $style['event_filter_search'];
$include_extended_events = $item['show_extended_events'];
break;
case 'general':
@ -1729,6 +1732,15 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_extended_events" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Include extended events'); ?></td>
<td>
<?php
html_print_checkbox('include_extended_events', true, $include_extended_events);
?>
</td>
</tr>
<tr id="row_event_graphs" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Event graphs'); ?></td>
<td>
@ -3101,6 +3113,7 @@ function chooseType() {
$("#row_event_graph_by_user").hide();
$("#row_event_graph_by_criticity").hide();
$("#row_event_graph_by_validated").hide();
$("#row_extended_events").hide();
$("#row_netflow_filter").hide();
$("#row_max_values").hide();
$("#row_resolution").hide();
@ -3144,6 +3157,7 @@ function chooseType() {
$("#row_event_graph_by_user").show();
$("#row_event_graph_by_criticity").show();
$("#row_event_graph_by_validated").show();
$("#row_extended_events").show();
$("#row_filter_search").show();
$("#row_historical_db_check").hide();
@ -3444,6 +3458,7 @@ function chooseType() {
$("#row_event_graph_by_criticity").show();
$("#row_event_graph_by_validated").show();
$("#row_event_type").show();
$("#row_extended_events").show();
$("#row_filter_search").show();
$("#row_historical_db_check").hide();
@ -3459,7 +3474,8 @@ function chooseType() {
$("#row_show_summary_group").show();
$("#row_event_graphs").show();
$("#row_event_type").show();
$("#row_extended_events").show();
$("#row_extended_events").show();
$("#row_event_graph_by_user").show();
$("#row_event_graph_by_criticity").show();
@ -3482,6 +3498,7 @@ function chooseType() {
$("#row_show_summary_group").show();
$("#row_event_graphs").show();
$("#row_event_type").show();
$("#row_extended_events").show();
$("#row_event_graph_by_user").show();
$("#row_event_graph_by_criticity").show();

View File

@ -1298,6 +1298,7 @@ switch ($action) {
$values['exception_condition_value'] = get_parameter('exception_condition_value');
$values['id_module_group'] = get_parameter('combo_modulegroup');
$values['id_group'] = get_parameter('combo_group');
$values['show_extended_events'] = get_parameter('include_extended_events');
$values['server_name'] = get_parameter('server_name');
$server_id = (int) get_parameter('server_id');
if ($server_id != 0) {
@ -1689,6 +1690,7 @@ switch ($action) {
$values['exception_condition_value'] = get_parameter('exception_condition_value');
$values['id_module_group'] = get_parameter('combo_modulegroup');
$values['id_group'] = get_parameter('combo_group');
$values['show_extended_events'] = get_parameter('include_extended_events');
if ((($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) && ($values['id_gs'] == 0 || $values['id_gs'] == '')) {

View File

@ -15,9 +15,6 @@ if (! check_acl($config['id_user'], 0, 'AW')) {
ui_require_css_file('discovery');
ui_print_page_header(__('Discover'), '', false, '', true);
/**
* Mask class names.
*

View File

@ -1,11 +1,10 @@
<?php
/**
* Extension to manage a list of gateways and the node address where they should
* point to.
* Deprectated.
*
* @category Extensions
* @category Deprectated
* @package Pandora FMS
* @subpackage Community
* @subpackage Recion task script
* @version 1.0.0
* @license See below
*
@ -26,481 +25,3 @@
* GNU General Public License for more details.
* ============================================================================
*/
global $config;
check_login();
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Recon Task Management'
);
include 'general/noaccess.php';
exit;
}
require_once $config['homedir'].'/include/functions_network_profiles.php';
if (check_acl($config['id_user'], 0, 'AW')) {
$options[]['text'] = "<a href='index.php?sec=estado&sec2=operation/servers/recon_view'>".html_print_image('images/operation.png', true, ['title' => __('View')]).'</a>';
}
$user_groups_w = users_get_groups(false, 'PM', true, false, null, 'id_grupo');
$user_groups_w = array_keys($user_groups_w);
$user_groups_r = users_get_groups(false, 'AW', true, false, null, 'id_grupo');
$user_groups_r = array_keys($user_groups_r);
// Headers.
ui_print_page_header(
__('Manage recontask'),
'images/gm_servers.png',
false,
'',
true,
$options
);
// --------------------------------
// DELETE A RECON TASKs.
// --------------------------------
if (isset($_GET['delete'])) {
$id = get_parameter_get('delete');
$result = db_process_sql_delete('trecon_task', ['id_rt' => $id]);
if ($result !== false) {
ui_print_success_message(__('Successfully deleted recon task'));
} else {
ui_print_error_message(__('Error deleting recon task'));
}
} else if (isset($_GET['disabled'])) {
$id = get_parameter_get('id');
$disabled = get_parameter_get('disabled');
$result = db_process_sql_update(
'trecon_task',
['disabled' => $disabled],
['id_rt' => $id]
);
if ($result !== false) {
ui_print_success_message(__('Successfully updated recon task'));
// If the action is enabled, we force recon_task to be queued asap.
if ($disabled == 0) {
servers_force_recon_task($id);
}
} else {
ui_print_error_message(__('Error updating recon task'));
}
}
// --------------------------------
// GET PARAMETERS IF UPDATE OR CREATE.
// --------------------------------
if ((isset($_GET['update'])) || ((isset($_GET['create'])))) {
$name = get_parameter_post('name');
$network = get_parameter_post('network');
$description = get_parameter_post('description');
$id_recon_server = get_parameter_post('id_recon_server');
$interval = get_parameter_post('interval');
$id_group = get_parameter_post('id_group');
$create_incident = get_parameter_post('create_incident');
$id_network_profile = get_parameter_post('id_network_profile');
$recon_ports = get_parameter_post('recon_ports', '');
$id_os = get_parameter_post('id_os', 10);
$snmp_community = get_parameter_post('snmp_community', 'public');
$id_recon_script = get_parameter('id_recon_script', 0);
$mode = get_parameter('mode', '');
$field1 = get_parameter('_field1_', '');
$field2 = get_parameter('_field2_', '');
$field3 = get_parameter('_field3_', '');
$field4 = get_parameter('_field4_', '');
$snmp_version = get_parameter_post('snmp_version');
$snmp3_auth_user = get_parameter_post('snmp_auth_user');
$snmp3_auth_pass = get_parameter_post('snmp_auth_pass');
$snmp3_privacy_method = get_parameter_post('snmp_privacy_method');
$snmp3_privacy_pass = get_parameter_post('snmp_privacy_pass');
$snmp3_auth_method = get_parameter_post('snmp_auth_method');
$snmp3_security_level = get_parameter_post('snmp_security_level');
if ($mode == 'network_sweep') {
$id_recon_script = 0;
} else {
$id_network_profile = 0;
}
$os_detect = (int) get_parameter('os_detect', 0);
$resolve_names = (int) get_parameter('resolve_names', 0);
$parent_detection = (int) get_parameter('parent_detection', 0);
$parent_recursion = (int) get_parameter('parent_recursion', 1);
$alias_as_name = (int) get_parameter('alias_as_name', 0);
$snmp_enabled = (int) get_parameter('snmp_enabled', 0);
$vlan_enabled = (int) get_parameter('vlan_enabled', 0);
// Get macros.
$macros = (string) get_parameter('macros');
if (!empty($macros)) {
$macros = json_decode(base64_decode($macros), true);
if (isset($macros) === true && is_array($macros) === true) {
foreach ($macros as $k => $m) {
$macros[$k]['value'] = get_parameter($m['macro'], '');
}
}
}
$macros = io_json_mb_encode($macros);
}
// --------------------------------
// UPDATE A RECON TASK.
// --------------------------------
if (isset($_GET['update'])) {
$id = get_parameter_get('update');
$values = [
'snmp_community' => $snmp_community,
'id_os' => $id_os,
'name' => $name,
'subnet' => $network,
'description' => $description,
'id_recon_server' => $id_recon_server,
'create_incident' => $create_incident,
'id_group' => $id_group,
'interval_sweep' => $interval,
'id_network_profile' => $id_network_profile,
'recon_ports' => $recon_ports,
'id_recon_script' => $id_recon_script,
'field1' => $field1,
'field2' => $field2,
'field3' => $field3,
'field4' => $field4,
'os_detect' => $os_detect,
'resolve_names' => $resolve_names,
'parent_detection' => $parent_detection,
'parent_recursion' => $parent_recursion,
'macros' => $macros,
'alias_as_name' => $alias_as_name,
'snmp_enabled' => $snmp_enabled,
'vlan_enabled' => $vlan_enabled,
'snmp_version' => $snmp_version,
];
$values_v3 = [
'snmp_auth_user' => $snmp3_auth_user,
'snmp_auth_pass' => $snmp3_auth_pass,
'snmp_privacy_method' => $snmp3_privacy_method,
'snmp_privacy_pass' => $snmp3_privacy_pass,
'snmp_auth_method' => $snmp3_auth_method,
'snmp_security_level' => $snmp3_security_level,
];
if ($values['snmp_version'] == '1' || $values['snmp_version'] == '2' || $values['snmp_version'] == '2c') {
$values_v3 = [
'snmp_auth_user' => '',
'snmp_auth_pass' => '',
'snmp_privacy_method' => '',
'snmp_privacy_pass' => '',
'snmp_auth_method' => '',
'snmp_security_level' => '',
];
}
$values = array_merge($values, $values_v3);
$where = ['id_rt' => $id];
$reason = '';
if ($name != '') {
if (empty($id_recon_script)) {
if (!preg_match('/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/', $network)) {
$reason = __('Wrong format in Subnet field');
$result = false;
} else {
$result = db_process_sql_update(
'trecon_task',
$values,
$where
);
}
} else {
$result = db_process_sql_update(
'trecon_task',
$values,
$where
);
}
} else {
$result = false;
}
if ($result !== false) {
ui_print_success_message(__('Successfully updated recon task'));
} else {
ui_print_error_message(__('Error updating recon task'));
echo $reason;
include 'manage_recontask_form.php';
return;
}
}
// --------------------------------
// CREATE A RECON TASK
// --------------------------------
if (isset($_GET['create'])) {
$values = [
'name' => $name,
'subnet' => $network,
'description' => $description,
'id_recon_server' => $id_recon_server,
'create_incident' => $create_incident,
'id_group' => $id_group,
'id_network_profile' => $id_network_profile,
'interval_sweep' => $interval,
'id_os' => $id_os,
'recon_ports' => $recon_ports,
'snmp_community' => $snmp_community,
'id_recon_script' => $id_recon_script,
'field1' => $field1,
'field2' => $field2,
'field3' => $field3,
'field4' => $field4,
'os_detect' => $os_detect,
'resolve_names' => $resolve_names,
'parent_detection' => $parent_detection,
'parent_recursion' => $parent_recursion,
'macros' => $macros,
'alias_as_name' => $alias_as_name,
'snmp_enabled' => $snmp_enabled,
'vlan_enabled' => $vlan_enabled,
'snmp_version' => $snmp_version,
];
$values_v3 = [
'snmp_auth_user' => $snmp3_auth_user,
'snmp_auth_pass' => $snmp3_auth_pass,
'snmp_privacy_method' => $snmp3_privacy_method,
'snmp_privacy_pass' => $snmp3_privacy_pass,
'snmp_auth_method' => $snmp3_auth_method,
'snmp_security_level' => $snmp3_security_level,
];
if ($values['snmp_version'] == '1' || $values['snmp_version'] == '2' || $values['snmp_version'] == '2c') {
$values_v3 = [
'snmp_auth_user' => '',
'snmp_auth_pass' => '',
'snmp_privacy_method' => '',
'snmp_privacy_pass' => '',
'snmp_auth_method' => '',
'snmp_security_level' => '',
];
}
if ($values['snmp_version'] == '3') {
$values['vlan_enabled'] = 0;
}
$values = array_merge($values, $values_v3);
$name = io_safe_output($name);
$name = trim($name, ' ');
$name = io_safe_input($name);
$reason = '';
if ($name != '') {
$name_exists = (bool) db_get_value('name', 'trecon_task', 'name', $name);
if (empty($id_recon_script)) {
if ($name_exists && (!preg_match('/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/', $network))) {
$reason = __('Recon-task name already exists and incorrect format in Subnet field');
$result = false;
} else if (!preg_match('/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/', $network)) {
$reason = __('Wrong format in Subnet field');
$result = false;
} else if ($name_exists) {
$reason = __('Recon-task name already exists');
$result = false;
} else {
$result = db_process_sql_insert('trecon_task', $values);
}
} else {
if ($name_exists) {
$reason = __('Recon-task name already exists');
$result = false;
} else {
$result = db_process_sql_insert('trecon_task', $values);
}
}
} else {
$reason = 'The field "Task name" is empty';
$result = false;
}
if ($result !== false) {
ui_print_success_message(__('Successfully created recon task'));
} else {
ui_print_error_message(__('Error creating recon task'));
echo $reason;
include 'manage_recontask_form.php';
return;
}
}
// --------------------------------
// SHOW TABLE WITH ALL RECON TASKs.
// --------------------------------
// Pandora Admin must see all columns.
if (! check_acl($config['id_user'], 0, 'PM')) {
$sql = sprintf(
'SELECT *
FROM trecon_task RT, tusuario_perfil UP
WHERE
UP.id_usuario = "%s" AND UP.id_grupo = RT.id_group',
$config['id_user']
);
$result = db_get_all_rows_sql($sql);
} else {
$result = db_get_all_rows_in_table('trecon_task');
}
$color = 1;
if ($result !== false) {
$table = new StdClass();
$table->head = [
__('Name'),
__('Network'),
__('Mode'),
__('Group'),
__('SNMP Version'),
__('Incident'),
__('OS'),
__('Interval'),
__('Ports'),
__('Action'),
];
$table->align = [
'left',
'left',
'left',
'left',
'left',
'left',
'left',
'left',
];
$table->width = '100%';
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->class = 'databox data';
$table->data = [];
$table->style[8] = 'text-align: left;';
$table->size[8] = '15%';
foreach ($result as $row) {
if (in_array($row['id_group'], $user_groups_r)) {
$data = [];
$data[0] = $row['name'];
if ($row['id_recon_script'] == 0) {
$data[1] = $row['subnet'];
} else {
$data[1] = '-';
}
if ($row['id_recon_script'] == 0) {
// Network recon task.
$data[2] = html_print_image('images/network.png', true, ['title' => __('Network recon task')]).'&nbsp;&nbsp;';
$data[2] .= network_profiles_get_name($row['id_network_profile']);
$mode_name = '';
} else {
// APP recon task.
$data[2] = html_print_image('images/plugin.png', true).'&nbsp;&nbsp;';
$mode_name = db_get_sql(sprintf('SELECT name FROM trecon_script WHERE id_recon_script = %d', $row['id_recon_script']));
$data[2] .= $mode_name;
}
// GROUP.
if ($row['id_recon_script'] == 0) {
$data[3] = ui_print_group_icon($row['id_group'], true);
} else {
$data[3] = '-';
}
// SNMP VERSION.
if ($row['snmp_version'] == '1') {
$data[4] = 'v. 1';
} else if ($row['snmp_version'] == '2') {
$data[4] = 'v. 2';
} else if ($row['snmp_version'] == '2c') {
$data[4] = 'v. 2c';
} else if ($row['snmp_version'] == '3') {
$data[4] = 'v. 3';
}
// INCIDENT.
$data[5] = (($row['create_incident'] == 1) ? __('Yes') : __('No'));
// OS.
if ($row['id_recon_script'] == 0) {
$data[6] = (($row['id_os'] > 0) ? ui_print_os_icon($row['id_os'], false, true) : __('Any'));
} else {
$data[6] = '-';
}
// INTERVAL.
if ($row['interval_sweep'] == 0) {
$data[7] = __('Manual');
} else {
$data[7] = human_time_description_raw($row['interval_sweep']);
}
// PORTS.
if ($row['id_recon_script'] == 0) {
$data[8] = substr($row['recon_ports'], 0, 15);
} else {
$data[8] = '-';
}
// ACTION.
$task_group = $row['id_group'];
if (in_array($task_group, $user_groups_w)) {
$data[9] = '<a href="index.php?sec=estado&sec2=operation/servers/recon_view">'.html_print_image('images/eye.png', true).'</a>';
$data[9] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&delete='.$row['id_rt'].'">'.html_print_image('images/cross.png', true, ['border' => '0']).'</a>';
if ($mode_name != 'IPAM Recon') {
$data[9] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&update='.$row['id_rt'].'">'.html_print_image('images/config.png', true).'</a>';
} else {
$sql_ipam = 'select id from tipam_network where id_recon_task ='.$row['id_rt'];
$id_recon_ipam = db_get_sql($sql_ipam);
$data[9] .= '<a href="index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=edit&id='.$id_recon_ipam.'">'.html_print_image('images/config.png', true).'</a>';
}
if ($row['disabled'] == 0) {
$data[9] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&id='.$row['id_rt'].'&disabled=1">'.html_print_image('images/lightbulb.png', true).'</a>';
} else {
$data[9] .= '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&id='.$row['id_rt'].'&disabled=0">'.html_print_image('images/lightbulb_off.png', true).'</a>';
}
}
$table->data[] = $data;
}
}
html_print_table($table);
unset($table);
} else {
echo '<div class="nf">'.__('There are no recon task configured').'</div>';
}
echo '<div class="action-buttons" style="width: 99%;">';
echo '<form method="post" action="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&create">';
echo html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"', true);
echo '</form>';
echo '</div>';

View File

@ -1,11 +1,10 @@
<?php
/**
* Extension to manage a list of gateways and the node address where they should
* point to.
* Deprectated.
*
* @category Extensions
* @category deprecated
* @package Pandora FMS
* @subpackage Community
* @subpackage recon task
* @version 1.0.0
* @license See below
*
@ -26,910 +25,3 @@
* GNU General Public License for more details.
* ============================================================================
*/
global $config;
check_login();
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Agent Management'
);
include 'general/noaccess.php';
return;
}
require_once $config['homedir'].'/include/functions_users.php';
$user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo');
$user_groups = array_keys($user_groups);
if (is_ajax()) {
$get_explanation = (bool) get_parameter('get_explanation', 0);
if ($get_explanation) {
$id = (int) get_parameter('id', 0);
$explanation = db_get_value(
'description',
'trecon_script',
'id_recon_script',
$id
);
echo io_safe_output($explanation);
return;
}
$get_recon_script_macros = get_parameter('get_recon_script_macros');
if ($get_recon_script_macros) {
$id_recon_script = (int) get_parameter('id');
$id_recon_task = (int) get_parameter('id_rt');
if (!empty($id_recon_task) && empty($id_recon_script)) {
$recon_script_macros = db_get_value(
'macros',
'trecon_task',
'id_rt',
$id_recon_task
);
} else if (!empty($id_recon_task)) {
$recon_task_id_rs = (int) db_get_value(
'id_recon_script',
'trecon_task',
'id_rt',
$id_recon_task
);
if ($id_recon_script == $recon_task_id_rs) {
$recon_script_macros = db_get_value(
'macros',
'trecon_task',
'id_rt',
$id_recon_task
);
} else {
$recon_script_macros = db_get_value(
'macros',
'trecon_script',
'id_recon_script',
$id_recon_script
);
}
} else if (!empty($id_recon_script)) {
$recon_script_macros = db_get_value(
'macros',
'trecon_script',
'id_recon_script',
$id_recon_script
);
} else {
$recon_script_macros = [];
}
$macros = [];
$macros['base64'] = base64_encode($recon_script_macros);
$macros['array'] = json_decode($recon_script_macros, true);
echo io_json_mb_encode($macros);
return;
}
return;
}
// Edit mode.
if (isset($_GET['update']) || (isset($_GET['upd']))) {
$update_recon = true;
if (isset($_GET['upd'])) {
if ($_GET['upd'] != 'update') {
$update_recon = false;
} else {
$id_rt = get_parameter('upd');
}
}
if ($update_recon) {
if (!isset($id_rt)) {
$id_rt = (int) get_parameter_get('update');
}
$row = db_get_row('trecon_task', 'id_rt', $id_rt);
$name = $row['name'];
$network = $row['subnet'];
$id_recon_server = $row['id_recon_server'];
$description = $row['description'];
$interval = $row['interval_sweep'];
$id_group = $row['id_group'];
$create_incident = $row['create_incident'];
$id_network_profile = $row['id_network_profile'];
$id_os = $row['id_os'];
$recon_ports = $row['recon_ports'];
$snmp_community = $row['snmp_community'];
$snmp_version = $row['snmp_version'];
$snmp3_auth_user = $row['snmp_auth_user'];
$snmp3_auth_pass = $row['snmp_auth_pass'];
$snmp3_privacy_method = $row['snmp_privacy_method'];
$snmp3_privacy_pass = $row['snmp_privacy_pass'];
$snmp3_auth_method = $row['snmp_auth_method'];
$snmp3_security_level = $row['snmp_security_level'];
$id_recon_script = $row['id_recon_script'];
$field1 = $row['field1'];
$field2 = $row['field2'];
$field3 = $row['field3'];
$field4 = $row['field4'];
if ($id_recon_script == 0) {
$mode = 'network_sweep';
} else {
$mode = 'recon_script';
}
$os_detect = $row['os_detect'];
$resolve_names = $row['resolve_names'];
$os_detect = $row['os_detect'];
$parent_detection = $row['parent_detection'];
$parent_recursion = $row['parent_recursion'];
$macros = $row['macros'];
$alias_as_name = $row['alias_as_name'];
$snmp_enabled = $row['snmp_enabled'];
$vlan_enabled = $row['vlan_enabled'];
$name_script = db_get_value(
'name',
'trecon_script',
'id_recon_script',
$id_recon_script
);
if (! in_array($id_group, $user_groups)) {
db_pandora_audit(
'ACL Violation',
'Trying to access Recon Task Management'
);
include 'general/noaccess.php';
return;
}
}
} else if (isset($_GET['create']) || isset($_GET['crt'])) {
$create_recon = true;
if (isset($_GET['crt'])) {
if ($_GET['crt'] != 'Create') {
$create_recon = false;
}
}
if ($create_recon) {
$id_rt = -1;
$name = get_parameter('name');
$network = get_parameter('network');
$description = get_parameter('description');
$id_recon_server = 0;
$interval = 0;
$id_group = 0;
$create_incident = 1;
$snmp_community = 'public';
$snmp3_auth_user = '';
$snmp3_auth_pass = '';
$snmp_version = 1;
$snmp3_privacy_method = '';
$snmp3_privacy_pass = '';
$snmp3_auth_method = '';
$snmp3_security_level = '';
$id_network_profile = 0;
$id_os = -1;
$recon_ports = '';
$field1 = '';
$field2 = '';
$field3 = '';
$field4 = '';
$id_recon_script = 0;
$mode = 'network_sweep';
$os_detect = 0;
$resolve_names = 0;
$parent_detection = 1;
$parent_recursion = 5;
$macros = '';
$alias_as_name = 0;
$snmp_enabled = 0;
$vlan_enabled = 0;
}
$modify = false;
if (($name != '') || ($network != '')) {
$modify = true;
}
}
if (!$modify) {
// Headers.
ui_print_page_header(__('Manage recontask'), '', false, 'recontask', true);
}
$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
if ($is_windows) {
echo '<div class="notify">';
echo __('Warning').': '.__('By default, in Windows, %s only support Standard network sweep, not custom scripts', get_product_name());
echo '</div>';
}
$table = new stdClass();
$table->id = 'table_recon';
$table->width = '100%';
$table->cellspacing = 4;
$table->cellpadding = 4;
$table->class = 'databox filters';
$table->rowclass[3] = 'network_sweep';
$table->rowclass[5] = 'network_sweep';
$table->rowclass[7] = 'network_sweep';
$table->rowclass[8] = 'network_sweep';
$table->rowclass[11] = 'network_sweep';
$table->rowclass[12] = 'network_sweep';
$table->rowclass[18] = 'network_sweep';
$table->rowclass[19] = 'network_sweep';
$table->rowclass[20] = 'network_sweep';
$table->rowclass[21] = 'network_sweep';
$table->rowclass[22] = 'network_sweep';
$table->rowclass[23] = 'network_sweep';
$table->rowclass[24] = 'network_sweep';
$table->rowclass[25] = 'network_sweep recon_v3';
$table->rowclass[26] = 'network_sweep recon_v3';
$table->rowclass[27] = 'network_sweep recon_v3';
$table->rowclass[28] = 'network_sweep recon_v3';
$table->rowclass[29] = 'network_sweep recon_v3';
$table->rowclass[30] = 'network_sweep recon_v3';
$table->rowclass[6] = 'recon_script';
$table->rowclass[13] = 'recon_script';
$table->rowclass[14] = 'recon_script';
$table->rowclass[15] = 'recon_script';
$table->rowclass[16] = 'recon_script';
$table->rowclass[17] = 'recon_script';
// Name.
$table->data[0][0] = '<b>'.__('Task name').'</b>';
$table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true);
// Discovery server.
$table->data[1][0] = '<b>'.__('Discovery server').ui_print_help_tip(
__('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'),
true
);
$sql = 'SELECT id_server, name
FROM tserver
WHERE server_type = 3
ORDER BY name';
$table->data[1][1] = html_print_select_from_sql(
$sql,
'id_recon_server',
$id_recon_server,
'',
'',
'',
true
);
$fields['network_sweep'] = __('Network sweep');
if (!$is_windows) {
$fields['recon_script'] = __('Custom script');
}
$table->data[2][0] = '<b>'.__('Mode').'</b>';
$table->data[2][1] = html_print_select(
$fields,
'mode',
$mode,
'',
'',
0,
true
);
// Network.
$table->data[3][0] = '<b>'.__('Network').'</b>';
$table->data[3][0] .= ui_print_help_tip(
__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'),
true
);
$table->data[3][1] = html_print_input_text(
'network',
$network,
'',
25,
0,
true
);
// Interval.
$interv_manual = 0;
if ((int) $interval == 0) {
$interv_manual = 1;
}
$table->data[4][0] = '<b>'.__('Interval');
$table->data[4][0] .= ui_print_help_tip(
__('Manual interval means that it will be executed only On-demand'),
true
);
$values = [
0 => __('Defined'),
1 => __('Manual'),
];
$table->data[4][1] = html_print_select(
$values,
'interval_manual_defined',
$interv_manual,
'',
'',
'',
true
);
$table->data[4][1] .= '<span id="interval_manual_container">';
$table->data[4][1] .= html_print_extended_select_for_time(
'interval',
$interval,
'',
'',
'0',
false,
true,
false,
false
);
$table->data[4][1] .= ui_print_help_tip(
__('The minimum recomended interval for Recon Task is 5 minutes'),
true
);
$table->data[4][1] .= '</span>';
// Module template.
$table->data[5][0] = '<b>'.__('Module template').'</b>';
$sql = 'SELECT id_np, name
FROM tnetwork_profile
ORDER BY name';
$table->data[5][1] = html_print_select_from_sql(
$sql,
'id_network_profile',
$id_network_profile,
'',
__('None'),
0,
true
);
// Recon script.
$data[1] = '';
$table->data[6][0] = '<b>'.__('Recon script').'</b>';
$sql = "SELECT id_recon_script, name
FROM trecon_script
WHERE name <> 'IPAM Recon'
ORDER BY name";
if ($name_script != 'IPAM Recon') {
$table->data[6][1] = html_print_select_from_sql(
$sql,
'id_recon_script',
$id_recon_script,
'',
'',
'',
true
);
$table->data[6][1] .= "<span id='spinner_recon_script' style='display: none;'>".html_print_image('images/spinner.gif', true).'</span>';
$table->data[6][1] .= $data[1] .= html_print_input_hidden(
'macros',
base64_encode($macros),
true
);
} else {
$table->data[6][1] = 'IPAM Recon';
}
// OS.
$table->data[7][0] = '<b>'.__('OS').'</b>';
$sql = 'SELECT id_os, name
FROM tconfig_os
ORDER BY name';
$table->data[7][1] = html_print_select_from_sql(
$sql,
'id_os',
$id_os,
'',
__('Any'),
-1,
true
);
// Recon ports.
$table->data[8][0] = '<b>'.__('Ports').'</b>';
$table->data[8][1] = html_print_input_text(
'recon_ports',
$recon_ports,
'',
25,
0,
true
);
$table->data[8][1] .= ui_print_help_tip(
__('Ports defined like: 80 or 80,443,512 or even 0-1024 (Like Nmap command line format). If dont want to do a sweep using portscan, left it in blank'),
true
);
// Group.
$table->data[9][0] = '<b>'.__('Group');
$groups = users_get_groups(false, 'PM', false);
$table->data[9][1] = html_print_select_groups(
false,
'PM',
false,
'id_group',
$id_group,
'',
'',
0,
true
);
// Incident.
$values = [
0 => __('No'),
1 => __('Yes'),
];
$table->data[10][0] = '<b>'.__('Incident');
$table->data[10][1] = html_print_select(
$values,
'create_incident',
$create_incident,
'',
'',
'',
true
).' '.ui_print_help_tip(
__('Choose if the discovery of a new system creates an incident or not.'),
true
);
// Snmp_enabled.
$table->data[11][0] = '<b>'.__('SNMP enabled');
$table->data[11][1] = html_print_checkbox(
'snmp_enabled',
1,
$snmp_enabled,
true
);
// SNMP default community.
$table->data[12][0] = '<b>'.__('SNMP Default community');
$table->data[12][0] .= ui_print_help_tip(
__('You can specify several values, separated by commas, for example: public,mysecret,1234'),
true
);
$table->data[12][1] = html_print_input_text(
'snmp_community',
$snmp_community,
'',
35,
0,
true
);
// SNMP version.
$snmp_versions['1'] = 'v. 1';
$snmp_versions['2'] = 'v. 2';
$snmp_versions['2c'] = 'v. 2c';
$snmp_versions['3'] = 'v. 3';
$table->data[24][0] = '<b>'._('SNMP version');
$table->data[24][1] = html_print_select(
$snmp_versions,
'snmp_version',
$snmp_version,
'',
'',
0,
true
);
$table->data[25][0] = '<b>'.__('Auth user');
$table->data[25][1] = html_print_input_text(
'snmp_auth_user',
$snmp3_auth_user,
'',
15,
60,
true,
'',
false,
'',
''
);
$table->data[26][0] = '<b>'.__('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true);
$table->data[26][1] = html_print_input_password(
'snmp_auth_pass',
$snmp3_auth_pass,
'',
15,
60,
true,
'',
false,
''
);
$table->data[26][1] .= html_print_input_hidden_extended(
'active_snmp_v3',
0,
'active_snmp_v3_mmen',
true
);
$table->data[27][0] = '<b>'.__('Privacy method');
$table->data[27][1] = html_print_select(
[
'DES' => __('DES'),
'AES' => __('AES'),
],
'snmp_privacy_method',
$snmp3_privacy_method,
'',
'',
'',
true,
false,
false,
'',
''
);
$table->data[28][0] = '<b>'.__('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true);
$table->data[28][1] = html_print_input_password(
'snmp_privacy_pass',
$snmp3_privacy_pass,
'',
15,
60,
true,
'',
false,
''
);
$table->data[29][0] = '<b>'.__('Auth method');
$table->data[29][1] = html_print_select(
[
'MD5' => __('MD5'),
'SHA' => __('SHA'),
],
'snmp_auth_method',
$snmp3_auth_method,
'',
'',
'',
true,
false,
false,
'',
''
);
$table->data[30][0] = '<b>'.__('Security level');
$table->data[30][1] = html_print_select(
[
'noAuthNoPriv' => __('Not auth and not privacy method'),
'authNoPriv' => __('Auth and not privacy method'),
'authPriv' => __('Auth and privacy method'),
],
'snmp_security_level',
$snmp3_security_level,
'',
'',
'',
true,
false,
false,
'',
''
);
// Explanation.
$explanation = db_get_value(
'description',
'trecon_script',
'id_recon_script',
$id_recon_script
);
$table->data[13][0] = '<b>'.__('Explanation').'</b>';
$table->data[13][1] = "<span id='spinner_layout' style='display: none;'>".html_print_image('images/spinner.gif', true).'</span>'.html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true);
// A hidden "model row" to clone it from javascript to add fields dynamicaly.
$data = [];
$data[0] = 'macro_desc';
$data[0] .= ui_print_help_tip('macro_help', true);
$data[1] = html_print_input_text(
'macro_name',
'macro_value',
'',
100,
255,
true
);
$table->colspan['macro_field'][1] = 3;
$table->rowstyle['macro_field'] = 'display:none';
$table->data['macro_field'] = $data;
// If there are $macros, we create the form fields.
if (!empty($macros)) {
$macros = json_decode($macros, true);
if (isset($macros) === true
&& is_array($macros) === true
) {
foreach ($macros as $k => $m) {
$data = [];
$data[0] = '<b>'.$m['desc'].'</b>';
if (!empty($m['help'])) {
$data[0] .= ui_print_help_tip($m['help'], true);
}
if ($m['hide']) {
$data[1] = html_print_input_password(
$m['macro'],
$m['value'],
'',
100,
255,
true
);
} else {
$data[1] = html_print_input_text(
$m['macro'],
$m['value'],
'',
100,
255,
true
);
}
$table->colspan['macro'.$m['macro']][1] = 3;
$table->rowclass['macro'.$m['macro']] = 'macro_field';
$table->data['macro'.$m['macro']] = $data;
}
}
}
// Comments.
$table->data[18][0] = '<b>'.__('Comments');
$table->data[18][1] = html_print_input_text(
'description',
$description,
'',
45,
0,
true
);
// OS detection.
$table->data[19][0] = '<b>'.__('OS detection');
$table->data[19][1] = html_print_checkbox(
'os_detect',
1,
$os_detect,
true
);
// Name resolution.
$table->data[20][0] = '<b>'.__('Name resolution');
$table->data[20][1] = html_print_checkbox(
'resolve_names',
1,
$resolve_names,
true
);
// Parent detection.
$table->data[21][0] = '<b>'.__('Parent detection');
$table->data[21][1] = html_print_checkbox(
'parent_detection',
1,
$parent_detection,
true
);
// Parent recursion.
$table->data[22][0] = '<b>'.__('Parent recursion');
$table->data[22][1] = html_print_input_text(
'parent_recursion',
$parent_recursion,
'',
5,
0,
true
).ui_print_help_tip(
__('Maximum number of parent hosts that will be created if parent detection is enabled.'),
true
);
// Vlan_enabled.
$table->data[23][0] = '<b>'.__('Vlan enabled');
$table->data[23][1] = html_print_checkbox(
'vlan_enabled',
1,
$vlan_enabled,
true
);
// NOTE: The 7.0NG Recon Server will not generate random names, since IP
// address collisions could have other consequences.
// Different Form url if it's a create or if it's a update form.
echo '<form name="modulo" method="post" action="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&'.(($id_rt != -1) ? 'update='.$id_rt : 'create=1').'">';
html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id_rt != -1) {
if ($name_script != 'IPAM Recon') {
html_print_submit_button(__('Update'), 'crt', false, 'class="sub upd"');
}
} else {
html_print_submit_button(__('Add'), 'crt', false, 'class="sub wand"');
}
echo '</div>';
echo '</form>';
ui_require_javascript_file('pandora_modules');
?>
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready (function () {
});
var xhrManager = function () {
var manager = {};
manager.tasks = [];
manager.addTask = function (xhr) {
manager.tasks.push(xhr);
}
manager.stopTasks = function () {
while (manager.tasks.length > 0)
manager.tasks.pop().abort();
}
return manager;
};
var taskManager = new xhrManager();
$('select#interval_manual_defined').change(function() {
if ($("#interval_manual_defined").val() == 1) {
$('#interval_manual_container').hide();
$('#text-interval_text').val(0);
$('#hidden-interval').val(0);
}
else {
$('#interval_manual_container').show();
$('#text-interval_text').val(10);
$('#hidden-interval').val(600);
$('#interval_units').val(60);
}
}).change();
$('select#id_recon_script').change(function() {
if ($('select#mode').val() == 'recon_script')
get_explanation_recon_script($(this).val());
});
$('select#snmp_version').change(function () {
if (this.value == "3") {
$(".recon_v3").show();
$("input[name=active_snmp_v3]").val(1);
$("input[name=snmp_community]").attr("disabled", true);
$("input[name=vlan_enabled]").removeAttr("checked");
$("input[name=vlan_enabled]").attr("disabled", true);
}
else {
$(".recon_v3").hide();
$("input[name=active_snmp_v3]").val(0);
$("input[name=snmp_community]").removeAttr('disabled');
$("input[name=vlan_enabled]").removeAttr('disabled');
}
});
$('select#mode').change(function() {
var type = $(this).val();
if (type == 'recon_script') {
$(".recon_script").show();
$(".network_sweep").hide();
get_explanation_recon_script($("#id_recon_script").val());
}
else if (type == 'network_sweep') {
$(".recon_script").hide();
$(".network_sweep").show();
$('.macro_field').remove();
$('select#snmp_version').trigger('change');
}
}).change();
function get_explanation_recon_script (id) {
// Stop old ajax tasks.
taskManager.stopTasks();
// Show the spinners.
$("#textarea_explanation").hide();
$("#spinner_layout").show();
var xhr = jQuery.ajax ({
data: {
'page': 'godmode/servers/manage_recontask_form',
'get_explanation': 1,
'id': id,
'id_rt': <?php echo json_encode((int) $id_rt); ?>
},
url: "<?php echo $config['homeurl']; ?>ajax.php",
type: 'POST',
dataType: 'text',
complete: function (xhr, textStatus) {
$("#spinner_layout").hide();
},
success: function (data, textStatus, xhr) {
$("#textarea_explanation").val(data);
$("#textarea_explanation").show();
},
error: function (xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
taskManager.addTask(xhr);
// Delete all the macro fields.
$('.macro_field').remove();
$("#spinner_recon_script").show();
var xhr = jQuery.ajax ({
data: {
'page': 'godmode/servers/manage_recontask_form',
'get_recon_script_macros': 1,
'id': id,
'id_rt': <?php echo json_encode((int) $id_rt); ?>
},
url: "<?php echo $config['homeurl']; ?>ajax.php",
type: 'POST',
dataType: 'json',
complete: function (xhr, textStatus) {
$("#spinner_recon_script").hide();
forced_title_callback();
},
success: function (data, textStatus, xhr) {
if (data.array !== null) {
$('#hidden-macros').val(data.base64);
jQuery.each (data.array, function (i, macro) {
if (macro.desc != '') {
add_macro_field(macro, 'table_recon-macro');
}
});
}
},
error: function (xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
taskManager.addTask(xhr);
}
</script>

View File

@ -1,401 +1,27 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// 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.
if (is_ajax()) {
$get_reconscript_description = get_parameter('get_reconscript_description');
$id_reconscript = get_parameter('id_reconscript');
$description = db_get_value_filter(
'description',
'trecon_script',
['id_recon_script' => $id_reconscript]
);
echo htmlentities(io_safe_output($description), ENT_QUOTES, 'UTF-8', true);
return;
}
// Load global vars
global $config;
check_login();
if (! check_acl($config['id_user'], 0, 'LM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access recon script Management'
);
include 'general/noaccess.php';
return;
}
/*
* Disabled at the moment.
if (!check_referer()) {
require ("general/noaccess.php");
return;
}
/**
* Deprectated.
*
* @category Deprectated
* @package Pandora FMS
* @subpackage recon script
* @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.
* ============================================================================
*/
$view = get_parameter('view', '');
$create = get_parameter('create', '');
if ($view != '') {
$form_id = $view;
$reconscript = db_get_row('trecon_script', 'id_recon_script', $form_id);
$form_name = $reconscript['name'];
$form_description = $reconscript['description'];
$form_script = $reconscript['script'];
$macros = $reconscript['macros'];
}
if ($create != '') {
$form_name = '';
$form_description = '';
$form_script = '';
$macros = '';
}
// SHOW THE FORM
// =================================================================
if (($create != '') or ($view != '')) {
if ($create != '') {
ui_print_page_header(__('Recon script creation'), 'images/gm_servers.png', false, 'reconscript_definition', true);
} else {
ui_print_page_header(__('Recon script update'), 'images/gm_servers.png', false, 'reconscript_definition', true);
$id_recon_script = get_parameter('view', '');
}
if ($create == '') {
echo "<form name=reconscript method='post' action='index.php?sec=gservers&sec2=godmode/servers/recon_script&update_reconscript=$id_recon_script'>";
} else {
echo "<form name=reconscript method='post' action='index.php?sec=gservers&sec2=godmode/servers/recon_script&create_reconscript=1'>";
}
$table = new stdClass();
$table->width = '100%';
$table->id = 'table-form';
$table->class = 'databox filters';
$table->style = [];
$table->style[0] = 'font-weight: bold';
$table->style[2] = 'font-weight: bold';
$table->data = [];
$data = [];
$data[0] = __('Name');
$data[1] = '<input type="text" name="form_name" size=30 value="'.$form_name.'">';
$table->data['recon_name'] = $data;
$table->colspan['recon_name'][1] = 3;
$data = [];
$data[0] = __('Script fullpath');
$data[1] = '<input type="text" name="form_script" size=70 value="'.$form_script.'">';
$table->data['recon_fullpath'] = $data;
$table->colspan['recon_fullpath'][1] = 3;
$data = [];
$data[0] = __('Description');
$data[1] = '<textarea name="form_description" cols="50" rows="4">';
$data[1] .= $form_description;
$data[1] .= '</textarea>';
$table->data['recon_description'] = $data;
$table->colspan['recon_description'][1] = 3;
$macros = json_decode($macros, true);
// This code is ready to add locked feature as plugins
$locked = false;
// The next row number is recon_3
$next_name_number = 3;
$i = 1;
while (1) {
// Always print at least one macro
if ((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) {
break;
}
$macro_desc_name = 'field'.$i.'_desc';
$macro_desc_value = '';
$macro_help_name = 'field'.$i.'_help';
$macro_help_value = '';
$macro_value_name = 'field'.$i.'_value';
$macro_value_value = '';
$macro_name_name = 'field'.$i.'_macro';
$macro_name = '_field'.$i.'_';
$macro_hide_value_name = 'field'.$i.'_hide';
$macro_hide_value_value = 0;
if (isset($macros[$i]['desc'])) {
$macro_desc_value = $macros[$i]['desc'];
}
if (isset($macros[$i]['help'])) {
$macro_help_value = $macros[$i]['help'];
}
if (isset($macros[$i]['value'])) {
$macro_value_value = $macros[$i]['value'];
}
if (isset($macros[$i]['hide'])) {
$macro_hide_value_value = $macros[$i]['hide'];
}
$datam = [];
$datam[0] = __('Description')."<span style='font-weight: normal'> ($macro_name)</span>";
$datam[0] .= html_print_input_hidden($macro_name_name, $macro_name, true);
$datam[1] = html_print_input_text_extended($macro_desc_name, $macro_desc_value, 'text-'.$macro_desc_name, '', 30, 255, $locked, '', "class='command_advanced_conf'", true);
if ($locked) {
$datam[1] .= html_print_image('images/lock.png', true, ['class' => 'command_advanced_conf']);
}
$datam[2] = __('Default value')."<span style='font-weight: normal'> ($macro_name)</span>";
$datam[3] = html_print_input_text_extended($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, $locked, '', "class='command_component command_advanced_conf'", true);
if ($locked) {
$datam[3] .= html_print_image('images/lock.png', true, ['class' => 'command_advanced_conf']);
}
$table->data['recon_'.$next_name_number] = $datam;
$next_name_number++;
$table->colspan['recon_'.$next_name_number][1] = 3;
$datam = [];
$datam[0] = __('Hide value').ui_print_help_tip(__('This field will show up as dots like a password'), true);
$datam[1] = html_print_checkbox_extended($macro_hide_value_name, 1, $macro_hide_value_value, 0, '', ['class' => 'command_advanced_conf'], true, 'checkbox-'.$macro_hide_value_name);
$table->data['recon_'.$next_name_number] = $datam;
$next_name_number++;
$table->colspan['recon_'.$next_name_number][1] = 3;
$datam = [];
$datam[0] = __('Help')."<span style='font-weight: normal'> ($macro_name)</span><br><br><br>";
$tadisabled = $locked === true ? ' disabled' : '';
$datam[1] = html_print_textarea($macro_help_name, 6, 100, $macro_help_value, 'class="command_advanced_conf" style="width: 97%;"'.$tadisabled, true);
if ($locked) {
$datam[1] .= html_print_image('images/lock.png', true, ['class' => 'command_advanced_conf']);
}
$datam[1] .= '<br><br><br>';
$table->data['recon_'.$next_name_number] = $datam;
$next_name_number++;
$i++;
}
if (!$locked) {
$datam = [];
$datam[0] = '<span style="font-weight: bold">'.__('Add macro').'</span> <a href="javascript:new_macro(\'table-form-recon_\');update_preview();">'.html_print_image('images/add.png', true).'</a>';
$datam[0] .= '<div id="next_macro" style="display:none">'.$i.'</div>';
$datam[0] .= '<div id="next_row" style="display:none">'.$next_name_number.'</div>';
$delete_macro_style = '';
if ($i <= 2) {
$delete_macro_style = 'display:none;';
}
$datam[2] = '<div id="delete_macro_button" style="'.$delete_macro_style.'">'.__('Delete macro').' <a href="javascript:delete_macro_form(\'table-form-recon_\');update_preview();">'.html_print_image('images/delete.png', true).'</a></div>';
$table->colspan['recon_action'][0] = 2;
$table->rowstyle['recon_action'] = 'text-align:center';
$table->colspan['recon_action'][2] = 2;
$table->data['recon_action'] = $datam;
}
html_print_table($table);
echo '<table width=100%>';
echo '<tr><td align="right">';
if ($create != '') {
echo "<input name='crtbutton' type='submit' class='sub wand' value='".__('Create')."'>";
} else {
echo "<input name='uptbutton' type='submit' class='sub upd' value='".__('Update')."'>";
}
echo '</form></table>';
} else {
ui_print_page_header(__('Recon scripts registered on %s', get_product_name()), 'images/gm_servers.png', false, '', true);
// Update reconscript
if (isset($_GET['update_reconscript'])) {
// if modified any parameter
$id_recon_script = get_parameter('update_reconscript', 0);
$reconscript_name = get_parameter('form_name', '');
$reconscript_description = get_parameter('form_description', '');
$reconscript_script = get_parameter('form_script', '');
// Get macros
$i = 1;
$macros = [];
while (1) {
$macro = (string) get_parameter('field'.$i.'_macro');
if ($macro == '') {
break;
}
$desc = (string) get_parameter('field'.$i.'_desc');
$help = (string) get_parameter('field'.$i.'_help');
$value = (string) get_parameter('field'.$i.'_value');
$hide = get_parameter('field'.$i.'_hide');
$macros[$i]['macro'] = $macro;
$macros[$i]['desc'] = $desc;
$macros[$i]['help'] = $help;
$macros[$i]['value'] = $value;
$macros[$i]['hide'] = $hide;
$i++;
}
$macros = io_json_mb_encode($macros);
$sql_update = "UPDATE trecon_script SET
name = '$reconscript_name',
description = '$reconscript_description',
script = '$reconscript_script',
macros = '$macros'
WHERE id_recon_script = $id_recon_script";
$result = false;
if ($reconscript_name != '' && $reconscript_script != '') {
$result = db_process_sql($sql_update);
}
if (! $result) {
ui_print_error_message(__('Problem updating'));
} else {
ui_print_success_message(__('Updated successfully'));
}
}
// Create reconscript
if (isset($_GET['create_reconscript'])) {
$reconscript_name = get_parameter('form_name', '');
$reconscript_description = get_parameter('form_description', '');
$reconscript_script = get_parameter('form_script', '');
// Get macros
$i = 1;
$macros = [];
while (1) {
$macro = (string) get_parameter('field'.$i.'_macro');
if ($macro == '') {
break;
}
$desc = (string) get_parameter('field'.$i.'_desc');
$help = (string) get_parameter('field'.$i.'_help');
$value = (string) get_parameter('field'.$i.'_value');
$hide = get_parameter('field'.$i.'_hide');
$macros[$i]['macro'] = $macro;
$macros[$i]['desc'] = $desc;
$macros[$i]['help'] = $help;
$macros[$i]['value'] = $value;
$macros[$i]['hide'] = $hide;
$i++;
}
$macros = io_json_mb_encode($macros);
$values = [
'name' => $reconscript_name,
'description' => $reconscript_description,
'script' => $reconscript_script,
'macros' => $macros,
];
$result = false;
if ($values['name'] != '' && $values['script'] != '') {
$result = db_process_sql_insert('trecon_script', $values);
}
if (! $result) {
ui_print_error_message(__('Problem creating'));
} else {
ui_print_success_message(__('Created successfully'));
}
}
if (isset($_GET['kill_reconscript'])) {
// if delete alert
$reconscript_id = get_parameter('kill_reconscript', 0);
$result = db_process_sql_delete(
'trecon_script',
['id_recon_script' => $reconscript_id]
);
if (! $result) {
ui_print_error_message(__('Problem deleting reconscript'));
} else {
ui_print_success_message(__('reconscript deleted successfully'));
}
if ($reconscript_id != 0) {
$result = db_process_sql_delete(
'trecon_task',
['id_recon_script' => $reconscript_id]
);
}
}
// If not edition or insert, then list available reconscripts
$rows = db_get_all_rows_in_table('trecon_script');
if ($rows !== false) {
echo '<table width="100%" cellspacing="4" cellpadding="4" class="databox data">';
echo '<th>'.__('Name').'</th>';
echo '<th>'.__('Description').'</th>';
echo '<th>'.__('Delete').'</th>';
$color = 0;
foreach ($rows as $row) {
if ($color == 1) {
$tdcolor = 'datos';
$color = 0;
} else {
$tdcolor = 'datos2';
$color = 1;
}
echo '<tr>';
echo "<td class='$tdcolor' style='min-width: 100px;'>";
echo "<b><a href='index.php?sec=gservers&sec2=godmode/servers/recon_script&view=".$row['id_recon_script']."'>";
echo $row['name'];
echo '</a></b></td>';
echo "</td><td class='$tdcolor'>";
$desc = io_safe_output($row['description']);
$desc = str_replace("\n", '<br>', $desc);
echo $desc.'<br><br>';
echo '<b>'.__('Command').': </b><i>'.$row['script'].'</i>';
echo "</td><td align='center' class='$tdcolor'>";
echo "<a href='index.php?sec=gservers&sec2=godmode/servers/recon_script&kill_reconscript=".$row['id_recon_script']."'>".html_print_image('images/cross.png', true, ['border' => '0']).'</a>';
echo '</td></tr>';
}
echo '</table>';
} else {
ui_print_info_message(['no_close' => true, 'message' => __('There are no recon scripts in the system') ]);
}
echo '<table width=100%>';
echo '<tr><td align=right>';
echo "<form name=reconscript method='post' action='index.php?sec=gservers&sec2=godmode/servers/recon_script&create=1'>";
echo "<input name='crtbutton' type='submit' class='sub next' value='".__('Add')."'>";
echo '</td></tr></table>';
}
ui_require_javascript_file('pandora_modules');

View File

@ -30,7 +30,10 @@ require_once __DIR__.'/Wizard.main.php';
require_once $config['homedir'].'/include/functions_users.php';
require_once $config['homedir'].'/include/functions_reports.php';
require_once $config['homedir'].'/include/functions_cron.php';
enterprise_include('include/functions_tasklist.php');
enterprise_include_once('include/functions_tasklist.php');
enterprise_include_once('include/functions_cron.php');
ui_require_css_file('task_list');
/**
* Defined as wizard to guide user to explore running tasks.
@ -93,7 +96,8 @@ class DiscoveryTaskList extends Wizard
]
);
$this->printHeader();
// Header
ui_print_page_header(__('Task list'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
// Show redirected messages from discovery.php.
if ($status === 0) {
@ -237,7 +241,7 @@ class DiscoveryTaskList extends Wizard
$id_console_task = (int) get_parameter('id_console_task');
if ($id_console_task !== null) {
enterprise_include('cron_task_run', $id_console_task, true);
enterprise_hook('cron_task_run', [$id_console_task, true]);
// Trick to avoid double execution.
header('Location: '.$this->url);
}
@ -345,6 +349,8 @@ class DiscoveryTaskList extends Wizard
$recon_tasks = [];
}
$url_ajax = $config['homeurl'].'ajax.php';
$table = new StdClass();
$table->cellpadding = 4;
$table->cellspacing = 4;
@ -424,7 +430,16 @@ class DiscoveryTaskList extends Wizard
$data[0] = '';
}
$data[1] = '<b>'.$task['name'].'</b>';
// Name task.
$data[1] = '';
if ($task['disabled'] != 2) {
$data[1] .= '<a href="#" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\')">';
}
$data[1] .= '<b>'.$task['name'].'</b>';
if ($task['disabled'] != 2) {
$data[1] .= '</a>';
}
$data[2] = $server_name;
@ -488,6 +503,24 @@ class DiscoveryTaskList extends Wizard
$data[8] = __('Not executed yet');
}
if ($task['disabled'] != 2) {
$data[9] = '<a href="#" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\')">';
$data[9] .= html_print_image(
'images/eye.png',
true
);
$data[9] .= '</a>';
}
if ($task['disabled'] != 2 && $task['utimestamp'] > 0) {
$data[9] .= '<a href="#" onclick="show_map('.$task['id_rt'].',\''.$task['name'].'\')">';
$data[9] .= html_print_image(
'images/dynamic_network_icon.png',
true
);
$data[9] .= '</a>';
}
if (check_acl(
$config['id_user'],
$task['id_group'],
@ -495,7 +528,7 @@ class DiscoveryTaskList extends Wizard
)
) {
if ($ipam === true) {
$data[9] = '<a href="'.ui_get_full_url(
$data[9] .= '<a href="'.ui_get_full_url(
sprintf(
'index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=edit&id=%d',
$tipam_task_id
@ -512,7 +545,7 @@ class DiscoveryTaskList extends Wizard
).'</a>';
} else {
// Check if is a H&D, Cloud or Application or IPAM.
$data[9] = '<a href="'.ui_get_full_url(
$data[9] .= '<a href="'.ui_get_full_url(
sprintf(
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&task=%d',
$this->getTargetWiz($task),
@ -533,6 +566,9 @@ class DiscoveryTaskList extends Wizard
$data[9] = '';
}
// Div neccesary for modal progress task.
echo '<div id="progress_task_'.$task['id_rt'].'" style="display:none"></div>';
array_push($table->data, $data);
}
@ -544,7 +580,12 @@ class DiscoveryTaskList extends Wizard
html_print_table($table);
}
// Div neccesary for modal map task.
echo '<div id="map_task" style="display:none"></div>';
unset($table);
ui_require_javascript_file('pandora_taskList');
}
return true;
@ -583,7 +624,12 @@ class DiscoveryTaskList extends Wizard
return 'wiz=ctask';
default:
if ($task['id_recon_script'] === null) {
return 'wiz=hd&mode=netscan';
} else {
return 'wiz=hd&mode=customnetscan';
}
break;
}
}

View File

@ -28,7 +28,10 @@
require_once __DIR__.'/Wizard.main.php';
require_once $config['homedir'].'/include/functions_users.php';
enterprise_include('include/class/CSVImportAgents.class.php');
require_once $config['homedir'].'/include/class/CustomNetScan.class.php';
require_once $config['homedir'].'/include/class/ManageNetScanScripts.class.php';
enterprise_include_once('include/class/CSVImportAgents.class.php');
enterprise_include_once('include/functions_hostdevices.php');
/**
@ -117,6 +120,7 @@ class HostDevices extends Wizard
'icon' => 'images/wizard/netscan.png',
'label' => __('Net Scan'),
];
if (enterprise_installed()) {
$buttons[] = [
'url' => $this->url.'&mode=importcsv',
@ -125,6 +129,18 @@ class HostDevices extends Wizard
];
}
$buttons[] = [
'url' => $this->url.'&mode=customnetscan',
'icon' => '/images/wizard/customnetscan.png',
'label' => __('Custom NetScan'),
];
$buttons[] = [
'url' => $this->url.'&mode=managenetscanscripts',
'icon' => '/images/wizard/managenetscanscripts.png',
'label' => __('Manage NetScan scripts'),
];
$this->prepareBreadcrum(
[
[
@ -136,19 +152,38 @@ class HostDevices extends Wizard
]
);
$this->printHeader();
ui_print_page_header(__('Host & devices'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
$this->printBigButtonsList($buttons);
return;
}
if (enterprise_installed()) {
if ($mode == 'importcsv') {
$csv_importer = new CSVImportAgents($this->page, $this->breadcrum);
if ($mode === 'importcsv') {
$csv_importer = new CSVImportAgents(
$this->page,
$this->breadcrum
);
return $csv_importer->runCSV();
}
}
if ($mode === 'customnetscan') {
$customnetscan_importer = new CustomNetScan(
$this->page,
$this->breadcrum
);
return $customnetscan_importer->runCustomNetScan();
}
if ($mode === 'managenetscanscripts') {
$managenetscanscript_importer = new ManageNetScanScripts(
$this->page,
$this->breadcrum
);
return $managenetscanscript_importer->runManageNetScanScript();
}
if ($mode == 'netscan') {
return $this->runNetScan();
}
@ -477,9 +512,15 @@ class HostDevices extends Wizard
$task_url = '&task='.$this->task['id_rt'];
}
$breadcrum[] = [
$breadcrum = [
[
'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery',
'label' => 'Discovery',
],
[
'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd',
'label' => __($this->label),
],
];
for ($i = 0; $i < $this->maxPagesNetScan; $i++) {
$breadcrum[] = [
@ -492,7 +533,7 @@ class HostDevices extends Wizard
if ($this->page < $this->maxPagesNetScan) {
// Avoid to print header out of wizard.
$this->prepareBreadcrum($breadcrum);
$this->printHeader();
ui_print_page_header(__('NetScan'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
}
if (isset($this->page) === true

View File

@ -26,7 +26,8 @@
* ============================================================================
*/
define('CLOUDWIZARD_AWS_DESCRIPTION', 'Discovery.Cloud.AWS.EC2');
// Begin.
/**
* Global Wizard generic class. Needs to be inherited.
@ -195,20 +196,34 @@ class Wizard
*
* @return void
*/
public function prepareBreadcrum(array $urls, bool $add=false)
public function prepareBreadcrum(array $urls, bool $add=false, bool $separator_beginning=false)
{
$bc = [];
$i = 0;
$count = 0;
$array_size = count($urls);
foreach ($urls as $url) {
$count++;
if ($url['selected'] == 1) {
$class = 'selected';
} else {
$class = '';
}
$bc[$i] = '<a href="'.$url['link'].'" class="text_color">';
$bc[$i] .= '<div class="arrow_box '.$class.'">'.$url['label'];
$bc[$i++] .= '</div></a>';
$bc[$i] = '';
if ($separator_beginning === true) $bc[$i] .= '<span class="breadcrumb_link">&nbsp/&nbsp</span>';
$bc[$i] .= '<span><a class="breadcrumb_link '.$class.'" href="'.$url['link'].'">';
$bc[$i] .= $url['label'];
$bc[$i] .= '</a>';
if ($count < $array_size) $bc[$i] .= '<span class="breadcrumb_link">&nbsp/&nbsp</span>';
$bc[$i] .= '</span>';
$i++;
}
if ($add === true) {
@ -256,7 +271,7 @@ class Wizard
*/
public function printBreadcrum()
{
return '<h1 class="wizard">'.implode('', $this->breadcrum).'</h1>';
return implode('', $this->breadcrum);
}
@ -572,14 +587,18 @@ class Wizard
{
$output = '';
if ($input['hidden'] == 1) {
$class = ' class="hidden"';
$class = ' hidden';
} else {
$class = '';
}
if (isset($input['class']) === true) {
$class = $input['class'].$class;
}
if (is_array($input['block_content']) === true) {
// Print independent block of inputs.
$output .= '<li id="'.$input['block_id'].'" '.$class.'>';
$output .= '<li id="'.$input['block_id'].'" class="'.$class.'">';
$output .= '<ul class="wizard">';
foreach ($input['block_content'] as $input) {
$output .= $this->printBlock($input, $return);
@ -588,7 +607,7 @@ class Wizard
$output .= '</ul></li>';
} else {
if ($input['arguments']['type'] != 'hidden') {
$output .= '<li id="'.$input['id'].'" '.$class.'>';
$output .= '<li id="'.$input['id'].'" class="'.$class.'">';
$output .= '<label>'.$input['label'].'</label>';
$output .= $this->printInput($input['arguments']);
// Allow dynamic content.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,173 @@
<?php
/**
* Extension to schedule tasks on Pandora FMS Console
*
* @category Ajax
* @package Pandora FMS
* @subpackage Host&Devices
* @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.
* ============================================================================
*/
require_once $config['homedir'].'/include/graphs/functions_d3.php';
$progress_task_discovery = (bool) get_parameter('progress_task_discovery', 0);
$showmap = (bool) get_parameter('showmap', 0);
if ($progress_task_discovery) {
$id_task = get_parameter('id', 0);
if ($id_task <= 0) {
echo json_encode(['error' => true]);
return;
}
$task = db_get_row('trecon_task', 'id_rt', $id_task);
$global_progress = $task['status'];
$summary = json_decode($task['summary'], true);
$result = '<div id = progress_task_'.$id_task.'>';
if ($task['utimestamp']) {
$result .= '<ul class="progress_task_discovery">';
$result .= '<li><h1>'._('Overall Progress').'</h1></li>';
$result .= '<li>';
$result .= d3_progress_bar(
$id_task,
($global_progress < 0) ? 100 : $global_progress,
460,
30,
'#EA5434',
'%',
'',
'#FFFFFF',
0,
0,
0
);
if ($global_progress > 0) {
switch ($summary['step']) {
case STEP_SCANNING:
$str = __('Scanning network');
break;
case STEP_AFT:
$str = __('Finding AFT connectivity');
break;
case STEP_TRACEROUTE:
$str = __('Finding traceroute connectivity');
break;
case STEP_GATEWAY:
$str = __('Finding gateway connectivity');
break;
default:
$str = __('Searching for devices...');
break;
}
$result .= '</li>';
$result .= '<li><h1>'.$str.' ';
$result .= $summary['c_network_name'];
$result .= '</h1></li>';
$result .= '<li>';
$result .= d3_progress_bar(
$id_task.'_detail',
$summary['c_network_percent'],
460,
30,
'#2751E1',
'%',
'',
'#FFFFFF',
0,
0,
0
);
$result .= '</li>';
}
$result .= '</ul>';
$i = 0;
$table = new StdClasS();
$table->class = 'databox data';
$table->width = '75%';
$table->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;';
$table->rowid = [];
$table->data = [];
// Content.
$table->data[$i][0] = '<b>'.__('Hosts discovered').'</b>';
$table->data[$i][1] = '<span id="discovered">';
$table->data[$i][1] .= $summary['summary']['discovered'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Alive').'</b>';
$table->data[$i][1] = '<span id="alive">';
$table->data[$i][1] .= $summary['summary']['alive'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Not alive').'</b>';
$table->data[$i][1] = '<span id="not_alive">';
$table->data[$i][1] .= $summary['summary']['not_alive'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Responding SNMP').'</b>';
$table->data[$i][1] = '<span id="SNMP">';
$table->data[$i][1] .= $summary['summary']['SNMP'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Responding WMI').'</b>';
$table->data[$i][1] = '<span id="WMI">';
$table->data[$i][1] .= $summary['summary']['WMI'];
$table->data[$i++][1] .= '</span>';
$result .= html_print_table($table, true).'</div>';
} else {
$global_progress = -1;
$result .= ui_print_error_message(
__('No data to show'),
'',
true
).'</div>';
}
$result_array['status'] = $global_progress;
$result_array['html'] = $result;
echo json_encode($result_array);
return;
}
if ($showmap) {
include_once $config['homedir'].'/include/class/NetworkMap.class.php';
$id_task = get_parameter('id', 0);
$map = new NetworkMap(
[
'id_task' => $id_task,
'pure' => 1,
]
);
$map->printMap();
}

View File

@ -36,7 +36,7 @@ require_once $config['homedir'].'/include/functions_servers.php';
// Enterprise includes.
enterprise_include_once('include/functions_metaconsole.php');
enterprise_include_once('include/functions_license.php');
enterprise_include_once('extensions/cron/functions.php');
enterprise_include_once('include/functions_cron.php');
/**
* Base class to run scheduled tasks in cron extension
@ -541,6 +541,7 @@ class ConsoleSupervisor
case 'NOTIF.LICENSE.LIMITED':
$max_age = 0;
break;
case 'NOTIF.LICENSE.EXPIRATION':
case 'NOTIF.FILES.ATTACHMENT':
case 'NOTIF.FILES.DATAIN':
@ -711,7 +712,7 @@ class ConsoleSupervisor
'type' => 'NOTIF.LICENSE.EXPIRATION',
'title' => __('License is going to expire.'),
'message' => __(
'Your license is going to expire in %d days. Please contact sales.',
'Your license will expire in %d days. Please, contact our sales department.',
$days_to_expiry
),
'url' => 'index.php?sec=gsetup&sec2=godmode/setup/license',
@ -722,8 +723,8 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.LICENSE.EXPIRATION',
'title' => __('License is expired.'),
'message' => __('Your license has expired. Please contact sales.'),
'title' => __('Expired license'),
'message' => __('Your license has expired. Please, contact our sales department.'),
'url' => 'index.php?sec=gsetup&sec2=godmode/setup/license',
]
);
@ -796,9 +797,9 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.WRITABLE.ATTACHMENT',
'title' => __('Attachment directory is not writable.'),
'title' => __('Attachment directory is not writable'),
'message' => __(
'Directory %s is not writable. Please configure proper permissions.',
'Directory %s is not writable. Please, configure corresponding permissions.',
$config['attachment_store']
),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=general',
@ -818,9 +819,9 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.FILES.ATTACHMENT',
'title' => __('There are too much files in attachment directory.'),
'title' => __('There are too many files in attachment directory'),
'message' => __(
'There are more than %d files in attachment, you should consider cleaning up your attachment directory manually.',
'There are more than %d files in attachment, consider cleaning up attachment directory manually.',
$config['num_files_attachment']
),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=perf',
@ -850,9 +851,9 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG',
'title' => __('Remote configuration directory is not readable.'),
'title' => __('Remote configuration directory is not readable'),
'message' => __(
'Remote configuration directory %s is not readable. Please configure it.',
'Remote configuration directory %s is not readable. Please, adjust configuration.',
$config['remote_config']
),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=general',
@ -869,9 +870,9 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF',
'title' => __('Remote configuration directory is not writable.'),
'title' => __('Remote configuration directory is not writable'),
'message' => __(
'Remote configuration directory %s is not writable. Please configure it.',
'Remote configuration directory %s is not writable. Please, adjust configuration.',
$config['remote_config'].'/conf'
),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=general',
@ -887,9 +888,9 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS',
'title' => __('Remote collections directory is not writable.'),
'title' => __('Remote collections directory is not writable'),
'message' => __(
'Collections directory %s is not writable. Please configure it.',
'Collections directory %s is not writable. Please, adjust configuration.',
$config['remote_config'].'/collections'
),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=general',
@ -905,9 +906,9 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5',
'title' => __('Remote md5 directory is not writable.'),
'title' => __('Remote md5 directory is not writable'),
'message' => __(
'MD5 directory %s is not writable. Please configure it.',
'MD5 directory %s is not writable. Please, adjust configuration.',
$config['remote_config'].'/md5'
),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=general',
@ -937,7 +938,7 @@ class ConsoleSupervisor
'type' => 'NOTIF.FILES.DATAIN',
'title' => __('There are too much files in spool').'.',
'message' => __(
'There are more than %d files in %s, you should consider checking DataServer performance',
'There are more than %d files in %s. Consider checking DataServer performance',
$MAX_FILES_DATA_IN,
$config['remote_config']
),
@ -958,9 +959,9 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.FILES.DATAIN.BADXML',
'title' => __('There are too much BADXML files in spool.'),
'title' => __('There are too many BADXML files in spool'),
'message' => __(
'There are more than %d files in %s, you should consider checking software agents.',
'There are more than %d files in %s. Consider checking software agents.',
$MAX_BADXML_FILES_DATA_IN,
$config['remote_config']
),
@ -982,10 +983,12 @@ class ConsoleSupervisor
{
global $config;
include_once $config['homedir'].'/include/functions_servers.php';
$idx_file = $config['attachment_store'].'/.cron.supervisor.servers.idx';
$MAX_QUEUE = 1500;
$MAX_GROWN = 50;
$total_modules = servers_get_total_modules();
$queue_state = [];
$previous = [];
@ -1008,6 +1011,13 @@ class ConsoleSupervisor
$key = $queue['id_server'];
$type = $queue['server_type'];
$new_data[$key] = $queue['queued_modules'];
$max_grown = 0;
if (is_array($total_modules)
&& isset($total_modules[$queue['server_type']])
) {
$max_grown = ($total_modules[$queue['server_type']] * 0.40);
}
// Compare queue increments in a not over 900 seconds.
if (empty($previous[$key]['modules'])
@ -1018,9 +1028,9 @@ class ConsoleSupervisor
$modules_queued = ($queue['queued_modules'] - $previous[$key]['modules']);
// 50 Modules queued since last check. Or more than 1500 queued.
if ($modules_queued > $MAX_GROWN
|| $queue['queued_modules'] > $MAX_QUEUE
// 40% Modules queued since last check. If any.
if ($max_grown > 0
&& $modules_queued > $max_grown
) {
$msg = 'Queue has grown %d modules. Total %d';
if ($modules_queued <= 0) {
@ -1032,7 +1042,7 @@ class ConsoleSupervisor
[
'type' => 'NOTIF.SERVER.QUEUE.'.$key,
'title' => __(
'%s (%s) performance is being lacked.',
'%s (%s) is lacking performance.',
servers_get_server_string_name($type),
$queue['name']
),
@ -1076,6 +1086,7 @@ class ConsoleSupervisor
id_server,
name,
server_type,
server_keepalive,
status,
unix_timestamp() - unix_timestamp(keepalive) as downtime
FROM tserver
@ -1099,7 +1110,7 @@ class ConsoleSupervisor
[
'type' => 'NOTIF.SERVER.STATUS',
'title' => __('No servers available.'),
'message' => __('There are no servers registered in this console, please check installation guide.'),
'message' => __('There are no servers registered in this console. Please, check installation guide.'),
'url' => $url,
]
);
@ -1111,28 +1122,35 @@ class ConsoleSupervisor
}
foreach ($servers as $server) {
if ($server['server_type'] == SERVER_TYPE_ENTERPRISE_SATELLITE) {
if ($server['downtime'] < ($server['server_keepalive'] * 2)) {
// Satellite uses different keepalive mode.
continue;
}
}
if ($server['status'] == 1) {
// Fatal error. Component has die.
$msg = __(
'%s (%s) crashed.',
'%s (%s) has crashed.',
servers_get_server_string_name($server['server_type']),
$server['name']
);
$description = __(
'%s (%s) has died, please check log files',
'%s (%s) has crashed, please check log files.',
servers_get_server_string_name($server['server_type']),
$server['name']
);
} else {
// Non-fatal error. Controlated exit. Component is not running.
$msg = __(
'%s (%s) is stopped.',
'%s (%s) is not running.',
servers_get_server_string_name($server['server_type']),
$server['name']
);
$description = __(
'%s (%s) is stopped, please check configuration file or remove this server from server list.',
'%s (%s) is not running. Please, check configuration file or remove this server from server list.',
servers_get_server_string_name($server['server_type']),
$server['name']
);
@ -1183,7 +1201,7 @@ class ConsoleSupervisor
[
'type' => 'NOTIF.SERVER.MASTER',
'title' => __('No master servers found.'),
'message' => __('You should define at last one server to run as master, please check documentation.'),
'message' => __('At least one server must be defined to run as master. Please, check documentation.'),
'url' => $url,
]
);
@ -1224,12 +1242,17 @@ class ConsoleSupervisor
$php_version_array = explode('.', $php_version);
if ($PHPsafe_mode === '1') {
$url = 'http://php.net/manual/en/features.safe-mode.php';
if ($config['language'] == 'es') {
$url = 'http://php.net/manual/es/features.safe-mode.php';
}
$this->notify(
[
'type' => 'NOTIF.PHP.SAFE_MODE',
'title' => __('PHP safe mode is enabled. Some features may not properly work.'),
'message' => __('To disable, change it on your PHP configuration file (php.ini) and put safe_mode = Off (Dont forget restart apache process after changes)'),
'url' => 'index.php',
'title' => __('PHP safe mode is enabled. Some features may not work properly'),
'message' => __('To disable it, go to your PHP configuration file (php.ini) and put safe_mode = Off (Do not forget to restart apache process after changes)'),
'url' => $url,
]
);
} else {
@ -1237,18 +1260,23 @@ class ConsoleSupervisor
}
if ($PHPmax_input_time !== '-1') {
$url = 'http://php.net/manual/en/info.configuration.php#ini.max-input-time';
if ($config['language'] == 'es') {
$url = 'http://php.net/manual/es/info.configuration.php#ini.max-input-time';
}
$this->notify(
[
'type' => 'NOTIF.PHP.INPUT_TIME',
'title' => sprintf(
__("Not recommended '%s' value in PHP configuration"),
__("'%s' value in PHP configuration is not recommended"),
'max_input_time'
),
'message' => sprintf(
__('Recommended value is %s'),
'-1 ('.__('Unlimited').')'
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
'url' => 'index.php',
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Do not forget to restart Apache process after)'),
'url' => $url,
]
);
} else {
@ -1256,6 +1284,11 @@ class ConsoleSupervisor
}
if ($PHPmax_execution_time !== '0') {
$url = 'http://php.net/manual/en/info.configuration.php#ini.max-execution-time';
if ($config['language'] == 'es') {
$url = 'http://php.net/manual/es/info.configuration.php#ini.max-execution-time';
}
$this->notify(
[
'type' => 'NOTIF.PHP.EXECUTION_TIME',
@ -1267,7 +1300,7 @@ class ConsoleSupervisor
__('Recommended value is: %s'),
'0 ('.__('Unlimited').')'
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
'url' => 'index.php',
'url' => $url,
]
);
} else {
@ -1275,6 +1308,11 @@ class ConsoleSupervisor
}
if ($PHPupload_max_filesize < $PHPupload_max_filesize_min) {
$url = 'http://php.net/manual/en/ini.core.php#ini.upload-max-filesize';
if ($config['language'] == 'es') {
$url = 'http://php.net/manual/es/ini.core.php#ini.upload-max-filesize';
}
$this->notify(
[
'type' => 'NOTIF.PHP.UPLOAD_MAX_FILESIZE',
@ -1286,7 +1324,7 @@ class ConsoleSupervisor
__('Recommended value is: %s'),
sprintf(__('%s or greater'), '800M')
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
'url' => 'index.php',
'url' => $url,
]
);
} else {
@ -1294,6 +1332,11 @@ class ConsoleSupervisor
}
if ($PHPmemory_limit < $PHPmemory_limit_min && $PHPmemory_limit !== '-1') {
$url = 'http://php.net/manual/en/ini.core.php#ini.memory-limit';
if ($config['language'] == 'es') {
$url = 'http://php.net/manual/es/ini.core.php#ini.memory-limit';
}
$this->notify(
[
'type' => 'NOTIF.PHP.MEMORY_LIMIT',
@ -1305,7 +1348,7 @@ class ConsoleSupervisor
__('Recommended value is: %s'),
sprintf(__('%s or greater'), '500M')
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'),
'url' => 'index.php',
'url' => $url,
]
);
} else {
@ -1313,12 +1356,17 @@ class ConsoleSupervisor
}
if (preg_match('/system/', $PHPdisable_functions) || preg_match('/exec/', $PHPdisable_functions)) {
$url = 'http://php.net/manual/en/ini.core.php#ini.disable-functions';
if ($config['language'] == 'es') {
$url = 'http://php.net/manual/es/ini.core.php#ini.disable-functions';
}
$this->notify(
[
'type' => 'NOTIF.PHP.DISABLE_FUNCTIONS',
'title' => __('Problems with disable functions in PHP.INI'),
'message' => __('Variable disable_functions containts functions system() or exec(), in PHP configuration file (php.ini)').'<br /><br />'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
'url' => 'index.php',
'title' => __('Problems with disable_functions in php.ini'),
'message' => __('The variable disable_functions contains functions system() or exec() in PHP configuration file (php.ini)').'<br /><br />'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
'url' => $url,
]
);
} else {
@ -1334,8 +1382,8 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.PHP.PHANTOMJS',
'title' => __('phantomjs is not installed'),
'message' => __('To be able to create images of the graphs for PDFs, please install the phantom.js extension. For that, it is necessary to follow these steps:'),
'title' => __('PhantomJS is not installed'),
'message' => __('To be able to create images of the graphs for PDFs, please install the PhantomJS extension. For that, it is necessary to follow these steps:'),
'url' => $url,
]
);
@ -1395,7 +1443,7 @@ class ConsoleSupervisor
[
'type' => 'NOTIF.HISTORYDB',
'title' => __('Historical database not available'),
'message' => __('Historical database is enabled. But not available using given configuration. Please check it.'),
'message' => __('Historical database is enabled, though not accessible with the current configuration.'),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=hist_db',
]
);
@ -1438,9 +1486,9 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.PANDORADB',
'title' => __('Database maintance problem'),
'title' => __('Database maintenance problem'),
'message' => __(
'Your database is not maintained correctly. It seems that more than 48hrs have passed without proper maintenance. Please review documents of %s on how to perform this maintenance process (DB Tool) and enable it as soon as possible.',
'Your database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.',
io_safe_output(get_product_name())
),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=perf',
@ -1500,9 +1548,9 @@ class ConsoleSupervisor
[
'type' => 'NOTIF.PANDORADB.HISTORY',
'title' => __(
'Historical database maintance problem.'
'Historical database maintenance problem.'
),
'message' => __('Your historical database is not being maintained correctly. It seems that more than 48hrs have passed without proper maintenance. Please review documents of %s on how to perform this maintenance process (DB Tool) and enable it as soon as possible.', get_product_name()),
'message' => __('Your historical database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', get_product_name()),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=perf',
]
);
@ -1540,8 +1588,8 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.HISTORYDB.MR',
'title' => __('Historical database MR missmatch'),
'message' => __('Your historical database is not using the same schema of main DB. This could produce anomalyes while storing historical data.'),
'title' => __('Historical database MR mismatch'),
'message' => __('Your historical database is not using the same schema as the main DB. This could produce anomalies while storing historical data.'),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=hist_db',
]
);
@ -1583,7 +1631,7 @@ class ConsoleSupervisor
[
'type' => 'NOTIF.EXT.ELASTICSEARCH',
'title' => __('Log collector cannot connect to ElasticSearch'),
'message' => __('ElasticSearch is not available using current configuration. Please check it.'),
'message' => __('ElasticSearch is not available using current configuration.'),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=log',
]
);
@ -1653,7 +1701,7 @@ class ConsoleSupervisor
[
'type' => 'NOTIF.METACONSOLE.DB_CONNECTION',
'title' => __('Metaconsole DB is not available.'),
'message' => __('Cannot connect with Metaconsole DB using stored configuration. Please check it.'),
'message' => __('Cannot connect with Metaconsole DB using current configuration.'),
'url' => 'index.php?sec=general&sec2=godmode/setup/setup&section=enterprise',
]
);
@ -1682,7 +1730,7 @@ class ConsoleSupervisor
[
'type' => 'NOTIF.DOWNTIME',
'title' => __('Scheduled downtime running.'),
'message' => __('A scheduled downtime is running. Some monitorization data won\'t be available while downtime is taking place.'),
'message' => __('A scheduled downtime is running. Some monitoring data won\'t be available while downtime is taking place.'),
'url' => 'index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list',
]
);
@ -1840,7 +1888,7 @@ class ConsoleSupervisor
'type' => 'NOTIF.DOWNTIME',
'title' => __('Downtime scheduled soon.'),
'message' => __(
'A scheduled downtime is going to be executed from %s to %s. Some monitorization data won\'t be available while downtime is taking place.',
'A scheduled downtime is going to be executed from %s to %s. Some monitoring data won\'t be available while downtime is taking place.',
date('M j, G:i:s ', $next_downtime_begin),
date('M j, G:i:s ', $next_downtime_end)
),
@ -1876,7 +1924,7 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION',
'title' => __('This instance is not registered in the Update manager'),
'title' => __('This instance is not registered in the Update manager section'),
'message' => __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_register();"> here</a> to start the registration process'),
'url' => 'javascript: force_run_register();',
]
@ -1915,7 +1963,7 @@ class ConsoleSupervisor
[
'type' => 'NOTIF.NEWSLETTER.SUBSCRIPTION',
'title' => __('Not subscribed to the newsletter'),
'message' => __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_newsletter();"> here</a> to start the newsletter subscription process'),
'message' => __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_newsletter();"> here</a> to subscribe to the newsletter'),
'url' => 'javascript: force_run_newsletter();',
]
);
@ -1947,8 +1995,8 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.SECURITY.DEFAULT_PASSWORD',
'title' => __('Default password for "Admin" user has not been changed.'),
'message' => __('Please change the default password because is a common vulnerability reported.'),
'title' => __('Default password for "Admin" user has not been changed'),
'message' => __('Please, change the default password since it is a commonly reported vulnerability.'),
'url' => 'index.php?sec=gusuarios&sec2=godmode/users/user_list',
]
);
@ -1973,8 +2021,8 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.MISC.FONTPATH',
'title' => __('Default font doesnt exist'),
'message' => __('Your defined font doesnt exist or is not defined. Please check font parameters in your config'),
'title' => __('Default font doesn\'t exist'),
'message' => __('Your defined font doesn\'t exist or is not defined. Please, check font parameters in your config'),
'url' => 'index.php?sec=gsetup&sec2=godmode/setup/setup&section=vis',
]
);
@ -1999,7 +2047,7 @@ class ConsoleSupervisor
'type' => 'NOTIF.MISC.DEVELOPBYPASS',
'title' => __('Developer mode is enabled'),
'message' => __(
'Your %s has the "develop_bypass" mode enabled. This is a developer mode and should be disabled in a production system. This value is written in the main index.php file',
'Your %s has the "develop_bypass" mode enabled. This is a developer mode and should be disabled in a production environment. This value is located in the main index.php file',
get_product_name()
),
'url' => 'index.php',
@ -2023,8 +2071,8 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.MISC.EVENTSTORMPROTECTION',
'title' => __('Event storm protection is activated.'),
'message' => __('You need to restart server after altering this configuration setting. No events will be generated during this mode.'),
'title' => __('Event storm protection is enabled.'),
'message' => __('Some events may get lost while this mode is enabled. The server must be restarted after altering this setting.'),
'url' => 'index.php?sec=gsetup&sec2=godmode/setup/setup&section=general',
]
);
@ -2050,7 +2098,7 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.UPDATEMANAGER.OPENSETUP',
'title' => __('Error, first setup "Open update".'),
'title' => __('Failed to retrieve updates, please configure utility'),
'message' => $message,
'url' => 'index.php?sec=gsetup&sec2=godmode/setup/setup&section=general',
]
@ -2107,10 +2155,10 @@ class ConsoleSupervisor
'type' => 'NOTIF.UPDATEMANAGER.MINOR',
'title' => __('Minor release/s available'),
'message' => __(
'There are one or more minor releases waiting for update. <a style="font-size:8pt;font-style:italic;" target="blank" href="%s">.About minor release update</a>.',
'There is one or more minor releases available. <a style="font-size:8pt;font-style:italic;" target="blank" href="%s">.About minor release update</a>.',
$url
),
'url' => $url,
'url' => 'index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online',
]
);
} else {
@ -2135,7 +2183,7 @@ class ConsoleSupervisor
) {
$message_conf_cron = __('DiscoveryConsoleTasks is not running properly');
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
$message_conf_cron .= __('Discovery relies on a proper setup of cron, the time-based scheduling service');
$message_conf_cron .= __('Discovery relies on an appropriate cron setup.');
$message_conf_cron .= '. '.__('Please, add the following line to your crontab file:');
$message_conf_cron .= '<pre>* * * * * &lt;user&gt; wget -q -O - --no-check-certificate ';
$message_conf_cron .= str_replace(
@ -2151,7 +2199,7 @@ class ConsoleSupervisor
if (isset($config['cron_last_run']) === true) {
$message_conf_cron .= __('Last execution').': ';
$message_conf_cron .= date('Y/m/d H:i:s', $config['cron_last_run']);
$message_conf_cron .= __('Please check process is no locked.');
$message_conf_cron .= __('Please, make sure process is not locked.');
}
$this->notify(
@ -2159,7 +2207,7 @@ class ConsoleSupervisor
'type' => 'NOTIF.CRON.CONFIGURED',
'title' => __('DiscoveryConsoleTasks is not configured.'),
'message' => __($message_conf_cron),
'url' => 'index.php?extension_in_menu=gservers&sec=extensions&sec2=enterprise/extensions/cron',
'url' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist',
]
);
} else {

View File

@ -0,0 +1,768 @@
<?php
/**
* Extension to schedule tasks on Pandora FMS Console
*
* @category Wizard
* @package Pandora FMS
* @subpackage Host&Devices
* @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.
* ============================================================================
*/
require_once $config['homedir'].'/godmode/wizards/Wizard.main.php';
/**
* CustomNetScan. Host and devices child class.
*/
class CustomNetScan extends Wizard
{
/**
* Number of pages to control breadcrum.
*
* @var integer
*/
public $MAXPAGES = 2;
/**
* Labels for breadcrum.
*
* @var array
*/
public $pageLabels = [
'Netscan Custom definition',
'Netscan Custom script',
];
/**
* Constructor.
*
* @param integer $page Page.
* @param array $breadcrum Breadcrum.
*
* @return void
*/
public function __construct(int $page, array $breadcrum)
{
$this->url = ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd'
);
$this->page = $page;
$this->breadcrum = $breadcrum;
}
/**
* Retrieves and validates information given by user in NetScan wizard.
*
* @return boolean Data OK or not.
*/
public function parseNetScan()
{
if (isset($this->page) === true && $this->page === 0) {
// Check if we're updating a task.
$task_id = get_parameter('task', null);
if (isset($task_id) === true) {
// We're updating this task.
$task = db_get_row(
'trecon_task',
'id_rt',
$task_id
);
if ($task !== false) {
$this->task = $task;
}
}
return true;
}
// Validate response from page 0. No, not a bug, we're always 1 page
// from 'validation' page.
if (isset($this->page) === true && $this->page === 1) {
$task_id = get_parameter('task', null);
$taskname = get_parameter('taskname', '');
$comment = get_parameter('comment', '');
$server_id = get_parameter('id_recon_server', '');
$id_group = get_parameter('id_group', '');
$interval = get_parameter('interval', 0);
if (isset($task_id) === true) {
// We're updating this task.
$task = db_get_row(
'trecon_task',
'id_rt',
$task_id
);
if ($task !== false) {
$this->task = $task;
}
} else if (isset($taskname) === true) {
// Avoid double creation.
$task = db_get_row_filter(
'trecon_task',
['name' => $taskname]
);
if ($task !== false) {
$this->task = $task;
$this->msg = __('This task has been already defined. Please edit it or create a new one.');
return false;
}
}
if ($task_id !== null
&& $taskname == null
&& $server_id == null
&& $id_group == null
&& $server == null
&& $datacenter == ''
&& $user == ''
&& $pass == ''
&& $encrypt == null
&& $interval == 0
) {
// Default values, no data received.
// User is accesing directly to this page.
if (users_is_admin() !== true && check_acl(
$config['id_usuario'],
$this->task['id_group'],
'PM'
) !== true
) {
$this->msg = __('You have no access to edit this task.');
return false;
}
} else {
if (isset($this->task['id_rt']) === false) {
// Disabled 2 Implies wizard non finished.
$this->task['disabled'] = 2;
}
if ($taskname == '') {
$this->msg = __('You must provide a task name.');
return false;
}
if ($server_id == '') {
$this->msg = __('You must select a Discovery Server.');
return false;
}
if ($id_group == '') {
$this->msg = __('You must select a valid group.');
return false;
}
// Assign fields.
$this->task['name'] = $taskname;
$this->task['description'] = $comment;
$this->task['id_recon_server'] = $server_id;
$this->task['id_group'] = $id_group;
$this->task['interval_sweep'] = $interval;
if (isset($this->task['id_rt']) === false) {
// Create.
$this->task['id_rt'] = db_process_sql_insert(
'trecon_task',
$this->task
);
} else {
// Update.
db_process_sql_update(
'trecon_task',
$this->task,
['id_rt' => $this->task['id_rt']]
);
}
}
return true;
}
// Validate response from page 1.
if ($this->page == 2) {
$id_rt = get_parameter('task', -1);
$task = db_get_row(
'trecon_task',
'id_rt',
$id_rt
);
if ($task !== false) {
$this->task = $task;
} else {
$this->msg = __('Failed to find network scan task.');
return false;
}
$id_recon_script = get_parameter('id_recon_script', null);
$field1 = get_parameter('_field1_', '');
$field2 = get_parameter('_field2_', '');
$field3 = get_parameter('_field3_', '');
$field4 = get_parameter('_field4_', '');
// Get macros.
$macros = get_parameter('macros', null);
if (empty($macros) === false) {
$macros = json_decode(
base64_decode($macros),
true
);
foreach ($macros as $k => $m) {
$macros[$k]['value'] = get_parameter($m['macro'], '');
}
}
$this->task['id_recon_script'] = $id_recon_script;
$this->task['macros'] = io_json_mb_encode($macros);
$this->task['field1'] = $field1;
$this->task['field2'] = $field2;
$this->task['field3'] = $field3;
$this->task['field4'] = $field4;
if ($this->task['disabled'] == 2) {
// Wizard finished.
$this->task['disabled'] = 0;
}
// Update.
$res = db_process_sql_update(
'trecon_task',
$this->task,
['id_rt' => $this->task['id_rt']]
);
return true;
}
return false;
}
/**
* Run function. It will be call into HostsDevices class.
* Page 0: Upload form.
* Page 1: Task resume.
*
* @return void
*/
public function runCustomNetScan()
{
global $config;
if (!check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Custom Net Scan.'
);
include 'general/noaccess.php';
return;
}
if ($this->parseNetScan() === false) {
// Error.
ui_print_error_message(
$this->msg
);
$form = [
'form' => [
'method' => 'POST',
'action' => $this->url.'&mode=customnetscan&page='.($this->page - 1).'&task='.$this->task['id_rt'],
],
'inputs' => [
[
'arguments' => [
'type' => 'hidden',
'name' => 'task',
'value' => $this->task['id_rt'],
],
],
[
'arguments' => [
'name' => 'submit',
'label' => __('Go back'),
'type' => 'submit',
'attributes' => 'class="sub cancel"',
'return' => true,
],
],
],
];
// Check ACL. If user is not able to manage target task,
// redirect him to main page.
if (users_is_admin() !== true && check_acl(
$config['id_usuario'],
$this->task['id_group'],
'PM'
) !== true
) {
$form['form']['action'] = $this->url.'&mode=customnetscan&page='.($this->page - 1);
}
$this->printForm($form);
return null;
}
$run_url = 'index.php?sec=gservers&sec2=godmode/servers/discovery';
$task_url = '';
if (isset($this->task['id_rt']) === true) {
$task_url = '&task='.$this->task['id_rt'];
}
$breadcrum = [
[
'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery',
'label' => 'Discovery',
],
[
'link' => $run_url.'&wiz=hd',
'label' => __('Host & Devices'),
],
];
for ($i = 0; $i < $this->MAXPAGES; $i++) {
$breadcrum[] = [
'link' => $run_url.'&wiz=hd&mode=customnetscan&page='.$i.$task_url,
'label' => __($this->pageLabels[$i]),
'selected' => (($i == $this->page) ? 1 : 0),
];
}
if ($this->page < $this->MAXPAGES) {
// Avoid to print header out of wizard.
$this->prepareBreadcrum($breadcrum);
// Header
ui_print_page_header(__('NetScan Custom'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
}
$task_url = '';
if (isset($this->task['id_rt'])) {
$task_url = '&task='.$this->task['id_rt'];
}
$breadcrum[] = [
'link' => $run_url.'&wiz=hd',
'label' => __($this->label),
];
for ($i = 0; $i < $this->maxPagesNetScan; $i++) {
$breadcrum[] = [
'link' => $run_url.'&wiz=hd&mode=customnetscan&page='.$i.$task_url,
'label' => $this->pageLabelsNetScan[$i],
'selected' => (($i == $this->page) ? 1 : 0),
];
}
if ($this->page < $this->maxPagesNetScan) {
// Avoid to print header out of wizard.
$this->prepareBreadcrum($breadcrum);
// Header
ui_print_page_header(__('NetScan Custom'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
}
if (isset($this->page) === true
&& $this->page !== 0
&& isset($this->task['id_rt']) === false
) {
// Error.
ui_print_error_message(
__('Internal error, please re-run this wizard.')
);
$form = [
'form' => [
'method' => 'POST',
'action' => $this->url.'&mode=customnetscan&page=0',
],
'inputs' => [
[
'arguments' => [
'type' => 'hidden',
'name' => 'page',
'value' => 0,
],
],
[
'arguments' => [
'name' => 'submit',
'label' => __('Go back'),
'type' => 'submit',
'attributes' => 'class="sub cancel"',
'return' => true,
],
],
],
];
$this->printForm($form);
return null;
}
// -------------------------------.
// Page 0. wizard starts HERE.
// -------------------------------.
if (isset($this->page) === true || $this->page == 0) {
if (isset($this->page) === false
|| $this->page == 0
) {
$form = [];
// Input task name.
$form['inputs'][] = [
'label' => '<b>'.__('Task name').'</b>',
'arguments' => [
'name' => 'taskname',
'value' => $this->task['name'],
'type' => 'text',
'size' => 25,
],
];
if (isset($this->task['id_rt']) === true) {
// Propagate id.
$form['inputs'][] = [
'arguments' => [
'name' => 'task',
'value' => $this->task['id_rt'],
'type' => 'hidden',
],
];
}
// Input task description.
$form['inputs'][] = [
'label' => '<b>'.__('Comment').'</b>',
'arguments' => [
'name' => 'comment',
'value' => $this->task['description'],
'type' => 'text',
'size' => 25,
],
];
// Input Discovery Server.
$form['inputs'][] = [
'label' => '<b>'.__('Discovery server').'</b>'.ui_print_help_tip(
__('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'),
true
),
'arguments' => [
'type' => 'select_from_sql',
'sql' => sprintf(
'SELECT id_server, name
FROM tserver
WHERE server_type = %d
ORDER BY name',
SERVER_TYPE_DISCOVERY
),
'name' => 'id_recon_server',
'selected' => $this->task['id_recon_server'],
'return' => true,
],
];
// Input Group.
$form['inputs'][] = [
'label' => '<b>'.__('Group').'</b>',
'arguments' => [
'name' => 'id_group',
'returnAllGroup' => false,
'privilege' => 'PM',
'type' => 'select_groups',
'selected' => $this->task['id_group'],
'return' => true,
],
];
// Interval and schedules.
$interv_manual = 0;
if ((int) $this->task['interval_sweep'] == 0) {
$interv_manual = 1;
}
// Schedule.
$form['inputs'][] = [
'label' => '<b>'.__('Interval').'</b>'.ui_print_help_tip(
__('Manual interval means that it will be executed only On-demand'),
true
),
'arguments' => [
'type' => 'select',
'selected' => $interv_manual,
'fields' => [
0 => __('Defined'),
1 => __('Manual'),
],
'name' => 'interval_manual_defined',
'return' => true,
],
'extra' => '<span id="interval_manual_container">'.html_print_extended_select_for_time(
'interval',
$this->task['interval_sweep'],
'',
'',
'0',
false,
true,
false,
false
).ui_print_help_tip(
__('The minimum recomended interval for Recon Task is 5 minutes'),
true
).'</span>',
];
$str = __('Next');
if (isset($this->task['id_rt']) === true) {
$str = __('Update and continue');
}
// Submit button.
$form['inputs'][] = [
'arguments' => [
'name' => 'submit',
'label' => $str,
'type' => 'submit',
'attributes' => 'class="sub next"',
'return' => true,
],
];
$task_url = '';
if (isset($this->task['id_rt'])) {
$task_url = '&task='.$this->task['id_rt'];
}
$form['form'] = [
'method' => 'POST',
'action' => $this->url.'&mode=customnetscan&page='.($this->page + 1).$task_url,
];
// Default.
$interval = 600;
$unit = 60;
if (isset($this->task['interval_sweep']) === true) {
$interval = $this->task['interval_sweep'];
$unit = $this->getTimeUnit($interval);
}
$form['js'] = '
$("select#interval_manual_defined").change(function() {
if ($("#interval_manual_defined").val() == 1) {
$("#interval_manual_container").hide();
$("#text-interval_text").val(0);
$("#hidden-interval").val(0);
}
else {
$("#interval_manual_container").show();
$("#text-interval_text").val(10);
$("#hidden-interval").val('.$interval.');
$("#interval_units").val('.$unit.');
}
}).change();
';
// XXX: Could be improved validating inputs before continue (JS)
// Print NetScan page 0.
$this->printForm($form);
}
}
if (isset($this->page) === true && $this->page === 1) {
$name_ipam = 'IPAM Recon';
// Recon script.
$form['inputs'][] = [
'label' => '<b>'.__('Recon script').'</b>',
'arguments' => [
'type' => 'select_from_sql',
'sql' => sprintf(
'SELECT id_recon_script, name FROM trecon_script WHERE name <> "%s" ORDER BY name',
$name_ipam
),
'name' => 'id_recon_script',
'selected' => $this->task['id_recon_script'],
'return' => true,
],
];
$form['inputs'][] = [
'hidden' => 1,
'arguments' => [
'type' => 'hidden',
'name' => 'task',
'value' => $this->task['id_rt'],
],
];
$form['inputs'][] = [
'hidden' => 1,
'arguments' => [
'type' => 'hidden_extended',
'name' => 'macros',
'value' => base64_encode($this->task['macros']),
'return' => true,
],
];
// Explanation.
$explanation = db_get_value(
'description',
'trecon_script',
'id_recon_script',
$this->task['id_recon_script']
);
$form['inputs'][] = [
'label' => '<b>'.__('Explanation').'</b><span id="spinner_recon_script" style="display: none;">'.html_print_image('images/spinner.gif', true).'</span>',
'arguments' => [
'type' => 'textarea',
'rows' => 4,
'columns' => 60,
'name' => 'explanation',
'value' => $explanation,
'return' => true,
'attributes' => 'style="width: 388px;"',
],
];
$form['inputs'][] = [
'hidden' => 1,
'id' => 'table_recon-macro_field',
'label' => '<b>'.__('macro_desc').'</b>'.ui_print_help_tip('macro_help', true),
'arguments' => [
'name' => 'macro_name',
'value' => 'macro_value',
'type' => 'text',
'size' => 100,
'return' => true,
],
];
if (empty($this->task['macros']) === false) {
$macros = json_decode($this->task['macros'], true);
foreach ($macros as $k => $m) {
$label_macro = '';
$label_macro .= '<b>'.$m['desc'].'</b>';
if (!empty($m['help'])) {
$label_macro .= ui_print_help_tip(
$m['help'],
true
);
}
if ($m['hide']) {
$form['inputs'][] = [
'label' => $label_macro,
'id' => 'table_recon-macro'.$m['macro'],
'class' => 'macro_field',
'arguments' => [
'name' => $m['macro'],
'value' => $m['value'],
'type' => 'password',
'size' => 100,
'return' => true,
],
];
} else {
$form['inputs'][] = [
'label' => $label_macro,
'id' => 'table_recon-macro'.$m['macro'],
'class' => 'macro_field',
'arguments' => [
'name' => $m['macro'],
'value' => $m['value'],
'type' => 'text',
'size' => 100,
'return' => true,
],
];
}
}
}
// Submit button.
$form['inputs'][] = [
'arguments' => [
'name' => 'submit',
'label' => __('Finish'),
'type' => 'submit',
'attributes' => 'class="sub next"',
'return' => true,
],
];
$form['form'] = [
'method' => 'POST',
'action' => $this->url.'&mode=customnetscan&page='.($this->page + 1).'&task='.$this->task['id_rt'],
];
$id_task = (isset($this->task['id_rt']) === true) ? $this->task['id_rt'] : 0;
$url_ajax = $config['homeurl'].'ajax.php';
$change = '';
if (empty($this->task['macros']) !== false) {
$change = '.change();';
}
$form['js'] = '
$("select#id_recon_script").change(function() {
get_explanation_recon_script($(this).val(), "'.$id_task.'", "'.$url_ajax.'");
})'.$change;
$this->printForm($form);
}
if (isset($this->page) === true && $this->page === 2) {
if ($this->task['id_rt']) {
// 0 - Is OK.
$this->result = 0;
$this->msg = __('Task configured.');
} else {
// 1 - Is NOT OK.
$this->result = 1;
$this->msg = __('Wizard failed. Cannot configure task.');
}
return [
'result' => $this->result,
'id' => $this->task['id_rt'],
'msg' => $this->msg,
];
}
ui_require_javascript_file('pandora_modules');
}
}

View File

@ -0,0 +1,767 @@
<?php
/**
* Extension to schedule tasks on Pandora FMS Console
*
* @category Wizard
* @package Pandora FMS
* @subpackage Host&Devices
* @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.
* ============================================================================
*/
require_once $config['homedir'].'/godmode/wizards/Wizard.main.php';
/**
* ManageNetScanScripts. Host and devices child class.
*/
class ManageNetScanScripts extends Wizard
{
/**
* Number of pages to control breadcrum.
*
* @var integer
*/
public $MAXPAGES = 2;
/**
* Labels for breadcrum.
*
* @var array
*/
public $pageLabels = [
'List net scan scripts',
'Operation net scan cripts',
];
/**
* Constructor.
*
* @param integer $page Page.
* @param array $breadcrum Breadcrum.
*
* @return void
*/
public function __construct(int $page, array $breadcrum)
{
$this->url = ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd'
);
$this->page = $page;
$this->breadcrum = $breadcrum;
}
/**
* Run function. It will be call into HostsDevices class.
* Page 0: Upload form.
* Page 1: Task resume.
*
* @return void
*/
public function runManageNetScanScript()
{
global $config;
if (check_acl($config['id_user'], 0, 'AW') === 0) {
db_pandora_audit(
'ACL Violation',
'Trying to access Net Scan Script.'
);
include 'general/noaccess.php';
return;
}
$run_url = 'index.php?sec=gservers&sec2=godmode/servers/discovery';
$breadcrum = [
[
'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery',
'label' => 'Discovery',
],
[
'link' => $run_url.'&wiz=hd',
'label' => __('Host & Devices'),
],
];
for ($i = 0; $i < $this->MAXPAGES; $i++) {
$breadcrum[] = [
'link' => $run_url.'&wiz=hd&mode=managenetscanscripts&page='.$i,
'label' => __($this->pageLabels[$i]),
'selected' => (($i == $this->page) ? 1 : 0),
];
}
if ($this->page < $this->MAXPAGES) {
// Avoid to print header out of wizard.
$this->prepareBreadcrum($breadcrum);
// Header
ui_print_page_header(__('Net scan scripts'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
}
$id_script = get_parameter('id_script', 0);
// Initialize msg.
$msg = [];
// Operations.
$operation_scp = get_parameter('operation_scp', '');
if ($operation_scp !== '') {
switch ($operation_scp) {
case 'update_scp':
$msg = $this->updateScanScripts($id_script);
break;
case 'delete_scp':
$msg = $this->deleteScanScripts($id_script);
break;
case 'create_scp':
$msg = $this->createScanScripts($id_script);
break;
default:
// Nothing for doing. Never exist other operation.
break;
}
}
if (!isset($this->page) || $this->page === 0) {
$this->printListNetScanScripts($msg);
}
if (!isset($this->page) || $this->page === 1) {
$this->printFormScanScripts($id_script);
}
}
/**
* Create net scan script.
*
* @return array Check msg successfully or problem
*/
private function createScanScripts()
{
$result = [];
$reconscript_name = get_parameter('form_name', '');
$reconscript_description = get_parameter('form_description', '');
$reconscript_script = get_parameter('form_script', '');
// Get macros.
$i = 1;
$macros = [];
while (1) {
$macro = (string) get_parameter('field'.$i.'_macro');
if ($macro == '') {
break;
}
$desc = (string) get_parameter('field'.$i.'_desc');
$help = (string) get_parameter('field'.$i.'_help');
$value = (string) get_parameter('field'.$i.'_value');
$hide = get_parameter('field'.$i.'_hide');
$macros[$i]['macro'] = $macro;
$macros[$i]['desc'] = $desc;
$macros[$i]['help'] = $help;
$macros[$i]['value'] = $value;
$macros[$i]['hide'] = $hide;
$i++;
}
$macros = io_json_mb_encode($macros);
$values = [
'name' => $reconscript_name,
'description' => $reconscript_description,
'script' => $reconscript_script,
'macros' => $macros,
];
$result_crt = false;
if ($values['name'] !== '' && $values['script'] !== '') {
$result_crt = db_process_sql_insert('trecon_script', $values);
if (!$result_crt) {
$result = [
'error' => 1,
'msg' => __('Problem creating'),
];
} else {
$result = [
'error' => 0,
'msg' => __('Created successfully'),
];
}
} else {
$result = [
'error' => 1,
'msg' => __('Name or Script fullpath they can not be empty'),
];
}
return $result;
}
/**
* Update net scan script.
*
* @param integer $id_script Id script.
*
* @return array Check msg successfully or problem
*/
private function updateScanScripts(int $id_script)
{
$result = [];
if (isset($id_script) === false || $id_script === 0) {
$result = [
'error' => 1,
'msg' => __('Problem deleting Net scan Scripts, Not selected script'),
];
return $result;
}
// If modified any parameter.
$reconscript_name = get_parameter('form_name', '');
$reconscript_description = get_parameter('form_description', '');
$reconscript_script = get_parameter('form_script', '');
// Get macros.
$i = 1;
$macros = [];
while (1) {
$macro = (string) get_parameter('field'.$i.'_macro');
if ($macro == '') {
break;
}
$desc = (string) get_parameter('field'.$i.'_desc');
$help = (string) get_parameter('field'.$i.'_help');
$value = (string) get_parameter('field'.$i.'_value');
$hide = get_parameter('field'.$i.'_hide');
$macros[$i]['macro'] = $macro;
$macros[$i]['desc'] = $desc;
$macros[$i]['help'] = $help;
$macros[$i]['value'] = $value;
$macros[$i]['hide'] = $hide;
$i++;
}
$macros = io_json_mb_encode($macros);
$sql_update = sprintf(
"UPDATE trecon_script SET
name = '%s',
description = '%s',
script = '%s',
macros = '%s'
WHERE id_recon_script = %d",
$reconscript_name,
$reconscript_description,
$reconscript_script,
$macros,
$id_script
);
$result_upd = false;
if ($reconscript_name !== '' && $reconscript_script !== '') {
$result_upd = db_process_sql($sql_update);
if (!$result_upd) {
$result = [
'error' => 1,
'msg' => __('Problem updating'),
];
} else {
$result = [
'error' => 0,
'msg' => __('Updated successfully'),
];
}
} else {
$result = [
'error' => 1,
'msg' => __('Name or Script fullpath they can not be empty'),
];
}
return $result;
}
/**
* Delete net scan script.
*
* @param integer $id_script Id script.
*
* @return array Check msg successfully or problem
*/
private function deleteScanScripts(int $id_script)
{
$result = [];
if (isset($id_script) === false || $id_script === 0) {
$result = [
'error' => 1,
'msg' => __('Problem deleting Net scan Scripts, Not selected script'),
];
return $result;
}
$result_dlt = db_process_sql_delete(
'trecon_script',
['id_recon_script' => $id_script]
);
if (!$result_dlt) {
$result = [
'error' => 1,
'msg' => __('Problem deleting Net scan Scripts'),
];
} else {
$result_dlt2 = db_process_sql_delete(
'trecon_task',
['id_recon_script' => $id_script]
);
if (!$result_dlt2) {
$result = [
'error' => 1,
'msg' => __('Problem deleting Net scan Scripts'),
];
} else {
$result = [
'error' => 0,
'msg' => __('Deleted successfully'),
];
}
}
return $result;
}
/**
* Print list Net scan scripts and messages operations.
*
* @param array $msg Print msg if necessary.
*
* @return void
*/
private function printListNetScanScripts(array $msg)
{
if (count($msg) > 0) {
if ($msg['error'] === 1) {
ui_print_error_message($msg['msg']);
} else {
ui_print_success_message($msg['msg']);
}
}
$url = 'index.php?sec=gservers&sec2=godmode/servers/discovery';
$url .= '&wiz=hd&mode=managenetscanscripts';
// List available Net scan scripts.
$rows = db_get_all_rows_in_table('trecon_script');
if ($rows !== false) {
echo '<table width="100%" cellspacing="4" cellpadding="4" class="databox data">';
echo '<th>'.__('Name').'</th>';
echo '<th>'.__('Description').'</th>';
echo '<th>'.__('Delete').'</th>';
$color = 0;
foreach ($rows as $row) {
if ($color == 1) {
$tdcolor = 'datos';
$color = 0;
} else {
$tdcolor = 'datos2';
$color = 1;
}
echo '<tr>';
echo "<td class='".$tdcolor."' style='min-width: 100px;'>";
echo '<b><a href="'.$url.'&page=1&id_script='.$row['id_recon_script'].'">';
echo $row['name'];
echo '</a></b></td>';
echo "</td><td class='".$tdcolor."'>";
$desc = io_safe_output(
$row['description']
);
$desc = str_replace(
"\n",
'<br>',
$desc
);
echo $desc.'<br><br>';
echo '<b>'.__('Command').': </b><i>'.$row['script'].'</i>';
echo "</td><td align='center' class='".$tdcolor."'>";
// Delete.
echo '<form
method="post"
onsubmit="if (! confirm (\''.__('Are you sure delete script?').'\')) return false"
style="display: inline;">';
echo html_print_input_hidden('page', 0, true);
echo html_print_input_hidden(
'operation_scp',
'delete_scp',
true
);
echo html_print_input_hidden(
'id_script',
$row['id_recon_script'],
true
);
echo html_print_input_image(
'delete',
'images/cross.png',
1,
'',
true,
[
'title' => __('Delete Script'),
]
);
echo '</form>';
echo '</td></tr>';
}
echo '</table>';
echo "<form name=reconscript method='post' action='".$url."'>";
echo html_print_input_hidden('page', 1, true);
echo "<input name='crtbutton' style='float:right;' type='submit' class='sub next' value='".__('Add')."'>";
echo '</form>';
} else {
ui_print_info_message(
[
'no_close' => true,
'message' => __(
'There are no net scan scripts in the system'
),
]
);
}
}
/**
* Print form net scan scripts.
*
* @param integer $id_script Id script.
*
* @return void
*/
private function printFormScanScripts(int $id_script)
{
// Initialize vars.
if ($id_script !== 0) {
$form_id = $id_script;
$reconscript = db_get_row(
'trecon_script',
'id_recon_script',
$form_id
);
$form_name = $reconscript['name'];
$form_description = $reconscript['description'];
$form_script = $reconscript['script'];
$macros = $reconscript['macros'];
} else {
$form_name = '';
$form_description = '';
$form_script = '';
$macros = '';
}
$url = 'index.php?sec=gservers&sec2=godmode/servers/discovery';
$url .= '&wiz=hd&mode=managenetscanscripts';
if ($id_script !== 0) {
echo '<form name=reconscript method="post" action="'.$url.'&id_script='.$id_script.'">';
echo html_print_input_hidden('page', 0, true);
echo html_print_input_hidden(
'operation_scp',
'update_scp',
true
);
} else {
echo '<form name=reconscript method="post" action="'.$url.'">';
echo html_print_input_hidden('page', 0, true);
echo html_print_input_hidden(
'operation_scp',
'create_scp',
true
);
}
$table = new stdClass();
$table->width = '100%';
$table->id = 'table-form';
$table->class = 'databox filters';
$table->style = [];
$table->style[0] = 'font-weight: bold';
$table->style[2] = 'font-weight: bold';
$table->data = [];
$data = [];
$data[0] = __('Name');
$data[0] .= ui_print_help_icon(
'reconscript_definition',
true,
'',
'images/help_w.png'
);
$data[1] = '<input type="text" name="form_name" size=30 value="'.$form_name.'">';
$table->data['recon_name'] = $data;
$table->colspan['recon_name'][1] = 3;
$data = [];
$data[0] = __('Script fullpath');
$data[1] = '<input type="text" name="form_script" size=70 value="'.$form_script.'">';
$table->data['recon_fullpath'] = $data;
$table->colspan['recon_fullpath'][1] = 3;
$data = [];
$data[0] = __('Description');
$data[1] = '<textarea name="form_description" cols="50" rows="4">';
$data[1] .= $form_description;
$data[1] .= '</textarea>';
$table->data['recon_description'] = $data;
$table->colspan['recon_description'][1] = 3;
$macros = json_decode($macros, true);
// This code is ready to add locked feature as plugins.
$locked = false;
// The next row number is recon_3.
$next_name_number = 3;
$i = 1;
while (1) {
// Always print at least one macro.
if ((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) {
break;
}
$macro_desc_name = 'field'.$i.'_desc';
$macro_desc_value = '';
$macro_help_name = 'field'.$i.'_help';
$macro_help_value = '';
$macro_value_name = 'field'.$i.'_value';
$macro_value_value = '';
$macro_name_name = 'field'.$i.'_macro';
$macro_name = '_field'.$i.'_';
$macro_hide_value_name = 'field'.$i.'_hide';
$macro_hide_value_value = 0;
if (isset($macros[$i]['desc'])) {
$macro_desc_value = $macros[$i]['desc'];
}
if (isset($macros[$i]['help'])) {
$macro_help_value = $macros[$i]['help'];
}
if (isset($macros[$i]['value'])) {
$macro_value_value = $macros[$i]['value'];
}
if (isset($macros[$i]['hide'])) {
$macro_hide_value_value = $macros[$i]['hide'];
}
$datam = [];
$datam[0] = __('Description');
$datam[0] .= "<span style='font-weight: normal'> ( ";
$datam[0] .= $macro_name;
$datam[0] .= ' )</span>';
$datam[0] .= html_print_input_hidden(
$macro_name_name,
$macro_name,
true
);
$datam[1] = html_print_input_text_extended(
$macro_desc_name,
$macro_desc_value,
'text-'.$macro_desc_name,
'',
30,
255,
$locked,
'',
"class='command_advanced_conf'",
true
);
if ($locked) {
$datam[1] .= html_print_image(
'images/lock.png',
true,
['class' => 'command_advanced_conf']
);
}
$datam[2] = __('Default value');
$datam[2] .= "<span style='font-weight: normal'> ( ";
$datam[2] .= $macro_name;
$datam[2] .= ' ) </span>';
$datam[3] = html_print_input_text_extended(
$macro_value_name,
$macro_value_value,
'text-'.$macro_value_name,
'',
30,
255,
$locked,
'',
"class='command_component command_advanced_conf'",
true
);
if ($locked) {
$datam[3] .= html_print_image(
'images/lock.png',
true,
['class' => 'command_advanced_conf']
);
}
$table->data['recon_'.$next_name_number] = $datam;
$next_name_number++;
$table->colspan['recon_'.$next_name_number][1] = 3;
$datam = [];
$datam[0] = __('Hide value');
$datam[0] .= ui_print_help_tip(
__('This field will show up as dots like a password'),
true
);
$datam[1] = html_print_checkbox_extended(
$macro_hide_value_name,
1,
$macro_hide_value_value,
0,
'',
['class' => 'command_advanced_conf'],
true,
'checkbox-'.$macro_hide_value_name
);
$table->data['recon_'.$next_name_number] = $datam;
$next_name_number++;
$table->colspan['recon_'.$next_name_number][1] = 3;
$datam = [];
$datam[0] = __('Help');
$datam[0] .= "<span style='font-weight: normal'> ( ";
$datam[0] .= $macro_name;
$datam[0] .= ' )</span><br><br><br>';
$tadisabled = ($locked === true) ? ' disabled' : '';
$datam[1] = html_print_textarea(
$macro_help_name,
6,
100,
$macro_help_value,
'class="command_advanced_conf" style="width: 97%;"'.$tadisabled,
true
);
if ($locked) {
$datam[1] .= html_print_image(
'images/lock.png',
true,
['class' => 'command_advanced_conf']
);
}
$datam[1] .= '<br><br><br>';
$table->data['recon_'.$next_name_number] = $datam;
$next_name_number++;
$i++;
}
if (!$locked) {
$datam = [];
$datam[0] = '<span style="font-weight: bold">';
$datam[0] .= __('Add macro').'</span>';
$datam[0] .= '<a href="javascript:new_macro(\'table-form-recon_\');update_preview();">';
$datam[0] .= html_print_image(
'images/add.png',
true
);
$datam[0] .= '</a>';
$datam[0] .= '<div id="next_macro" style="display:none">';
$datam[0] .= $i.'</div>';
$datam[0] .= '<div id="next_row" style="display:none">';
$datam[0] .= $next_name_number.'</div>';
$delete_macro_style = '';
if ($i <= 2) {
$delete_macro_style = 'display:none;';
}
$datam[2] = '<div id="delete_macro_button" style="'.$delete_macro_style.'">';
$datam[2] .= __('Delete macro');
$datam[2] .= '<a href="javascript:delete_macro_form(\'table-form-recon_\');update_preview();">';
$datam[2] .= html_print_image(
'images/delete.png',
true
);
$datam[2] .= '</a></div>';
$table->colspan['recon_action'][0] = 2;
$table->rowstyle['recon_action'] = 'text-align:center';
$table->colspan['recon_action'][2] = 2;
$table->data['recon_action'] = $datam;
}
html_print_table($table);
echo '<table width=100%>';
echo '<tr><td align="right">';
if ($id_script === 0) {
echo "<input name='crtbutton' type='submit' class='sub wand' value='".__('Create')."'>";
} else {
echo "<input name='uptbutton' type='submit' class='sub upd' value='".__('Update')."'>";
}
echo '</form></table>';
ui_require_javascript_file('pandora_modules');
}
}

File diff suppressed because it is too large Load Diff

View File

@ -195,6 +195,14 @@ define('AGENT_STATUS_UNKNOWN', 3);
define('AGENT_STATUS_ALERT_FIRED', 4);
define('AGENT_STATUS_WARNING', 2);
// Pseudo criticity analysis.
define('NO_CRIT', -1);
define('CRIT_0', 0);
define('CRIT_1', 1);
define('CRIT_2', 2);
define('CRIT_3', 3);
define('CRIT_4', 4);
define('CRIT_5', 5);
// Visual maps contants.
// The items kind.
@ -506,6 +514,18 @@ define('OPTION_COLOR_PICKER', 11);
define('NODE_TYPE', 0);
define('ARROW_TYPE', 1);
// Discovery task steps.
define('STEP_SCANNING', 1);
define('STEP_AFT', 2);
define('STEP_TRACEROUTE', 3);
define('STEP_GATEWAY', 4);
// Networkmap node types.
define('NODE_AGENT', 0);
define('NODE_MODULE', 1);
define('NODE_PANDORA', 2);
define('NODE_GENERIC', 3);
// SAML attributes constants.
define('SAML_ROLE_AND_TAG', 'eduPersonEntitlement');
define('SAML_USER_DESC', 'commonName');
@ -535,12 +555,41 @@ define('MAP_GENERATION_RADIAL', 2);
define('MAP_GENERATION_SPRING1', 3);
define('MAP_GENERATION_SPRING2', 4);
// Algorithm: Circo.
define('LAYOUT_CIRCULAR', 0);
// Algorithm: Dot.
define('LAYOUT_FLAT', 1);
// Algorithm: Twopi.
define('LAYOUT_RADIAL', 2);
// Algorithm: Neato.
define('LAYOUT_SPRING1', 3);
// Algorithm: Fdp.
define('LAYOUT_SPRING2', 4);
// Extra: radial dynamic.
define('LAYOUT_RADIAL_DYNAMIC', 6);
// Map sources.
define('SOURCE_GROUP', 0);
define('SOURCE_TASK', 1);
define('SOURCE_NETWORK', 2);
// Backward compatibility ~ Migration.
define('MAP_SOURCE_GROUP', 0);
define('MAP_SOURCE_IP_MASK', 1);
define('NETWORKMAP_DEFAULT_WIDTH', 800);
define('NETWORKMAP_DEFAULT_HEIGHT', 800);
// Discovery task types.
define('DISCOVERY_HOSTDEVICES', 0);
define('DISCOVERY_HOSTDEVICES_CUSTOM', 1);
define('DISCOVERY_CLOUD_AWS', 10);
define('DISCOVERY_APP_VMWARE', 100);
// Discovery task descriptions.
define('CLOUDWIZARD_AWS_DESCRIPTION', 'Discovery.Cloud.AWS.EC2');
define('CLOUDWIZARD_VMWARE_DESCRIPTION', 'Discovery.App.VMware');
// Background options.
define('CENTER', 0);
define('MOSAIC', 1);

View File

@ -434,15 +434,15 @@ function agents_get_agents(
$filter_nogroup = $filter;
// Get user groups
$groups = array_keys(users_get_groups($config['id_user'], $access, false));
$groups = array_keys(users_get_groups($config['id_user'], $access, true));
// If no group specified, get all user groups
if (empty($filter['id_grupo'])) {
if (isset($filter['id_grupo']) === false) {
$all_groups = true;
$filter['id_grupo'] = $groups;
} else if (! is_array($filter['id_grupo'])) {
$all_groups = false;
// If group is specified but not allowed, return false
// If group is specified but not allowed, return false.
if (! in_array($filter['id_grupo'], $groups)) {
return false;
}
@ -466,11 +466,6 @@ function agents_get_agents(
$filter['id_group'] = $filter['id_grupo'];
if (in_array(0, $filter['id_grupo'])) {
unset($filter['id_grupo']);
unset($filter['id_group']);
}
if (!is_array($fields)) {
$fields = [];
$fields[0] = 'id_agente';
@ -578,6 +573,7 @@ function agents_get_agents(
}
$sql = sprintf('%s %s', $sql, $limit_sql);
if ($return) {
return $sql;
} else {
@ -2202,7 +2198,7 @@ function agents_delete_agent($id_agents, $disableACL=false)
// Delete agent in networkmap enterprise
if (enterprise_installed()) {
enterprise_include_once('include/functions_pandora_networkmap.php');
enterprise_include_once('include/functions_networkmap.php');
networkmap_delete_nodes_by_agent([$id_agent]);
}

View File

@ -2700,9 +2700,7 @@ function config_check()
if (enterprise_installed() === false) {
$supervisor = new ConsoleSupervisor(false);
$supervisor->run();
} else if ($config['cron_last_run'] == 0
|| (get_system_time() - $config['cron_last_run']) > 3600
) {
} else {
$supervisor = new ConsoleSupervisor(false);
$supervisor->runBasic();
}

View File

@ -383,12 +383,15 @@ function extensions_load_extensions($process_login)
try {
include_once $path_extension;
}
// PHP 7
catch (Throwable $e) {
}
// PHP 5
catch (Exception $e) {
}
// ~ }
}
}

View File

@ -188,3 +188,252 @@ function maps_add_node_relationship($values)
$result_add_node_rel = db_process_sql_insert('trel_item', $values);
return $result_add_node_rel;
}
function run_graphviz($filename_map, $filename_dot, $layout, $graph)
{
switch (PHP_OS) {
case 'WIN32':
case 'WINNT':
case 'Windows':
$filename_plain = sys_get_temp_dir().'\\plain.txt';
break;
default:
$filename_plain = sys_get_temp_dir().'/plain.txt';
break;
}
file_put_contents($filename_dot, $graph);
file_put_contents($filename_dot, $graph);
$cmd = $layout.' -Tcmapx -o'.$filename_map.' -Tplain -o'.$filename_plain.' '.$filename_dot;
system($cmd);
if (file_exists($filename_map)) {
unlink($filename_map);
}
if (file_exists($filename_dot)) {
unlink($filename_dot);
}
return $filename_plain;
}
function open_graph($size_x=50, $size_y=25)
{
$size = '';
$size = $size_x.','.$size_y;
// BEWARE: graphwiz DONT use single ('), you need double (").
$head = 'graph vmwaremap { labeljust=l; margin=0; ';
$head .= 'ratio=fill;';
$head .= 'root=0;';
$head .= 'rankdir=LR;';
$head .= 'size="'.$size.'";';
return $head;
}
function create_node($node, $font_size=10)
{
// Set node status.
if (isset($node['status'])) {
switch ($node['status']) {
case AGENT_MODULE_STATUS_NORMAL:
$status_color = COL_NORMAL;
// Normal monitor.
break;
case AGENT_MODULE_STATUS_CRITICAL_BAD:
$status_color = COL_CRITICAL;
// Critical monitor.
break;
case AGENT_MODULE_STATUS_WARNING:
$status_color = COL_WARNING;
// Warning monitor.
break;
case AGENT_STATUS_ALERT_FIRED:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
$status_color = COL_ALERTFIRED;
// Alert fired.
break;
case AGENT_MODULE_STATUS_NOT_INIT:
$status_color = COL_NOTINIT;
// Not init.
break;
default:
$status_color = COL_UNKNOWN;
// Unknown monitor.
break;
}
$status_color = 'color="'.$status_color.'",';
} else {
$status_color = '';
}
// Short name.
if (isset($node['nombre'])) {
$name = io_safe_output(strtolower($node['nombre']));
if (strlen($name) > 16) {
$name = substr($name, 0, 16).'...';
}
}
// Set node icon.
if (isset($node['image'])) {
if (file_exists($node['image'])) {
$img_node = $node['image'];
} else {
$img_node = null;
}
} else {
$img_node = null;
}
$result = $node['id_node'].' [ '.$status_color.' fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD>'.html_print_image($img_node, true, false, false, true).'</TD></TR>
<TR><TD>'.$name.'</TD></TR></TABLE>>,
shape="doublecircle",
tooltip="ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$node['id'].'"];';
return $result;
}
/**
* Returns an edge definition.
*
* @param string $head Origin.
* @param string $tail Target.
*
* @return string Edge str.
*/
function create_edge($head, $tail)
{
// Token edgeURL allows node navigation.
$edge = $head.' -- '.$tail.'[color="#BDBDBD", headclip=false, tailclip=false];'."\n";
return $edge;
}
// Closes a graph definition
function close_graph()
{
return '}';
}
function loadfile_map($file='', $graph)
{
global $config;
$networkmap_nodes = [];
$relations = [];
$other_file = file($file);
$graph = explode(']', $graph);
$ids = [];
foreach ($graph as $node) {
$line = str_replace("\n", ' ', $node);
if (preg_match('/([0-9]+) \[.*tooltip.*id_agent=([0-9]+)/', $line, $match) != 0) {
$ids[$match[1]] = ['id_agent' => $match[2]];
}
}
foreach ($other_file as $key => $line) {
$line = preg_replace('/[ ]+/', ' ', $line);
$data = [];
if (preg_match('/^node.*$/', $line) != 0) {
$items = explode(' ', $line);
$node_id = $items[1];
$node_x = ($items[2] * 100);
// 200 is for show more big
$node_y = ($height_map - $items[3] * 100);
// 200 is for show more big
$data['id'] = $node_id;
$data['image'] = '';
$data['width'] = 10;
$data['height'] = 10;
$data['id_agent'] = 0;
if (preg_match('/<img src=\"([^\"]*)\"/', $line, $match) == 1) {
$image = $match[1];
$data['image'] = $config['homeurl'].'/'.$image;
$size = getimagesize($config['homeurl'].'/'.$image);
$data['image_width'] = $size[0];
$data['image_height'] = $size[1];
if ($ids[$node_id]['id_agent'] == '') {
$data['id_agent'] = 0;
$data['label'] = get_product_name();
$data['color'] = COL_UNKNOWN;
} else {
$data['id_agent'] = $ids[$node_id]['id_agent'];
$data['label'] = io_safe_output(agents_get_alias($data['id_agent']));
$status = agents_get_status($data['id_agent']);
switch ($status) {
case 0:
$status_color = COL_NORMAL;
// Normal monitor
break;
case 1:
$status_color = COL_CRITICAL;
// Critical monitor
break;
case 2:
$status_color = COL_WARNING;
// Warning monitor
break;
case 4:
$status_color = COL_ALERTFIRED;
// Alert fired
break;
default:
$status_color = COL_UNKNOWN;
// Unknown monitor
break;
}
$data['color'] = $status_color;
}
}
$data['x'] = $node_x;
$data['y'] = $node_y;
$networkmap_nodes['nodes'][] = $data;
} else if (preg_match('/^edge.*$/', $line) != 0) {
$items = explode(' ', $line);
$line_orig = $items[2];
$line_dest = $items[1];
$networkmap_nodes['arrows'][] = [
'orig' => $line_orig,
'dest' => $line_dest,
];
}
}
return $networkmap_nodes;
}

View File

@ -19,8 +19,10 @@
// Set session variable to store menu type (classic or collapsed) within this session
if (!empty(get_parameter('menuType')))
$_SESSION['menu_type'] = get_parameter('menuType', 'collapsed');
if (!empty(get_parameter('menuType'))) {
$_SESSION['menu_type'] = get_parameter('menuType', 'classic');
}
/**
* Prints a complete menu structure.
@ -80,10 +82,17 @@ function menu_print_menu(&$menu)
$submenu = false;
if ($_SESSION['menu_type']=='classic')
$classes = ['menu_icon', 'no_hidden_menu'];
else
$classes = ['menu_icon', 'menu_icon_collapsed'];
if ($_SESSION['menu_type'] == 'classic') {
$classes = [
'menu_icon',
'no_hidden_menu',
];
} else {
$classes = [
'menu_icon',
'menu_icon_collapsed',
];
}
if (isset($main['sub'])) {
$classes[] = '';
@ -383,10 +392,11 @@ function menu_print_menu(&$menu)
$length = strlen(__($main['text']));
$padding_top = ( $length >= 18) ? 6 : 12;
if ($_SESSION['menu_type']=='classic')
if ($_SESSION['menu_type'] == 'classic') {
$output .= '<div id="title_menu" class="title_menu_classic" style="padding-top:'.$padding_top.'px; display:none;">'.$main['text'].'</div>';
else
} else {
$output .= '<div id="title_menu" class="title_menu_collapsed" style="padding-top:'.$padding_top.'px; display:none;">'.$main['text'].'</div>';
}
// Add the notification ball if defined
if (isset($main['notification'])) {

View File

@ -582,6 +582,56 @@ function messages_get_overview_sent(
}
/**
* Get a message interpreted as a conversation.
*
* @param mixed $data Complete message or message id.
*
* @return mixed False if fails. A string array with the conversation.
*/
function messages_get_conversation($data)
{
if (is_array($data)) {
$message = $data;
} else {
$message = messages_get_message($data);
}
if (!isset($message) || !is_array($message)) {
return [];
}
$conversation = [];
$target_str = $message['mensaje'];
while (preg_match_all(
'/(.*)On(.*)wrote:(.*)/',
$target_str,
$decoded,
PREG_PATTERN_ORDER
) !== false && empty($target_str) !== true) {
if (empty($decoded[2]) !== true) {
array_push(
$conversation,
[
'message' => array_pop($decoded)[0],
'date' => array_pop($decoded)[0],
]
);
} else {
array_push(
$conversation,
['message' => $target_str]
);
}
$target_str = $decoded[1][0];
}
return $conversation;
}
/**
* Get the URL of a message. If field in db is null, it returs a link to
* messages view.

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,29 @@
<?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.
/*
* @package Include
* @subpackage Networkmaps
/**
* Library for networkmaps in Pandora FMS
*
* @category Deprecated
* @package Pandora FMS
* @subpackage NetworkMap
* @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.
* ============================================================================
*/
// Deprecated.

View File

@ -993,7 +993,7 @@ function notifications_print_dropdown_element($message_info)
$message_info['id_mensaje'],
messages_get_url($message_info['id_mensaje']),
html_print_image('images/'.$message_info['icon'], true),
$message_info['subject'],
str_replace([io_safe_input('<br>')], ' ', $message_info['mensaje'])
io_safe_output($message_info['subject']),
strip_tags(io_safe_output($message_info['mensaje']), '<br><pre>')
);
}

File diff suppressed because it is too large Load Diff

View File

@ -1697,6 +1697,7 @@ function reporting_event_report_group(
}
$return['description'] = $content['description'];
$return['show_extended_events'] = $content['show_extended_events'];
$return['date'] = reporting_get_date_text($report, $content);
$event_filter = $content['style'];
@ -1917,6 +1918,7 @@ function reporting_event_report_module(
}
$return['description'] = $content['description'];
$return['show_extended_events'] = $content['show_extended_events'];
$return['date'] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
@ -2756,6 +2758,7 @@ function reporting_event_report_agent(
$return['date'] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$return['show_summary_group'] = $content['style']['show_summary_group'];
$return['show_extended_events'] = $content['show_extended_events'];
$style = $content['style'];
@ -7734,6 +7737,7 @@ function reporting_get_agents_detailed_event(
'criticity' => $e['criticity'],
'validated_by' => $e['id_usuario'],
'timestamp' => $e['timestamp_rep'],
'id_evento' => $e['id_evento'],
];
} else {
$return_data[] = [
@ -7743,6 +7747,7 @@ function reporting_get_agents_detailed_event(
'criticity' => $e['criticity'],
'validated_by' => $e['id_usuario'],
'timestamp' => $e['timestamp'],
'id_evento' => $e['id_evento'],
];
}
}

View File

@ -910,6 +910,9 @@ function reporting_html_top_n($table, $item, $pdf=0)
function reporting_html_event_report_group($table, $item, $pdf=0)
{
global $config;
$show_extended_events = $item['show_extended_events'];
if ($item['total_events']) {
$table1 = new stdClass();
$table1->width = '99%';
@ -1017,6 +1020,17 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
}
array_push($table1->data, $data);
if ($show_extended_events == 1 && events_has_extended_info($event['id_evento'])) {
$extended_events = events_get_extended_events($event['id_evento']);
foreach ($extended_events as $extended_event) {
$extended_data = [];
$extended_data[] = "<td colspan='5'><font style='font-style: italic;'>".io_safe_output($extended_event['description'])."</font></td><td><font style='font-size: 6pt; font-style: italic;'>".date($config['date_format'], $extended_event['utimestamp']).'</font></td>';
array_push($table1->data, $extended_data);
}
}
}
if ($pdf) {
@ -1126,6 +1140,9 @@ function reporting_html_event_report_group($table, $item, $pdf=0)
function reporting_html_event_report_module($table, $item, $pdf=0)
{
global $config;
$show_extended_events = $item['show_extended_events'];
$show_summary_group = $item['show_summary_group'];
if ($item['total_events']) {
if (!empty($item['failed'])) {
@ -1209,6 +1226,17 @@ function reporting_html_event_report_module($table, $item, $pdf=0)
}
$table1->data[] = $data;
if ($show_extended_events == 1 && events_has_extended_info($event['id_evento'])) {
$extended_events = events_get_extended_events($event['id_evento']);
foreach ($extended_events as $extended_event) {
$extended_data = [];
$extended_data[] = "<td colspan='3'><font style='font-style: italic;'>".io_safe_output($extended_event['description'])."</font></td><td><font style='font-style: italic;'>".date($config['date_format'], $extended_event['utimestamp']).'</font></td>';
array_push($table1->data, $extended_data);
}
}
}
}
@ -1898,6 +1926,8 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
{
global $config;
$show_extended_events = $item['show_extended_events'];
if ($item['total_events'] != 0) {
$table1 = new stdClass();
$table1->width = '99%';
@ -1985,6 +2015,17 @@ function reporting_html_event_report_agent($table, $item, $pdf=0)
}
array_push($table1->data, $data);
if ($show_extended_events == 1 && events_has_extended_info($event['id_evento'])) {
$extended_events = events_get_extended_events($event['id_evento']);
foreach ($extended_events as $extended_event) {
$extended_data = [];
$extended_data[] = "<td colspan='4'><font style='font-style: italic;'>".io_safe_output($extended_event['description'])."</font></td><td><font style='font-size: 6pt; font-style: italic;'>".date($config['date_format'], $extended_event['utimestamp']).'</font></td>';
array_push($table1->data, $extended_data);
}
}
}
if ($pdf) {

View File

@ -11,10 +11,10 @@
// 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.
require_once 'include/functions_modules.php';
require_once 'include/functions_events.php';
require_once 'include/functions_groups.php';
require_once 'include/functions_netflow.php';
require_once __DIR__.'/functions_modules.php';
require_once __DIR__.'/functions_events.php';
require_once __DIR__.'/functions_groups.php';
require_once __DIR__.'/functions_netflow.php';
enterprise_include_once('include/functions_metaconsole.php');

View File

@ -88,6 +88,58 @@ function servers_force_recon_task($id_recon_task)
}
/**
* Retrieves total number of modules per server.
*
* @return array Modules per server (total).
*/
function servers_get_total_modules()
{
$modules = [];
$modules_from_monitors = db_get_all_rows_sql(
'SELECT
tserver.server_type,
count(tagente_estado.id_agente_modulo) as modules_assigned
FROM tserver, tagente_estado, tagente_modulo, tagente
WHERE tagente.disabled=0
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente_modulo.disabled = 0
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_estado.running_by = tserver.id_server
GROUP BY tserver.server_type;'
);
if ($modules_from_monitors !== false) {
$modules = array_reduce(
$modules_from_monitors,
function ($carry, $item) {
$carry[$item['server_type']] = $item['modules_assigned'];
return $carry;
}
);
}
$modules[SERVER_TYPE_INVENTORY] = db_get_sql(
'SELECT COUNT(tagent_module_inventory.id_agent_module_inventory)
FROM tagente, tagent_module_inventory
WHERE tagente.disabled=0
AND tagent_module_inventory.id_agente = tagente.id_agente'
);
$modules[SERVER_TYPE_EXPORT] = db_get_sql(
'SELECT COUNT(tagente_modulo.id_agente_modulo)
FROM tagente, tagente_modulo
WHERE tagente.disabled=0
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente_modulo.id_export != 0'
);
return $modules;
}
/**
* This function will get several metrics from the database to get info about server performance
*
@ -989,6 +1041,9 @@ function servers_get_server_string_name(int $server)
case SERVER_TYPE_WUX:
return __('WUX server');
case SERVER_TYPE_ENTERPRISE_SATELLITE:
return __('Satellite');
default:
return __('N/A');
}

View File

@ -2768,7 +2768,8 @@ function ui_print_page_header(
$modal=false,
$message='',
$numChars=GENERIC_SIZE_TEXT,
$alias=''
$alias='',
$breadcrumbs=''
) {
$title = io_safe_input_html($title);
if (($icon == '') && ($godmode == true)) {
@ -2781,15 +2782,20 @@ function ui_print_page_header(
if ($godmode == true) {
$type = 'view';
$type2 = 'menu_tab_frame_view';
$type2 = (empty($breadcrumbs)) ? 'menu_tab_frame_view' : 'menu_tab_frame_view_bc';
$separator_class = 'separator';
} else {
$type = 'view';
$type2 = 'menu_tab_frame_view';
$type2 = (empty($breadcrumbs)) ? 'menu_tab_frame_view' : 'menu_tab_frame_view_bc';
$separator_class = 'separator_view';
}
$buffer = '<div id="'.$type2.'" style=""><div id="menu_tab_left">';
$buffer = '<div id="'.$type2.'" style="">';
if (!empty($breadcrumbs))
$buffer .= '<div class="breadcrumbs_container">'.$breadcrumbs.'</div>';
$buffer .= '<div id="menu_tab_left">';
$buffer .= '<ul class="mn"><li class="'.$type.'">';

View File

@ -354,8 +354,19 @@ function ux_console_phases_donut($phases, $id, $return=false)
}
function d3_progress_bar($id, $percentile, $width, $height, $color, $unit='%', $text='', $fill_color='#FFFFFF')
{
function d3_progress_bar(
$id,
$percentile,
$width,
$height,
$color,
$unit='%',
$text='',
$fill_color='#FFFFFF',
$radiusx=10,
$radiusy=10,
$transition=1
) {
global $config;
$recipient_name = 'progress_bar_'.$id;
@ -366,8 +377,20 @@ function d3_progress_bar($id, $percentile, $width, $height, $color, $unit='%', $
$output .= '<div id='.$recipient_name." style='overflow: hidden;'></div>";
$output .= include_javascript_d3(true);
$output .= "<script language=\"javascript\" type=\"text/javascript\">
progress_bar_d3('".$recipient_name_to_js."', ".(int) $percentile.', '.(int) $width.', '.(int) $height.", '".$color."', '".$unit."', '".$text."', '".$fill_color."');
</script>";
progress_bar_d3(
'".$recipient_name_to_js."',
".(int) $percentile.',
'.(int) $width.',
'.(int) $height.",
'".$color."',
'".$unit."',
'".$text."',
'".$fill_color."',
".(int) $radiusx.',
'.(int) $radiusy.',
'.(int) $transition.'
);
</script>';
return $output;
}

View File

@ -1782,7 +1782,10 @@ function progress_bar_d3(
color,
unit,
label,
label_color
label_color,
radiusx,
radiusy,
transition
) {
var startPercent = 0;
var endPercent = parseInt(percentile) / 100;
@ -1799,20 +1802,20 @@ function progress_bar_d3(
.append("rect")
.attr("fill", "#000000")
.attr("fill-opacity", 0.5)
.attr("height", 20)
.attr("height", height)
.attr("width", width)
.attr("rx", 10)
.attr("ry", 10)
.attr("rx", radiusx)
.attr("ry", radiusy)
.attr("x", 0);
var progress_front = circle
.append("rect")
.attr("fill", color)
.attr("fill-opacity", 1)
.attr("height", 20)
.attr("height", height)
.attr("width", 0)
.attr("rx", 10)
.attr("ry", 10)
.attr("rx", radiusx)
.attr("ry", radiusy)
.attr("x", 0);
var labelText = circle
@ -1834,7 +1837,7 @@ function progress_bar_d3(
.style("font-weight", "bold")
.style("font-size", 14)
.attr("text-anchor", "middle")
.attr("dy", "-10");
.attr("dy", (height - height / 2) / 4);
function updateProgress(bar_progress) {
var percent_value = Number(bar_progress * 100);
@ -1842,8 +1845,11 @@ function progress_bar_d3(
progress_front.attr("width", width * bar_progress);
}
if (transition == 0) {
var bar_progress = endPercent;
updateProgress(bar_progress);
} else {
var bar_progress = startPercent;
(function loops() {
updateProgress(bar_progress);
@ -1854,6 +1860,7 @@ function progress_bar_d3(
}
})();
}
}
function progress_bubble_d3(
recipient,

View File

@ -1,5 +1,49 @@
/* global jQuery */
/* global $ */
/* global context_minimap */
/* global minimap_w */
/* global minimap_h */
/* global minimap_relation */
/* global graph */
/* global translation */
/* global scale */
/* global width_svg */
/* global height_svg */
/* global networkmap_dimensions */
/* global node_radius */
/* global holding_area_dimensions */
/* global networkmap_id */
/* global enterprise_installed */
/* global force */
/* global layer_graph_nodes */
/* global layer_graph_links */
/* global ellipsize */
/* global d3 */
/* global dialog_node_edit_title */
/* global click_menu_position_svg */
/* global show_labels:true */
/* global show_minimap:true */
/* global layer_graph */
/* global zoom_obj */
/* global disabled_drag_zoom */
/* global scale:true */
/* global link */
/* global siblingCount:true */
/* global xRotation:true */
/* global largeArc:true */
/* global node */
/* exported delete_link */
/* exported update_fictional_node */
/* exported update_node_name */
/* exported change_shape */
/* exported add_agent_node_from_the_filter_group */
/* exported hide_labels */
/* exported toggle_minimap */
/* exported over_node */
function draw_minimap() {
//Clean the canvas
// Clean the canvas.
context_minimap.clearRect(0, 0, minimap_w, minimap_h);
context_minimap.beginPath();
@ -20,6 +64,9 @@ function draw_minimap() {
jQuery.each(graph.nodes, function(key, value) {
if (typeof value == "undefined") return;
var center_orig_x;
var center_orig_y;
context_minimap.beginPath();
//Paint the item
if (graph.nodes.length > 100) {
@ -36,7 +83,7 @@ function draw_minimap() {
context_minimap.arc(center_orig_x, center_orig_y, 2, 0, Math.PI * 2, false);
//Check if the pandora point
if (value.id_agent == -1) {
if (value.type == 2) {
context_minimap.fillStyle = "#364D1F";
} else {
context_minimap.fillStyle = "#000";
@ -96,11 +143,11 @@ function inner_minimap_box(param_x, param_y) {
return false;
}
function set_center(id, event) {
pos_x = width_svg / 2 - translation[0] / scale;
pos_y = height_svg / 2 - translation[1] / scale;
function set_center(id) {
var pos_x = width_svg / 2 - translation[0] / scale;
var pos_y = height_svg / 2 - translation[1] / scale;
var params = [];
params.push("set_center=1");
params.push("id=" + id);
params.push("x=" + pos_x);
@ -111,11 +158,7 @@ function set_center(id, event) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
success: function(data) {
if (data["correct"]) {
}
}
url: "ajax.php"
});
}
@ -164,7 +207,7 @@ function delete_link(
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
var found = -1;
@ -222,7 +265,7 @@ function update_fictional_node(id_db_node) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
$("#dialog_node_edit").dialog("close");
@ -262,7 +305,7 @@ function update_node_name(id_db_node) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
$("#dialog_node_edit").dialog("close");
@ -308,13 +351,13 @@ function change_shape(id_db_node) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
$("#shape_icon_in_progress").css("display", "none");
if (data["correct"]) {
$("#shape_icon_correct").css("display", "");
count = graph.nodes.length;
var count = graph.nodes.length;
jQuery.each(graph.nodes, function(i, element) {
if (element.id_db == id_db_node) {
@ -585,7 +628,7 @@ function update_link(row_index, id_link) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
$(".edit_icon_progress_" + row_index).css("display", "none");
@ -607,12 +650,10 @@ function update_link(row_index, id_link) {
"']"
).prop("selected", true);
var id = "";
var index = -1;
$.each(graph.links, function(j, link) {
if (link["id_db"] == id_link) {
index = j;
id = String(id_link);
}
});
@ -706,7 +747,7 @@ function move_to_networkmap(node) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
window.location =
@ -726,6 +767,7 @@ function edit_node(data_node, dblClick) {
//Only select one node
var selection = d3.selectAll(".node_selected");
var id;
if (selection[0].length == 1) {
edit_node = selection[0].pop();
@ -746,12 +788,12 @@ function edit_node(data_node, dblClick) {
.select(edit_node)
.attr("id")
.replace("id_node_", "");
id_networkmap_lenght = networkmap_id.toString().length;
id_node_length = id.length - id_networkmap_lenght;
var id_networkmap_lenght = networkmap_id.toString().length;
var id_node_length = id.length - id_networkmap_lenght;
id = id.substring(0, id_node_length);
node_selected = graph.nodes[id];
var node_selected = graph.nodes[id];
selected_links = get_relations(node_selected);
var selected_links = get_relations(node_selected);
$(
"select[name='shape'] option[value='" + node_selected.shape + "']"
@ -779,7 +821,7 @@ function edit_node(data_node, dblClick) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
$("#node_details-0-1").html(
'<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' +
@ -795,7 +837,7 @@ function edit_node(data_node, dblClick) {
addresses += data["adressess"][i] + "<br>";
}
} else {
for (address in data["adressess"]) {
for (var address in data["adressess"]) {
addresses += address + "<br>";
}
}
@ -826,7 +868,7 @@ function edit_node(data_node, dblClick) {
); // It doesn't eval the possible XSS so it's ok
$("#dialog_node_edit").dialog("open");
if (node_selected.id_agent == undefined || node_selected.id_agent == -2) {
if (node_selected.id_agent == undefined || node_selected.type == 3) {
//Fictional node
$("#node_options-fictional_node_name").css("display", "");
$("input[name='edit_name_fictional_node']").val(node_selected.text); // It doesn't eval the possible XSS so it's ok
@ -868,7 +910,7 @@ function get_interface_data_to_table(node_selected, selected_links) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data.length == 0) {
$("#interface_information")
@ -880,10 +922,11 @@ function get_interface_data_to_table(node_selected, selected_links) {
);
} else {
jQuery.each(data, function(j, interface) {
var interf_graph;
if (interface["graph"] == "") {
var interf_graph = "--";
interf_graph = "--";
} else {
var interf_graph = interface["graph"];
interf_graph = interface["graph"];
}
$("#interface_information")
.find("tbody")
@ -955,7 +998,7 @@ function load_interfaces(selected_links) {
type: "POST",
async: true,
cache: false,
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
$(
@ -1075,7 +1118,7 @@ function add_node() {
}
function add_agent_node_from_the_filter_group() {
agents = $("select[name='agents_filter_group']").val();
var agents = $("select[name='agents_filter_group']").val();
add_agent_node(agents);
}
@ -1122,7 +1165,7 @@ function add_agent_node(agents) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
$("#agent_name").val("");
@ -1210,24 +1253,17 @@ function add_agent_node(agents) {
var temp_node = {};
temp_node["id"] = graph.nodes.length;
temp_node["id_db"] = data["id_node"];
temp_node["id_agent"] = data["id_agent"];
temp_node["id_db"] = graph.nodes.length;
temp_node["id_agent"] = id_agent;
temp_node["id_module"] = "";
temp_node["px"] = data["x"];
temp_node["py"] = data["y"];
temp_node["x"] = data["x"];
temp_node["y"] = data["y"];
temp_node["px"] = x;
temp_node["py"] = y;
temp_node["x"] = x;
temp_node["y"] = y;
temp_node["z"] = 0;
temp_node["fixed"] = true;
temp_node["type"] = 0;
temp_node["color"] = data["status"];
temp_node["shape"] = data["shape"];
temp_node["text"] = data["text"];
temp_node["image_url"] = data["image_url"];
temp_node["image_width"] = data["width"];
temp_node["image_height"] = data["height"];
temp_node["map_id"] = data["map_id"];
temp_node["state"] = data["state"];
temp_node["map_id"] = networkmap_id;
graph.nodes.push(temp_node);
}
@ -1320,9 +1356,10 @@ function delete_nodes() {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
var found = -1;
do {
found = -1;
jQuery.each(graph.links, function(i, element) {
@ -1600,7 +1637,7 @@ function set_positions_graph() {
}
function over_node(d) {
over = d3.select("#id_node_" + d.id + networkmap_id).classed("node_over");
var over = d3.select("#id_node_" + d.id + networkmap_id).classed("node_over");
in_a_node = !in_a_node;
@ -1644,7 +1681,8 @@ function clear_selection() {
function update_networkmap() {
if (enterprise_installed) {
node.each(function(d) {
if (d.id_agent != -1) {
// Do not update Pandora FMS node.
if (d.type != 2) {
var params = [];
params.push("update_node_color=1");
params.push("id=" + d.id_db);
@ -1656,7 +1694,7 @@ function update_networkmap() {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
d3.select(
"#id_node_" + d.id + networkmap_id + " .node_shape"
@ -1668,7 +1706,7 @@ function update_networkmap() {
link.each(function(d) {
if (d.id_module_start != 0 || d.id_module_end != 0) {
if (d.id_module_start != 0) {
if (d.id_module_start && d.id_module_start > 0) {
var params = [];
params.push("module_get_status=1");
params.push("page=operation/agentes/pandora_networkmap.view");
@ -1677,7 +1715,7 @@ function update_networkmap() {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
d3.selectAll(".id_module_start_" + d.id_module_start).attr(
"marker-start",
@ -1691,7 +1729,7 @@ function update_networkmap() {
});
}
if (d.id_module_end != 0) {
if (d.id_module_end && d.id_module_end > 0) {
var params = [];
params.push("module_get_status=1");
params.push("page=operation/agentes/pandora_networkmap.view");
@ -1700,7 +1738,7 @@ function update_networkmap() {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
d3.selectAll(".id_module_end_" + d.id_module_end).attr(
"marker-end",
@ -1859,7 +1897,7 @@ function show_menu(item, data) {
icon: "interface_link_children",
disabled: function() {
if (enterprise_installed) {
if (data.type == 3) {
if (data.type == 3 || data.type == 2) {
return true;
} else {
return false;
@ -1929,7 +1967,7 @@ function show_menu(item, data) {
icon: "interface_link_parent",
disabled: function() {
if (enterprise_installed) {
if (data.type == 3) {
if (data.type == 3 || data.type == 2) {
return true;
} else {
return false;
@ -2015,7 +2053,8 @@ function show_menu(item, data) {
};
}
if (data.id_agent != -1) {
// Avoid deletion if Pandora FMS node.
if (data.type != 2) {
items_list["delete"] = {
name: delete_menu,
icon: "delete",
@ -2141,6 +2180,7 @@ function show_menu(item, data) {
};
}
if (typeof $.contextMenu == "function") {
$.contextMenu("destroy");
$.contextMenu({
disabled: false,
@ -2148,15 +2188,18 @@ function show_menu(item, data) {
// define the elements of the menu
items: items_list
});
}
break;
}
//Force to show in the mouse position
if (typeof $("#networkconsole_" + networkmap_id).contextMenu == "function") {
$("#networkconsole_" + networkmap_id).contextMenu({
x: mouse[0],
y: mouse[1]
});
}
}
function add_interface_link(data_parent) {
var selection = d3.selectAll(".node_children");
@ -2205,7 +2248,7 @@ function add_interface_link(data_parent) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
var parent_name = data_parent.text;
var child_name = child_data.text;
@ -2250,32 +2293,32 @@ function add_interface_link_js() {
cancel_set_parent_interface();
$("#dialog_interface_link").dialog("close");
source_value = $("#interface_source_select").val();
source_text = $("#interface_source_select")
var source_value = $("#interface_source_select").val();
var source_text = $("#interface_source_select")
.find("option:selected")
.text();
target_value = $("#interface_target_select").val();
target_text = $("#interface_target_select")
var target_value = $("#interface_target_select").val();
var target_text = $("#interface_target_select")
.find("option:selected")
.text();
var params = [];
params.push("add_interface_relation=1");
params.push("id=" + networkmap_id);
params.push("source_value=" + source_value);
params.push("target_value=" + target_value);
params.push("source_text=" + source_text);
params.push("target_text=" + target_text);
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
jQuery.ajax({
data: params.join("&"),
data: {
page: "enterprise/operation/agentes/pandora_networkmap.view",
add_interface_relation: 1,
id: networkmap_id,
source_value: source_value,
target_value: target_value,
source_text: source_text,
target_text: target_text
},
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
var temp_link = {};
temp_link["id"] = graph.links.length;
temp_link["status_start"] = "0";
temp_link["status_end"] = "0";
@ -2284,8 +2327,9 @@ function add_interface_link_js() {
if (data["type_source"] == 1) {
temp_link["arrow_start"] = "module";
temp_link["id_module_start"] = source_value;
temp_link["status_start"] = data["status"];
temp_link["link_color"] = data["status"] == "1" ? "#FC4444" : "#999";
temp_link["status_start"] = data["status_start"];
temp_link["link_color"] =
data["status_start"] == "1" ? "#FC4444" : "#999";
} else {
temp_link["arrow_start"] = "";
temp_link["id_agent_start"] = source_value;
@ -2294,8 +2338,9 @@ function add_interface_link_js() {
if (data["type_target"] == 1) {
temp_link["arrow_end"] = "module";
temp_link["id_module_end"] = target_value;
temp_link["status_end"] = data["status"];
temp_link["link_color"] = data["status"] == "1" ? "#FC4444" : "#999";
temp_link["status_end"] = data["status_end"];
temp_link["link_color"] =
data["status_end"] == "1" ? "#FC4444" : "#999";
} else {
temp_link["arrow_end"] = "";
temp_link["id_agent_end"] = target_value;
@ -2325,8 +2370,8 @@ function add_interface_link_js() {
}
function refresh_holding_area() {
holding_pos_x = d3.select("#holding_area_" + networkmap_id).attr("x");
holding_pos_y = d3.select("#holding_area_" + networkmap_id).attr("y");
var holding_pos_x = d3.select("#holding_area_" + networkmap_id).attr("x");
var holding_pos_y = d3.select("#holding_area_" + networkmap_id).attr("y");
var pos_x = parseInt(holding_pos_x) + parseInt(node_radius);
var pos_y = parseInt(holding_pos_y) + parseInt(node_radius);
@ -2342,7 +2387,7 @@ function refresh_holding_area() {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
window.holding_area = data["holding_area"];
@ -2510,28 +2555,29 @@ function proceed_to_restart_map() {
text: ok_button,
click: function() {
$(this).dialog("close");
var new_elements = [];
new_elements[0] = $("#text-name").val();
new_elements[1] = $("#id_group").val();
new_elements[2] = $("#text-node_radius").val();
new_elements[3] = $("#textarea_description").val();
new_elements[4] = $("input[name=source]:checked").val();
if (new_elements[4] == "group") {
new_elements[5] = $("#checkbox-dont_show_subgroups").is(":checked");
} else if (new_elements[4] == "recon_task") {
new_elements[5] = $("#recon_task_id").val();
} else {
new_elements[5] = $("#text-ip_mask").val();
var data = {
params: {
name: $("#text-name").val(),
id_group: $("#id_group").val(),
node_radius: $("#text-node_radius").val(),
description: $("#textarea_description").val(),
source: $("input[name=source]:checked").val(),
dont_show_subgroups: $("#checkbox-dont_show_subgroups").is(
":checked"
),
recon_task_id: $("#recon_task_id").val(),
ip_mask: $("#text-ip_mask").val(),
generation_method: $("#method").val(),
pos_x: $("#text-pos_x").val(),
pos_y: $("#text-pos_y").val(),
scale_z: $("#text-scale_z").val(),
node_sep: $("#text-node_sep").val(),
mindist: $("#text-mindist").val(),
rank_sep: $("#text-rank_sep").val(),
kval: $("#text-kval").val()
}
new_elements[6] = $("#method").val();
new_elements[7] = $("#text-pos_x").val();
new_elements[8] = $("#text-pos_y").val();
new_elements[9] = $("#text-scale_z").val();
new_elements[10] = $("#text-node_sep").val();
new_elements[11] = $("#text-mindist").val();
new_elements[12] = $("#text-rank_sep").val();
new_elements[13] = $("#text-kval").val();
reset_map_from_form(new_elements);
};
reset_map_from_form(data);
}
},
{
@ -2551,32 +2597,30 @@ function proceed_to_restart_map() {
data: params.join("&"),
dataType: "html",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
$("#restart_map_form").html(data);
$("#restart_map_form").dialog("open");
$("#restart_map_form")
.html(data)
.dialog("open");
}
});
}
function reset_map_from_form(new_elements) {
var params = [];
params.push("reset_map=1");
params.push("map_id=" + networkmap_id);
params.push("elems[]=" + new_elements);
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
var data = new_elements;
data.map_id = networkmap_id;
data.reset_map = 1;
data.page = "enterprise/operation/agentes/pandora_networkmap.view";
jQuery.ajax({
data: params.join("&"),
data: data,
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
success: function(data) {
if (!data["error"]) {
url: "ajax.php",
success: function(d) {
window.location =
"index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab=view&id_networkmap=" +
networkmap_id;
}
}
});
}
@ -2636,7 +2680,7 @@ function set_parent(parent_data) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
//Add the relationship and paint
@ -2727,23 +2771,25 @@ function init_drag_and_drop() {
var selection = d3.selectAll(".node_selected");
if (enterprise_installed) {
holding_pos_x = d3.select("#holding_area_" + networkmap_id).attr("x");
holding_pos_y = d3.select("#holding_area_" + networkmap_id).attr("y");
var holding_pos_x = d3
.select("#holding_area_" + networkmap_id)
.attr("x");
var holding_pos_y = d3
.select("#holding_area_" + networkmap_id)
.attr("y");
delete d.raw_text;
selection.each(function(d) {
var params = [];
params.push("update_node=1");
params.push("node=" + JSON.stringify(d));
params.push("x=" + holding_pos_x);
params.push("y=" + holding_pos_y);
params.push(
"page=enterprise/operation/agentes/pandora_networkmap.view"
);
jQuery.ajax({
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
data: {
node: JSON.stringify(d),
x: holding_pos_x,
y: holding_pos_y,
update_node: 1,
page: "enterprise/operation/agentes/pandora_networkmap.view"
},
success: function(data) {
if (d.state == "holding_area") {
//It is out the holding area
@ -2777,7 +2823,7 @@ function init_drag_and_drop() {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
$("#open_version_dialog").dialog();
@ -2840,7 +2886,7 @@ function add_fictional_node() {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
$("#dialog_node_add").dialog("close");
@ -2909,6 +2955,13 @@ function init_graph(parameter_object) {
window.height_svg =
$(window).height() - $("#menu_tab_frame_view").height() - 20; // 20 of margin
}
if (!window.height_svg) {
window.height_svg = $("#networkconsole_" + networkmap_id).height();
}
if (typeof parameter_object.font_size != "undefined") {
window.font_size = parameter_object.font_size;
}
window.refresh_period = 5 * 1000; //milliseconds
if (typeof parameter_object.refresh_period != "undefined") {
@ -3922,6 +3975,10 @@ function draw_elements_graph() {
var font_size = node_radius / 1.5;
if (typeof window.font_size != "undefined") {
font_size = window.font_size;
}
node_temp
.append("text")
.attr("class", "node_text")
@ -3991,7 +4048,7 @@ function choose_group_for_show_agents() {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "ajax.php"),
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
$("#agents_filter_group").html("");
@ -4013,162 +4070,6 @@ function choose_group_for_show_agents() {
'<option value="-1">' + translation_none + "</option>"
);
$("#spinner_group").css("display", "none");
function show_networkmap_node(id_agent_param, refresh_state) {
id_agent = id_agent_param;
canvas = $("#node_info");
context_popup = canvas[0].getContext("2d");
dirty_popup = true;
self.setInterval("check_popup_modification()", 1000 / 30);
$("#node_info").mousemove(function(event) {
var x = event.pageX - $("#node_info").offset().left;
var y = event.pageY - $("#node_info").offset().top;
module_inner = inner_module(x, y);
if (module_inner != null) {
document.body.style.cursor = "pointer";
} else {
document.body.style.cursor = "default";
}
});
$("#node_info").mousedown(function(event) {
var x = event.pageX - $("#node_info").offset().left;
var y = event.pageY - $("#node_info").offset().top;
if (module_inner != null) {
show_tooltip(module_inner, x, y);
}
event.stopPropagation();
return false;
});
$("#node_info").mouseup(function(event) {
var x = event.pageX - $("#node_info").offset().left;
var y = event.pageY - $("#node_info").offset().top;
drag = false;
drag_x = 0;
drag_y = 0;
dirty_popup = true;
document.body.style.cursor = "default";
module_inner = null;
event.stopPropagation();
return false;
});
$("#node_info").mouseout(function(event) {
var x = event.pageX - $("#node_info").offset().left;
var y = event.pageY - $("#node_info").offset().top;
drag = false;
drag_x = 0;
drag_y = 0;
dirty_popup = true;
document.body.style.cursor = "default";
module_inner = null;
event.stopPropagation();
return false;
});
$(window).resize(function() {
function show_networkmap_node(id_agent_param, refresh_state) {
id_agent = id_agent_param;
canvas = $("#node_info");
context_popup = canvas[0].getContext("2d");
dirty_popup = true;
self.setInterval("check_popup_modification()", 1000 / 30);
$("#node_info").mousemove(function(event) {
var x = event.pageX - $("#node_info").offset().left;
var y = event.pageY - $("#node_info").offset().top;
module_inner = inner_module(x, y);
if (module_inner != null) {
document.body.style.cursor = "pointer";
} else {
document.body.style.cursor = "default";
}
});
$("#node_info").mousedown(function(event) {
var x = event.pageX - $("#node_info").offset().left;
var y = event.pageY - $("#node_info").offset().top;
if (module_inner != null) {
show_tooltip(module_inner, x, y);
}
event.stopPropagation();
return false;
});
$("#node_info").mouseup(function(event) {
var x = event.pageX - $("#node_info").offset().left;
var y = event.pageY - $("#node_info").offset().top;
drag = false;
drag_x = 0;
drag_y = 0;
dirty_popup = true;
document.body.style.cursor = "default";
module_inner = null;
event.stopPropagation();
return false;
});
$("#node_info").mouseout(function(event) {
var x = event.pageX - $("#node_info").offset().left;
var y = event.pageY - $("#node_info").offset().top;
drag = false;
drag_x = 0;
drag_y = 0;
dirty_popup = true;
document.body.style.cursor = "default";
module_inner = null;
event.stopPropagation();
return false;
});
$(window).resize(function() {
pos_scroll = Math.floor(
$("#content_node_info").width() / 2
);
$("#content_node_info").scrollLeft(pos_scroll);
dirty_popup = true;
check_popup_modification();
});
}
pos_scroll = Math.floor($("#content_node_info").width() / 2);
$("#content_node_info").scrollLeft(pos_scroll);
dirty_popup = true;
check_popup_modification();
});
}
}
}
});
@ -4213,7 +4114,7 @@ function get_status_node() {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "../../../ajax.php"),
url: "../../../ajax.php",
success: function(data) {
if (data["correct"]) {
color_status_node = data["status_agent"];
@ -4235,7 +4136,7 @@ function get_status_module() {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "../../../ajax.php"),
url: "../../../ajax.php",
success: function(data) {
if (data["correct"]) {
modules[data["id"]].status_color = data["status_color"];
@ -4333,7 +4234,7 @@ function show_tooltip_content(id) {
data: params.join("&"),
dataType: "json",
type: "POST",
url: (action = "../../../ajax.php"),
url: "../../../ajax.php",
success: function(data) {
if (data["correct"]) {
$("#tooltip").html(data["content"]);
@ -4353,7 +4254,7 @@ function show_tooltip(id, x, y) {
jQuery.ajax({
data: params1.join("&"),
type: "POST",
url: (action = "../../../ajax.php"),
url: "../../../ajax.php",
success: function(data) {
$("#tooltip").html(data);
$("#tooltip").css("display", "");

View File

@ -834,12 +834,10 @@ function add_macro_field(macro, row_model_id) {
$("#" + row_id)
.children()
.eq(1)
.children()
.attr("id", "text-" + macro_macro);
$("#" + row_id)
.children()
.eq(1)
.children()
.attr("name", macro_macro);
macro_field_hide = false;
@ -859,13 +857,11 @@ function add_macro_field(macro, row_model_id) {
$("#" + row_id)
.children()
.eq(1)
.children()
.attr("type", "password");
}
$("#" + row_id)
.children()
.eq(1)
.children()
.val(macro_value);
$("#" + row_id).show();
@ -1121,3 +1117,90 @@ function delete_macro(num) {
// Do not decrease the macro counter or new macros may overlap existing ones!
}
function get_explanation_recon_script(id, id_rt, url) {
var xhrManager = function() {
var manager = {};
manager.tasks = [];
manager.addTask = function(xhr) {
manager.tasks.push(xhr);
};
manager.stopTasks = function() {
while (manager.tasks.length > 0) manager.tasks.pop().abort();
};
return manager;
};
var taskManager = new xhrManager();
// Stop old ajax tasks.
taskManager.stopTasks();
// Show the spinners.
$("#textarea_explanation").hide();
$("#spinner_layout").show();
var xhr = jQuery.ajax({
data: {
page: "enterprise/include/ajax/hostDevices.ajax",
get_explanation: 1,
id: id,
id_rt: id_rt
},
url: url,
type: "POST",
dataType: "text",
complete: function(xhr, textStatus) {
$("#spinner_layout").hide();
},
success: function(data, textStatus, xhr) {
$("#textarea_explanation").val(data);
$("#textarea_explanation").show();
},
error: function(xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
taskManager.addTask(xhr);
// Delete all the macro fields.
$(".macro_field").remove();
$("#spinner_recon_script").show();
var xhr = jQuery.ajax({
data: {
page: "enterprise/include/ajax/hostDevices.ajax",
get_recon_script_macros: 1,
id: id,
id_rt: id_rt
},
url: url,
type: "POST",
dataType: "json",
complete: function(xhr, textStatus) {
$("#spinner_recon_script").hide();
forced_title_callback();
},
success: function(data, textStatus, xhr) {
if (data.array !== null) {
$("#hidden-macros").val(data.base64);
jQuery.each(data.array, function(i, macro) {
if (macro.desc != "") {
add_macro_field(macro, "table_recon-macro");
}
});
}
},
error: function(xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
taskManager.addTask(xhr);
}

View File

@ -0,0 +1,106 @@
/*
global $
global jQuery
*/
/**
* Function for create modal with progress task
* and recalculate 3 second.
* @param {int} id
* @param {string} name
*/
function progress_task_list(id, title) {
var timeoutRef = null;
var xhr = null;
var $elem = $("#progress_task_" + id);
$elem
.hide()
.empty()
.dialog({
title: title,
draggable: true,
modal: false,
width: 600,
height: 420,
close: function() {
if (xhr != null) xhr.abort();
if (timeoutRef != null) clearTimeout(timeoutRef);
}
});
// Function var.
var handleFetchTaskList = function(err, data) {
if (err) {
// TODO: Show info about the problem.
}
$elem.html(data.html);
if (!$elem.dialog("isOpen")) $elem.dialog("open");
if (data.status != -1) {
timeoutRef = setTimeout(function() {
xhr = fetchTaskList(id, handleFetchTaskList);
}, 3000);
}
};
xhr = fetchTaskList(id, handleFetchTaskList);
}
/**
* Function that performs ajax request to return
* the progress of the task.
* @param {int} id Id task.
* @param {function} callback Function callback.
*/
function fetchTaskList(id, callback) {
return jQuery.ajax({
data: {
page: "include/ajax/task_list.ajax",
progress_task_discovery: 1,
id: id
},
type: "POST",
url: "ajax.php",
dataType: "json",
success: function(data) {
callback(null, data);
},
error: function() {
callback(new Error("cannot fetch the list"));
}
});
}
function show_map(id, name) {
$("#map_task")
.empty()
.hide()
.append("<p>Loading map</p>")
.dialog({
title: "Task: " + name,
resizable: true,
draggable: true,
modal: false,
width: 1280,
height: 700
})
.show();
jQuery.ajax({
data: {
page: "include/ajax/task_list.ajax",
showmap: 1,
id: id
},
type: "POST",
url: "ajax.php",
dataType: "html",
success: function(data) {
$("#map_task")
.empty()
.append(data);
}
});
}

View File

@ -58,7 +58,7 @@
overflow-y: scroll;
}
#cluster_map {
#simple_map {
border: 1px solid lightgray;
width: 900px;
height: 500px;

View File

@ -49,7 +49,6 @@ div.data_container:hover {
h1.wizard {
padding: 0;
margin: 0;
margin-top: -1.25em;
}
h1.wizard a {
margin-left: -20px;
@ -65,7 +64,6 @@ h1.wizard a:hover {
div.arrow_box {
display: inline-block;
position: relative;
background: #ccc;
color: #888;
padding: 1.3em;
margin-left: 20px;
@ -73,16 +71,6 @@ div.arrow_box {
padding-left: 3em;
}
.arrow_box:before {
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
z-index: 1;
}
.arrow_box.selected {
background: #424242;
color: #ccc;
@ -111,3 +99,68 @@ div.arrow_box:before {
.arrow_box:hover {
color: #000;
}
/*
* Breadcrum
*/
#menu_tab_frame_view_bc {
display: flex;
justify-content: space-between;
border-bottom: 2px solid #82b92e;
max-height: 70px;
min-height: 55px;
width: 100%;
padding-right: 0px;
margin-left: 0px !important;
margin-bottom: 20px;
height: 55px;
box-sizing: border-box;
background-color: #fafafa;
border-top-right-radius: 7px;
border-top-left-radius: 7px;
box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.1);
flex-direction: column;
}
#menu_tab_frame_view_bc .breadcrumbs_container {
align-self: flex-start;
}
.breadcrumbs_container {
padding-left: 10px;
padding-top: 4px;
text-indent: 0.25em;
}
.breadcrumb_link {
color: #848484;
font-size: 10pt !important;
font-family: "lato-bolder", "Open Sans", sans-serif !important;
text-decoration: none !important;
}
span.breadcrumb_link {
color: #d0d0d0;
font-size: 12pt !important;
}
.breadcrumb_link.selected {
color: #95b750;
}
.breadcrumb_link.selected:hover {
color: #95b750;
}
.breadcrumb_link:hover {
color: #95b750;
}
.form_grid_items {
overflow: hidden;
}
.form_grid_items .form_grid_item {
float: left;
box-sizing: border-box;
padding: 10px;
}

View File

@ -72,6 +72,7 @@ div.new_task_cluster > div {
}
#description_task {
font-size: 12px;
line-height: 1.8em;
}
#fuerte {

View File

@ -107,61 +107,61 @@
background-position: 4px 2px;
}
.context-menu-item.icon-edit {
background-image: url(../../images/page_white_edit.png);
background-image: url(../../../images/page_white_edit.png);
}
.context-menu-item.icon-cut {
background-image: url(../../images/cut.png);
background-image: url(../../../images/cut.png);
}
.context-menu-item.icon-copy {
background-image: url(../../images/page_white_copy.png);
background-image: url(../../../images/page_white_copy.png);
}
.context-menu-item.icon-paste {
background-image: url(../../images/page_white_paste.png);
background-image: url(../../../images/page_white_paste.png);
}
.context-menu-item.icon-delete {
background-image: url(../../images/delete.png);
background-image: url(../../../images/delete.png);
}
.context-menu-item.icon-add {
background-image: url(../../images/page_white_add.png);
background-image: url(../../../images/page_white_add.png);
}
.context-menu-item.icon-quit {
background-image: url(../../images/door.png);
background-image: url(../../../images/door.png);
}
.context-menu-item.icon-refresh {
background-image: url(../../images/refresh.png);
background-image: url(../../../images/refresh.png);
}
.context-menu-item.icon-center {
background-image: url(../../images/set_center.png);
background-image: url(../../../images/set_center.png);
}
.context-menu-item.icon-details {
background-image: url(../../images/show_details.png);
background-image: url(../../../images/show_details.png);
}
.context-menu-item.icon-children {
background-image: url(../../images/children.png);
background-image: url(../../../images/children.png);
}
.context-menu-item.icon-cancel_set_parent {
background-image: url(../../images/link_delete.png);
background-image: url(../../../images/link_delete.png);
}
.context-menu-item.icon-set_parent {
background-image: url(../../images/father.png);
background-image: url(../../../images/father.png);
}
.context-menu-item.icon-add_node {
background-image: url(../../images/add.png);
background-image: url(../../../images/add.png);
}
.context-menu-item.icon-refresh_holding_area {
background-image: url(../../images/refresh_holding_area.png);
background-image: url(../../../images/refresh_holding_area.png);
}
.context-menu-item.icon-restart_map {
background-image: url(../../images/reset.png);
background-image: url(../../../images/reset.png);
}
.context-menu-item.icon-interface_link_children {
background-image: url(../../images/icono_link_hijo.png);
background-image: url(../../../images/icono_link_hijo.png);
}
.context-menu-item.icon-interface_link_parent {
background-image: url(../../images/icono_link_padre.png);
background-image: url(../../../images/icono_link_padre.png);
}
.context-menu-item.icon-interface_link_cancel {
background-image: url(../../images/link_abortar.png);
background-image: url(../../../images/link_abortar.png);
}
/* vertically align inside labels */

View File

@ -31,8 +31,7 @@
.operation .menu_icon ul.submenu > li,
.godmode .menu_icon ul.submenu > li {
background-color: #282828;
padding-left: 10px;
padding-right: 10px;
padding-left: 1.5em;
}
.menu ul {
@ -58,7 +57,7 @@ li:hover ul {
.submenu_text {
margin-left: 0px;
width: 100%;
color: #9ca4a6;
color: #b9b9b9;
font-family: "Open Sans", sans-serif;
font-size: 9.4pt;
}
@ -71,21 +70,20 @@ li:hover ul {
margin: 0px 0px 0px 0px;
position: absolute;
z-index: 999;
width: 214px;
width: 240px;
}
.submenu2 {
position: absolute;
z-index: 999;
left: 214px;
width: 214px;
left: 240px;
width: 240px;
}
.sub_subMenu {
font-weight: normal !important;
background-color: #202020;
padding-left: 10px;
padding-right: 10px;
padding-left: 1.5em;
}
.sub_subMenu.selected {
@ -291,7 +289,7 @@ ul li a:hover {
}
.operation {
background-color: #343434 !important;
background-color: #3d3d3d !important;
padding-top: 20px !important;
}
@ -468,11 +466,11 @@ ul li a:hover {
}
.header_table_classic {
padding-left: 250px !important; /* 215 + 35 */
padding-left: 235px !important; /* 215 + 35 */
}
.header_table_collapsed {
padding-left: 95px !important; /* 60 + 35 */
padding-left: 80px !important; /* 60 + 35 */
}
.title_menu_classic {

View File

@ -0,0 +1,35 @@
.node {
stroke: #fff;
stroke-width: 1px;
}
.node_over {
stroke: #999;
}
.node_selected {
stroke: #343434;
stroke-width: 5;
}
.node_children {
stroke: #00f;
}
.link {
stroke-opacity: 0.6;
}
.link_over {
stroke: #000;
stroke-opacity: 0.6;
}
.holding_area {
stroke: #0f0;
stroke-dasharray: 12, 3;
}
.holding_area_link {
stroke-dasharray: 12, 3;
}

View File

@ -404,10 +404,10 @@ div#page {
background-image: none;
clear: both;
width: auto;
padding-top: 20px !important;
padding-top: 5px !important;
padding-left: 60px; /* This is overwritten by the classic menu (215px)*/
padding-right: 35px;
margin-left: 35px;
margin-left: 20px;
}
body.pure {
@ -1266,7 +1266,7 @@ div.title_line {
margin-bottom: 20px;
height: 50px;
box-sizing: border-box;
background-color: #fff;
background-color: #fafafa;
border-top-right-radius: 7px;
border-top-left-radius: 7px;
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.1);
@ -1305,6 +1305,7 @@ div.title_line {
text-decoration: none;
padding: 0px;
margin: 0px;
padding-top: 6px;
}
#menu_tab li.nomn:hover a,
#menu_tab li:hover ul a:hover {
@ -1410,7 +1411,8 @@ div#agent_wizard_subtabs {
#menu_tab_left li a,
#menu_tab_left li span {
color: #343434;
font-size: 14pt;
font-size: 16pt;
line-height: 16pt;
}
/*
@ -2019,6 +2021,7 @@ div#pandora_logo_header {
#header_table_inner {
height: 60px;
min-width: 790px;
/*width: 100%;*/
display: flex;
align-items: center;
@ -3251,7 +3254,7 @@ div.div_groups_status {
}
#title_menu {
color: #9ca4a6;
color: #b9b9b9;
float: right;
width: 72%;
letter-spacing: 0pt;
@ -3267,16 +3270,15 @@ div.div_groups_status {
#menu_tab li.nomn,
#menu_tab li.nomn_high {
background-color: #fff;
padding-right: 3px;
padding-left: 3px;
padding-right: 8px;
padding-left: 8px;
padding-top: 6px;
font-weight: bold;
text-decoration: none;
font-size: 14px;
margin-top: 0;
min-width: 30px;
height: 29px;
height: 40px;
}
#menu_tab li:hover {
@ -3287,6 +3289,7 @@ div.div_groups_status {
#menu_tab li.nomn_high span {
color: #fff;
box-shadow: inset 0px 4px #82b92e;
background-color: #fff;
}
#menu_tab li.nomn img,
@ -4420,6 +4423,10 @@ div#dialog_messages table th:last-child {
font-weight: bold;
}
.notification-ball.notification-ball-new-messages:hover {
box-shadow: 0 0 3px #888;
}
.notification-ball-no-messages {
background-color: #82b92e;
cursor: pointer;
@ -4433,7 +4440,7 @@ div#dialog_messages table th:last-child {
border: #a5a5a5 solid 1px;
z-index: 900000;
position: absolute;
width: 400px;
width: 550px;
margin-top: -5px;
border-radius: 5px;
}
@ -4447,8 +4454,7 @@ div#dialog_messages table th:last-child {
border-width: 12px;
border-style: solid;
bottom: 100%;
left: 78%;
left: calc(78% - 2px);
left: calc(58% - 7px);
margin-left: -12px;
border-bottom-color: white;
}
@ -4741,8 +4747,8 @@ input:checked + .p-slider:before {
/* New white rounded boxes */
.white_box {
background-color: #fff;
border: 1px solid #d7d9da;
border-radius: 10px;
border: 1px solid #f3f3f3;
border-radius: 5px;
padding: 20px 50px;
}

View File

@ -0,0 +1,42 @@
/**
*
* Name: Default theme
*
* Extension to manage a list of gateways and the node address where they should
* point to.
*
* @category css
* @package Pandora FMS
* @subpackage Community
* @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.
* ============================================================================
*/
ul.progress_task_discovery {
width: 80%;
margin: 0 auto;
display: flex;
flex-direction: column;
}
ul.progress_task_discovery li span {
font-size: 9pt;
margin-left: 20px;
}

View File

@ -244,7 +244,6 @@ if (strlen($search) > 0) {
// Login process
if (! isset($config['id_user'])) {
// Clear error messages.
unset($_COOKIE['errormsg']);
setcookie('errormsg', null, -1);

View File

@ -504,8 +504,8 @@ function create_loading_tooltip(d, x, y) {
}
function show_tooltip(d) {
x = d3.event.clientX + 10;
y = d3.event.clientY + 10;
x = d3.event.clientX 100;
y = d3.event.clientY 100;
if (d.default_tooltip) {
create_loading_tooltip(d, x, y);

View File

@ -49,18 +49,18 @@ if ($new_networkmap) {
$id_group = 0;
$node_radius = 40;
$description = '';
$method = 'fdp';
$method = 'neato';
$recon_task_id = 0;
$source = 'group';
$ip_mask = '';
$dont_show_subgroups = false;
$dont_show_subgroups = 0;
$offset_x = '';
$offset_y = '';
$scale_z = 0.5;
$node_sep = 0.25;
$node_sep = 0.1;
$rank_sep = 1.0;
$mindist = 1.0;
$kval = 0.3;
$kval = 0.1;
}
$disabled_generation_method_select = false;
@ -330,7 +330,13 @@ if ($not_found) {
$table->data['source_data_ip_mask'][1] = html_print_input_text('ip_mask', $ip_mask, '', 20, 255, true, $disabled_source);
$table->data['source_data_dont_show_subgroups'][0] = __('Don\'t show subgroups:');
$table->data['source_data_dont_show_subgroups'][1] = html_print_checkbox('dont_show_subgroups', '1', $dont_show_subgroups, true, $disabled_source);
$table->data['source_data_dont_show_subgroups'][1] = html_print_checkbox(
'dont_show_subgroups',
'1',
$dont_show_subgroups,
true,
$disabled_source
);
$methods = [
'twopi' => 'radial',
@ -348,7 +354,7 @@ if ($not_found) {
$method,
'',
'',
'twopi',
'neato',
true,
false,
true,

View File

@ -30,7 +30,6 @@ if (!$networkmaps_read && !$networkmaps_write && !$networkmaps_manage) {
}
require_once 'include/functions_networkmap.php';
require_once 'include/functions_pandora_networkmap.php';
$new_networkmap = (bool) get_parameter('new_networkmap', false);
$save_networkmap = (bool) get_parameter('save_networkmap', false);
@ -45,8 +44,9 @@ $new_empty_networkmap = get_parameter('new_empty_networkmap', false);
if (enterprise_installed()) {
if ($new_empty_networkmap) {
if ($networkmaps_write || $networkmaps_manage) {
include $config['homedir'].'/enterprise/godmode/agentes/pandora_networkmap_empty.editor.php';
include 'pandora_networkmap_empty.editor.php';
enterprise_include(
'godmode/agentes/pandora_networkmap_empty.editor.php'
);
return;
}
}
@ -71,12 +71,15 @@ if (enterprise_installed()) {
$name = (string) get_parameter('name', '');
// Default size values
$width = 4000;
$height = 4000;
$width = $config['networkmap_max_width'];
$height = $config['networkmap_max_width'];
$method = (string) get_parameter('method', 'fdp');
$dont_show_subgroups = 0;
$dont_show_subgroups = (int) get_parameter_checkbox(
'dont_show_subgroups',
0
);
$node_radius = (int) get_parameter('node_radius', 40);
$description = get_parameter('description', '');
@ -126,7 +129,14 @@ if (enterprise_installed()) {
$id = $result;
define('_id_', $id);
if ($result !== false) {
$tab = 'view';
header(
'Location: '.ui_get_full_url(
'index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab='.$tab.'&id_networkmap='.$id
)
);
}
} else if ($update_empty_networkmap) {
$id_group = (int) get_parameter('id_group', 0);
@ -161,7 +171,10 @@ if (enterprise_installed()) {
$description = get_parameter('description', '');
$values['description'] = $description;
$dont_show_subgroups = 0;
$dont_show_subgroups = (int) get_parameter_checkbox(
'dont_show_subgroups',
0
);
$node_radius = (int) get_parameter('node_radius', 40);
$row = db_get_row('tmap', 'id', $id);
$filter = json_decode($row['filter'], true);
@ -189,9 +202,9 @@ if (enterprise_installed()) {
}
}
$result_txt = '';
// The networkmap doesn't exist yet
if ($new_networkmap || $save_networkmap) {
$result_txt = '';
if ($new_networkmap) {
if ($networkmaps_write || $networkmaps_manage) {
include 'pandora_networkmap.editor.php';
@ -226,8 +239,8 @@ if ($new_networkmap || $save_networkmap) {
$name = (string) get_parameter('name', '');
// Default size values
$width = 4000;
$height = 4000;
$width = $config['networkmap_max_width'];
$height = $config['networkmap_max_width'];
$method = (string) get_parameter('method', 'fdp');
@ -240,12 +253,15 @@ if ($new_networkmap || $save_networkmap) {
''
);
$source = (string) get_parameter('source', 'group');
$dont_show_subgroups = (int) get_parameter('dont_show_subgroups', 0);
$dont_show_subgroups = (int) get_parameter_checkbox(
'dont_show_subgroups',
0
);
$node_radius = (int) get_parameter('node_radius', 40);
$description = get_parameter('description', '');
$offset_x = get_parameter('pos_x');
$offset_y = get_parameter('pos_y');
$offset_x = get_parameter('pos_x', 0);
$offset_y = get_parameter('pos_y', 0);
$scale_z = get_parameter('scale_z', 0.5);
$node_sep = get_parameter('node_sep', '0.25');
@ -269,31 +285,31 @@ if ($new_networkmap || $save_networkmap) {
switch ($method) {
case 'twopi':
$values['generation_method'] = 2;
$values['generation_method'] = LAYOUT_RADIAL;
break;
case 'dot':
$values['generation_method'] = 1;
$values['generation_method'] = LAYOUT_FLAT;
break;
case 'circo':
$values['generation_method'] = 0;
$values['generation_method'] = LAYOUT_CIRCULAR;
break;
case 'neato':
$values['generation_method'] = 3;
$values['generation_method'] = LAYOUT_SPRING1;
break;
case 'fdp':
$values['generation_method'] = 4;
$values['generation_method'] = LAYOUT_SPRING2;
break;
case 'radial_dinamic':
$values['generation_method'] = 6;
$values['generation_method'] = LAYOUT_RADIAL_DYNAMIC;
break;
default:
$values['generation_method'] = 2;
$values['generation_method'] = LAYOUT_RADIAL;
break;
}
@ -349,11 +365,25 @@ if ($new_networkmap || $save_networkmap) {
$id = $result;
define('_id_', $id);
if ($result !== false) {
$tab = 'view';
if ($values['generation_method'] == 6) {
if ($values['generation_method'] == LAYOUT_RADIAL_DYNAMIC) {
$tab = 'r_dinamic';
define('_activeTab_', 'radial_dynamic');
$url = 'index.php?sec=network&sec2=operation/agentes/networkmap.dinamic&activeTab=radial_dynamic';
header(
'Location: '.ui_get_full_url(
$url.'&id_networkmap='.$id
)
);
} else {
$url = 'index.php?sec=network&sec2=operation/agentes/pandora_networkmap';
header(
'Location: '.ui_get_full_url(
$url.'&tab='.$tab.'&id_networkmap='.$id
)
);
}
}
}
}
@ -419,8 +449,8 @@ else if ($update_networkmap || $copy_networkmap || $delete) {
$source = (string) get_parameter('source', 'group');
$offset_x = get_parameter('pos_x');
$offset_y = get_parameter('pos_y');
$offset_x = get_parameter('pos_x', 0);
$offset_y = get_parameter('pos_y', 0);
$scale_z = get_parameter('scale_z', 0.5);
$values = [];
@ -712,6 +742,8 @@ switch ($tab) {
if (($count == 0) && ($network_map['source'] != 'empty')) {
if ($network_map['generated']) {
$data['nodes'] = __('Empty map');
} else if ($network_map['generation_method'] == LAYOUT_RADIAL_DYNAMIC) {
$data['nodes'] = __('Dynamic');
} else {
$data['nodes'] = __('Pending to generate');
}
@ -756,4 +788,3 @@ switch ($tab) {
}
break;
}

View File

@ -29,7 +29,7 @@
global $config;
require_once 'include/functions_pandora_networkmap.php';
require_once 'include/functions_networkmap.php';
enterprise_include_once('include/functions_policies.php');
enterprise_include_once('include/functions_dashboard.php');
require_once 'include/functions_modules.php';
@ -80,6 +80,10 @@ if (is_ajax()) {
if ($module_get_status) {
$id = (int) get_parameter('id', 0);
if ($id == 0) {
return;
}
$return = [];
$return['correct'] = true;
$return['status'] = modules_get_agentmodule_status(
@ -756,6 +760,7 @@ html_print_input_hidden('center_logo', ui_get_full_url(ui_get_logo_to_center_net
$dash_mode = 0;
$map_dash_details = [];
$networkmap = db_get_row('tmap', 'id', $id);
if (enterprise_installed()) {
include_once 'enterprise/dashboard/widgets/network_map.php';
if ($id_networkmap) {
@ -767,7 +772,6 @@ if (enterprise_installed()) {
$map_dash_details['x_offs'] = $x_offs;
$map_dash_details['y_offs'] = $y_offs;
$map_dash_details['z_dash'] = $z_dash;
$networkmap = db_get_row('tmap', 'id', $id);
} else {
$networkmap_filter = json_decode($networkmap['filter'], true);
@ -866,9 +870,13 @@ if ($networkmap === false) {
);
}
$nodes_and_relations = networkmap_process_networkmap($id);
include_once $config['homedir'].'/include/class/NetworkMap.class.php';
show_networkmap($id, $user_readonly, $nodes_and_relations, $dash_mode, $map_dash_details);
$map_manager = new NetworkMap(
[ 'id_map' => $networkmap['id']]
);
$map_manager->printMap();
}
?>

View File

@ -335,11 +335,6 @@ if (check_acl($config['id_user'], 0, 'ER')
$sub['operation/events/events_marquee.php']['type'] = 'direct';
}
// CSV
$sub['operation/events/export_csv.php?search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0&section=list&open_filter=0&pure=']['text'] = __('CSV File');
$sub['operation/events/export_csv.php?search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0&section=list&open_filter=0&pure=']['id'] = 'CSV File';
$sub['operation/events/export_csv.php?search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0&section=list&open_filter=0&pure=']['type'] = 'direct';
// Sound Events
$javascript = "javascript: window.open('operation/events/sound_events.php');";
$javascript = 'javascript: alert(111);';

View File

@ -114,32 +114,7 @@ if ($read_message) {
echo '<h2>Subject: '.$message['subject'].'</h2>';
$conversation = [];
$target_str = $message['mensaje'];
while (preg_match_all(
'/(.*)On(.*)wrote:(.*)/',
$target_str,
$decoded,
PREG_PATTERN_ORDER
) !== false && empty($target_str) !== true) {
if (empty($decoded[2]) !== true) {
array_push(
$conversation,
[
'message' => array_pop($decoded)[0],
'date' => array_pop($decoded)[0],
]
);
} else {
array_push(
$conversation,
['message' => $target_str]
);
}
$target_str = $decoded[1][0];
}
$conversation = messages_get_conversation($message);
ui_require_css_file('message_edit');
foreach ($conversation as $row) {

View File

@ -785,6 +785,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
`wmi_enabled` tinyint(1) unsigned DEFAULT '0',
`auth_strings` text,
`autoconfiguration_enabled` tinyint(1) unsigned default '0',
`summary` text,
PRIMARY KEY (`id_rt`),
KEY `recon_task_daemon` (`id_recon_server`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -1412,6 +1413,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`visual_format` tinyint(1) UNSIGNED NOT NULL default '0',
`hide_no_data` tinyint(1) default 0,
`recursion` tinyint(1) default NULL,
`show_extended_events` tinyint(1) default '0',
PRIMARY KEY(`id_rc`),
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
ON UPDATE CASCADE ON DELETE CASCADE
@ -3488,3 +3490,30 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` (
`group_search` int(10) unsigned default '0',
PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `user_task`
-- ---------------------------------------------------------------------
CREATE TABLE `tuser_task` (
`id` int(20) unsigned NOT NULL auto_increment,
`function_name` varchar(80) NOT NULL default '',
`parameters` text NOT NULL default '',
`name` varchar(60) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `user_task_scheduled`
-- ---------------------------------------------------------------------
CREATE TABLE `tuser_task_scheduled` (
`id` int(20) unsigned NOT NULL auto_increment,
`id_usuario` varchar(60) NOT NULL default '0',
`id_user_task` int(20) unsigned NOT NULL default '0',
`args` TEXT NOT NULL,
`scheduled` enum('no','hourly','daily','weekly','monthly','yearly','custom') default 'no',
`last_run` int(20) unsigned default '0',
`custom_data` int(10) NULL default '0',
`flag_delete` tinyint(1) UNSIGNED NOT NULL default 0,
`id_grupo` int(10) unsigned NOT NULL default 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -31,6 +31,9 @@ INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal
LOCK TABLES `tconfig` WRITE;
INSERT INTO `tconfig` (`token`, `value`) VALUES
('cron_extension_installed','1'),
('cron_extension_sql_version','1'),
('cron_last_run','0'),
('language','en_GB'),
('block_size','20'),
('days_purge','45'),

View File

@ -26,7 +26,7 @@ use lib '/usr/lib/perl5';
use PandoraFMS::Tools;
use PandoraFMS::DB;
use PandoraFMS::Core;
require Exporter;
our @ISA = ("Exporter");
@ -226,7 +226,7 @@ sub pandora_load_config {
$pa_config->{"dataserver"} = 1; # default
$pa_config->{"networkserver"} = 1; # default
$pa_config->{"snmpconsole"} = 1; # default
$pa_config->{"discoveryserver"} = 1; # default
$pa_config->{"discoveryserver"} = 0; # default
$pa_config->{"wmiserver"} = 1; # default
$pa_config->{"pluginserver"} = 1; # default
$pa_config->{"predictionserver"} = 1; # default

View File

@ -3079,12 +3079,14 @@ Create a new entry in B<tagente> optionaly with position information
=cut
##########################################################################
sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$) {
sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$$) {
# If parameter event_id is not undef, then create an extended event
# related to it instead launch new event.
my ($pa_config, $server_name, $agent_name, $address,
$group_id, $parent_id, $os_id,
$description, $interval, $dbh, $timezone_offset,
$longitude, $latitude, $altitude, $position_description,
$custom_id, $url_address, $agent_mode, $alias) = @_;
$custom_id, $url_address, $agent_mode, $alias, $event_id) = @_;
logger ($pa_config, "Server '$server_name' creating agent '$agent_name' address '$address'.", 10);
@ -3127,7 +3129,11 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$) {
}
logger ($pa_config, "Server '$server_name' CREATED agent '$agent_name' address '$address'.", 10);
if (!defined($event_id)) {
pandora_event ($pa_config, "Agent [" . safe_output($alias) . "] created by $server_name", $group_id, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh);
} else {
pandora_extended_event($pa_config, $dbh, $event_id, "Agent [" . safe_output($alias) . "][#".$agent_id."] created by $server_name");
}
return $agent_id;
}
@ -3814,6 +3820,9 @@ sub subst_alert_macros ($$;$$$$) {
sub subst_column_macros ($$;$$$$) {
my ($string, $macros, $pa_config, $dbh, $agent, $module) = @_;
# Avoid to manipulate null strings
return $string unless defined($string);
# Do not attempt to substitute macros unless the string
# begins with an underscore.
return $string unless substr($string, 0, 1) eq '_';

View File

@ -469,10 +469,11 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
# Are we filtering hosts by TCP port?
return if ($self->{'recon_ports'} ne '' && $self->tcp_scan($device) == 0);
my $location = get_geoip_info($self->{'pa_config'}, $device);
$agent_id = pandora_create_agent($self->{'pa_config'}, $self->{'pa_config'}->{'servername'}, $host_name, $device,
$self->{'group_id'}, 0, $id_os,
'', 300, $self->{'dbh'}, undef,
$location->{'longitude'}, $location->{'latitude'}
$agent_id = pandora_create_agent(
$self->{'pa_config'}, $self->{'pa_config'}->{'servername'},
$host_name, $device, $self->{'group_id'}, 0, $id_os,
'', 300, $self->{'dbh'}, undef, $location->{'longitude'},
$location->{'latitude'}
);
return undef unless defined ($agent_id) and ($agent_id > 0);
@ -833,7 +834,17 @@ sub PandoraFMS::Recon::Base::wmi_module {
sub PandoraFMS::Recon::Base::update_progress ($$) {
my ($self, $progress) = @_;
db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ? WHERE id_rt = ?', time (), $progress, $self->{'task_id'});
my $stats = {};
if (defined($self->{'summary'}) && $self->{'summary'} ne '') {
$stats->{'summary'} = $self->{'summary'};
}
$stats->{'step'} = $self->{'step'};
$stats->{'c_network_name'} = $self->{'c_network_name'};
$stats->{'c_network_percent'} = $self->{'c_network_percent'};
# Store progress, last contact and overall status.
db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?',
time (), $progress, encode_json($stats), $self->{'task_id'});
}
1;

View File

@ -15,6 +15,14 @@ use PandoraFMS::Recon::NmapParser;
use PandoraFMS::Recon::Util;
use Socket qw/inet_aton/;
# Constants.
use constant {
STEP_SCANNING => 1,
STEP_AFT => 2,
STEP_TRACEROUTE => 3,
STEP_GATEWAY => 4
};
# /dev/null
my $DEVNULL = ($^O eq 'MSWin32') ? '/Nul' : '/dev/null';
@ -167,6 +175,18 @@ sub new {
snmp_version => 1,
subnets => [],
autoconfiguration_enabled => 0,
# Store progress summary - Discovery progress view.
step => 0,
c_network_name => '',
c_network_percent => 0.0,
summary => {
SNMP => 0,
WMI => 0,
discovered => 0,
alive => 0,
not_alive => 0
},
@_,
};
@ -176,25 +196,26 @@ sub new {
# Check SNMP params id SNMP is enabled
if ($self->{'snmp_enabled'}) {
# Check SNMP version
if ($self->{'snmp_version'} ne '1' && $self->{'snmp_version'} ne '2'
&& $self->{'snmp_version'} ne '2c' && $self->{'snmp_version'} ne '3'
) {
if ( $self->{'snmp_version'} ne '1'
&& $self->{'snmp_version'} ne '2'
&& $self->{'snmp_version'} ne '2c'
&& $self->{'snmp_version'} ne '3') {
$self->{'snmp_enabled'} = 0;
$self->call('message', "SNMP version " . $self->{'snmp_version'} . " not supported (only 1, 2, 2c and 3).", 5);
}
# Check the version 3 parameters
if ($self->{'snmp_version'} eq '3') {
# Fixed some vars
$self->{'communities'} = [];
# SNMP v3 checks
if (
$self->{'snmp_security_level'} ne 'noAuthNoPriv' &&
$self->{'snmp_security_level'} ne 'authNoPriv' &&
$self->{'snmp_security_level'} ne 'authPriv'
) {
if ( $self->{'snmp_security_level'} ne 'noAuthNoPriv'
&&$self->{'snmp_security_level'} ne 'authNoPriv'
&&$self->{'snmp_security_level'} ne 'authPriv') {
$self->{'snmp_enabled'} = 0;
$self->call('message', "Invalid SNMP security level " . $self->{'snmp_security_level'} . ".", 5);
}
@ -207,6 +228,7 @@ sub new {
$self->call('message', "Invalid SNMP authentication method " . $self->{'snmp_auth_method'} . ".", 5);
}
} else {
# Fixed some vars
$self->{'snmp_auth_user'} = '';
$self->{'snmp_auth_pass'} = '';
@ -296,6 +318,7 @@ sub aft_connectivity($$) {
foreach my $mac ($self->snmp_get_value_array($switch, $DOT1DTPFDBADDRESS)) {
push(@aft, parse_mac($mac));
}
# Search for matching entries.
foreach my $aft_mac (@aft) {
@ -342,8 +365,8 @@ sub are_connected($$$$$) {
$if_1 = "ping" if $if_1 eq '';
$if_2 = "ping" if $if_2 eq '';
if (defined($self->{'connections'}->{"${dev_1}\t${if_1}\t${dev_2}\t${if_2}"}) ||
defined($self->{'connections'}->{"${dev_2}\t${if_2}\t${dev_1}\t${if_1}"})) {
if ( defined($self->{'connections'}->{"${dev_1}\t${if_1}\t${dev_2}\t${if_2}"})
||defined($self->{'connections'}->{"${dev_2}\t${if_2}\t${dev_1}\t${if_1}"})) {
return 1;
}
@ -370,6 +393,7 @@ sub snmp_discovery($$) {
# Check if the device responds to SNMP.
if ($self->snmp_responds($device)) {
$self->{'summary'}->{'SNMP'} += 1;
# Fill the VLAN cache.
$self->find_vlans($device);
@ -906,12 +930,15 @@ sub guess_device_type($$) {
# L2?
my $device_type;
if ($service_bits[1] == 1) {
# L3?
if ($service_bits[2] == 1) {
# Bridge MIB?
if (defined($bridge_mib)) {
$device_type = 'switch';
} else {
# L7?
if ($service_bits[6] == 1) {
$device_type = 'host';
@ -919,8 +946,8 @@ sub guess_device_type($$) {
$device_type = 'router';
}
}
}
else {
}else {
# Bridge MIB?
if (defined($bridge_mib)) {
$device_type = 'switch';
@ -928,14 +955,16 @@ sub guess_device_type($$) {
$device_type = 'host';
}
}
}
else {
}else {
# L3?
if ($service_bits[2] == 1) {
# L4?
if ($service_bits[3] == 1) {
$device_type = 'switch';
} else {
# L7?
if ($service_bits[6] == 1) {
$device_type = 'host';
@ -943,8 +972,8 @@ sub guess_device_type($$) {
$device_type = 'router';
}
}
}
else {
}else {
# Printer MIB?
my $printer_mib = $self->snmp_get_value($device, $PRTMARKERINDEX);
if (defined($printer_mib)) {
@ -1069,8 +1098,8 @@ sub mark_connected($$;$$$) {
}
# Prevent parent-child loops.
if (!defined($self->{'parents'}->{$parent}) ||
$self->{'parents'}->{$parent} ne $child) {
if (!defined($self->{'parents'}->{$parent})
||$self->{'parents'}->{$parent} ne $child) {
# A parent-child relationship is always created to help complete the map with
# layer 3 information.
@ -1097,8 +1126,10 @@ sub mark_switch_connected($$$) {
sub mark_visited($$) {
my ($self, $device) = @_;
$self->{'visited_devices'}->{$device} = { 'addr' => { $device => '' },
'type' => 'host' };
$self->{'visited_devices'}->{$device} = {
'addr' => { $device => '' },
'type' => 'host'
};
}
########################################################################################
@ -1221,11 +1252,7 @@ sub remote_arp($$) {
##############################################################################
sub ping ($$$) {
my ($self, $host) = @_;
my ($timeout, $retries, $packets) = (
$self->{'icmp_timeout'},
$self->{'icmp_checks'},
1,
);
my ($timeout, $retries, $packets) = ($self->{'icmp_timeout'},$self->{'icmp_checks'},1,);
# Windows
if (($^O eq "MSWin32") || ($^O eq "MSWin32-x64") || ($^O eq "cygwin")){
@ -1242,6 +1269,7 @@ sub ping ($$$) {
if ($^O eq "solaris"){
my $ping_command = $host =~ /\d+:|:\d+/ ? "ping -A inet6" : "ping";
for (my $i = 0; $i < $retries; $i++) {
# Note: There is no timeout option.
`$ping_command -s -n $host 56 $packets >/dev/null 2>&1`;
return 1 if ($? == 0);
@ -1254,6 +1282,7 @@ sub ping ($$$) {
if ($^O eq "freebsd"){
my $ping_command = $host =~ /\d+:|:\d+/ ? "ping6" : "ping -t $timeout";
for (my $i = 0; $i < $retries; $i++) {
# Note: There is no timeout option for ping6.
`$ping_command -q -n -c $packets $host >/dev/null 2>&1`;
return 1 if ($? == 0);
@ -1266,6 +1295,7 @@ sub ping ($$$) {
if ($^O eq "netbsd"){
my $ping_command = $host =~ /\d+:|:\d+/ ? "ping6" : "ping -w $timeout";
for (my $i = 0; $i < $retries; $i++) {
# Note: There is no timeout option for ping6.
`$ping_command -q -n -c $packets $host >/dev/null 2>&1`;
if ($? == 0) {
@ -1295,6 +1325,8 @@ sub scan_subnet($) {
my @subnets = @{$self->get_subnets()};
foreach my $subnet (@subnets) {
$self->{'c_network_percent'} = 0;
$self->{'c_network_name'} = $subnet;
# Clean blanks.
$subnet =~ s/\s+//g;
@ -1316,20 +1348,32 @@ sub scan_subnet($) {
my @hosts = `"$self->{'fping'}" -ga "$subnet" 2>DEVNULL`;
next if (scalar(@hosts) == 0);
$self->{'summary'}->{'discovered'} += scalar(@hosts);
my $step = 50.0 / scalar(@subnets) / scalar(@hosts); # The first 50% of the recon task approx.
my $subnet_step = 100.0 / scalar(@hosts);
foreach my $line (@hosts) {
chomp($line);
my @temp = split(/ /, $line);
next if (scalar(@temp) != 1); # Junk is shown for broadcast addresses.
if (scalar(@temp) != 1) {
# Junk is shown for broadcast addresses.
# Increase summary.not_alive hosts.
$self->{'summary'}->{'not_alive'} += 1;
next;
}
my $host = $temp[0];
# Skip network and broadcast addresses.
next if ($host eq $network->addr() || $host eq $broadcast->addr());
# Increase self summary.alive hosts.
$self->{'summary'}->{'alive'} += 1;
$self->call('message', "Scanning host: $host", 5);
$self->call('update_progress', ceil($progress));
$progress += $step;
$self->{'c_network_percent'} += $subnet_step;
$self->snmp_discovery($host);
@ -1337,12 +1381,16 @@ sub scan_subnet($) {
$self->wmi_scan($host) if ($self->{'wmi_enabled'} == 1);
}
}
# ping scan.
else {
my @hosts = map { (split('/', $_))[0] } $net_addr->hostenum;
next if (scalar(@hosts) == 0);
$self->{'summary'}->{'discovered'} += scalar(@hosts);
my $step = 50.0 / scalar(@subnets) / scalar(@hosts); # The first 50% of the recon task approx.
my $subnet_step = 100.0 / scalar(@hosts);
foreach my $host (@hosts) {
$self->call('message', "Scanning host: $host", 5);
@ -1350,7 +1398,13 @@ sub scan_subnet($) {
$progress += $step;
# Check if the host is up.
next if ($self->ping($host) == 0);
if ($self->ping($host) == 0) {
$self->{'summary'}->{'not_alive'} += 1;
next;
}
$self->{'summary'}->{'alive'} += 1;
$self->{'c_network_percent'} += $subnet_step;
$self->snmp_discovery($host);
@ -1373,6 +1427,8 @@ sub scan($) {
# Find devices.
$self->call('message', "[1/5] Scanning the network...", 3);
$self->{'step'} = STEP_SCANNING;
$self->call('update_progress', $progress);
$self->scan_subnet();
# Read the local ARP cache.
@ -1381,11 +1437,13 @@ sub scan($) {
# Get a list of found hosts.
my @hosts = @{$self->get_hosts()};
if (scalar(@hosts) > 0 && $self->{'parent_detection'} == 1) {
# Delete previous connections.
$self->call('delete_connections');
# Connectivity from address forwarding tables.
$self->call('message', "[1/4] Finding address forwarding table connectivity...", 3);
$self->{'step'} = STEP_AFT;
($progress, $step) = (50, 20.0 / scalar(@hosts)); # From 50% to 70%.
for (my $i = 0; defined($hosts[$i]); $i++) {
$self->call('update_progress', $progress);
@ -1395,6 +1453,7 @@ sub scan($) {
# Connect hosts that are still unconnected using traceroute.
$self->call('message', "[3/4] Finding traceroute connectivity.", 3);
$self->{'step'} = STEP_TRACEROUTE;
($progress, $step) = (70, 20.0 / scalar(@hosts)); # From 70% to 90%.
foreach my $host (@hosts) {
$self->call('update_progress', $progress);
@ -1405,6 +1464,7 @@ sub scan($) {
# Connect hosts that are still unconnected using known gateways.
$self->call('message', "[4/4] Finding host to gateway connectivity.", 3);
$self->{'step'} = STEP_GATEWAY;
($progress, $step) = (90, 10.0 / scalar(@hosts)); # From 70% to 90%.
$self->get_routes(); # Update the route cache.
foreach my $host (@hosts) {
@ -1416,6 +1476,7 @@ sub scan($) {
}
# Done!
$self->{'step'} = '';
$self->call('update_progress', -1);
# Print debug information on found devices.
@ -1473,8 +1534,8 @@ sub snmp_get($$$) {
if (scalar(@vlans) == 0) {
my $command = $self->snmp_get_command($device, $oid, $community);
@output = `$command`;
}
else {
}else {
# Handle duplicate lines.
my %output_hash;
foreach my $vlan (@vlans) {
@ -1575,9 +1636,7 @@ sub traceroute_connectivity($$) {
# Perform a traceroute.
my $nmap_args = '-nsP -PE --traceroute --max-retries '.$self->{'icmp_checks'}.' --host-timeout '.$self->{'icmp_timeout'}.'s -T'.$self->{'recon_timing_template'};
my $np = PandoraFMS::Recon::NmapParser->new();
eval {
$np->parsescan($self->{'nmap'}, $nmap_args, ($host));
};
eval {$np->parsescan($self->{'nmap'}, $nmap_args, ($host));};
return if ($@);
# Get hops to the host.
@ -1643,7 +1702,10 @@ sub wmi_scan {
my $auth = $self->responds_to_wmi($target);
return unless defined($auth);
$self->{'summary'}->{'WMI'} += 1;
$self->call('message', "[".$target."] WMI available.", 10);
# Create the agent if it does not exist.
my $agent_id = $self->call('create_agent', $target);
next unless defined($agent_id);
@ -1651,56 +1713,19 @@ sub wmi_scan {
# CPU.
my @cpus = $self->wmi_get_value_array($target, $auth, 'SELECT DeviceId FROM Win32_Processor', 0);
foreach my $cpu (@cpus) {
$self->call(
'wmi_module',
(
$agent_id,
$target,
"SELECT LoadPercentage FROM Win32_Processor WHERE DeviceId='$cpu'",
$auth,
1,
"CPU Load $cpu",
"Load for $cpu (%)",
'generic_data'
)
);
$self->call('wmi_module',($agent_id,$target,"SELECT LoadPercentage FROM Win32_Processor WHERE DeviceId='$cpu'",$auth,1,"CPU Load $cpu","Load for $cpu (%)",'generic_data'));
}
# Memory.
my $mem = $self->wmi_get_value($target, $auth, 'SELECT FreePhysicalMemory FROM Win32_OperatingSystem', 0);
if (defined($mem)) {
$self->call('wmi_module',
(
$agent_id,
$target,
"SELECT FreePhysicalMemory, TotalVisibleMemorySize FROM Win32_OperatingSystem",
$auth,
0,
'FreeMemory',
'Free memory',
'generic_data',
'KB'
)
);
$self->call('wmi_module',($agent_id,$target,"SELECT FreePhysicalMemory, TotalVisibleMemorySize FROM Win32_OperatingSystem",$auth,0,'FreeMemory','Free memory','generic_data','KB'));
}
# Disk.
my @units = $self->wmi_get_value_array($target, $auth, 'SELECT DeviceID FROM Win32_LogicalDisk', 0);
foreach my $unit (@units) {
$self->call(
'wmi_module',
(
$agent_id,
$target,
"SELECT FreeSpace FROM Win32_LogicalDisk WHERE DeviceID='$unit'",
$auth,
1,
"FreeDisk $unit",
'Available disk space in kilobytes',
'generic_data',
'KB'
)
);
$self->call('wmi_module',($agent_id,$target,"SELECT FreeSpace FROM Win32_LogicalDisk WHERE DeviceID='$unit'",$auth,1,"FreeDisk $unit",'Available disk space in kilobytes','generic_data','KB'));
}
}

View File

@ -1774,7 +1774,7 @@ sub api_call_url {
my $ua = LWP::UserAgent->new();
$ua->timeout($options->{lwp_timeout});
$ua->timeout($pa_config->{'tcp_timeout'});
# Enable environmental proxy settings
$ua->env_proxy;
# Enable in-memory cookie management