Merge branch 'ent-3431-discovery-host-devices' into ent-1798-monitorizacion-aws-amazon

Conflicts:
	pandora_console/godmode/servers/discovery.php

Former-commit-id: 4e840a1738523e2e0570413e8e7dedb02b265919
This commit is contained in:
fermin831 2019-02-18 08:50:54 +01:00
commit 2332001884
11 changed files with 703 additions and 132 deletions

View File

@ -15,17 +15,17 @@ global $config;
check_login();
ui_require_css_file('firts_task');
?>
<?php ui_print_info_message(['no_close' => true, 'message' => __('There are no recon task defined yet.') ]); ?>
<?php ui_print_info_message(['no_close' => true, 'message' => __('There are no discovery tasks defined yet.') ]); ?>
<div class="new_task">
<div class="image_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 Recon Task'); ?> <p id="description_task">
<h3> <?php echo __('Create Discovery Task'); ?><p id="description_task">
<?php
echo __(
'The Recon Task definition of Pandora FMS is used to find new elements in the network.
'Discovery Task are used to find new elements in the network.
If it detects any item, it will add that item to the monitoring, and if that item it is already being monitored, then it will
ignore it or will update its information.There are three types of detection: Based on <strong id="fuerte"> ICMP </strong>(pings),
<strong id="fuerte">SNMP</strong> (detecting the topology of networks and their interfaces), and other <strong id="fuerte"> customized </strong>
@ -33,8 +33,8 @@ ui_require_css_file('firts_task');
);
?>
</p>
<form action="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&create" method="post">
<input type="submit" class="button_task" value="<?php echo __('Create Recon Task'); ?>" />
<form action="index.php?sec=gservers&sec2=godmode/servers/discovery" method="post">
<input type="submit" class="button_task" value="<?php echo __('Discover'); ?>" />
</form>
</div>
</div>

View File

@ -15,7 +15,7 @@ if (! check_acl($config['id_user'], 0, 'AW')) {
ui_require_css_file('discovery');
ui_print_page_header(__('Discover'), 'wizards/hostDevices.png', false, '', true);
ui_print_page_header(__('Discover'), '', false, '', true);
/**
@ -33,6 +33,9 @@ function get_wiz_class($str)
case 'cloud':
return 'Cloud';
case 'tasklist':
return 'DiscoveryTaskList';
default:
// Ignore.
return null;
@ -40,6 +43,10 @@ function get_wiz_class($str)
}
/*
* CLASS LOADER.
*/
// Dynamic class loader.
$classes = glob($config['homedir'].'/godmode/wizards/*.class.php');
foreach ($classes as $classpath) {
@ -56,8 +63,18 @@ $classname_selected = get_wiz_class($wiz_in_use);
if ($classname_selected !== null) {
$wiz = new $classname_selected($page);
$result = $wiz->run();
// TODO: Here we'll controlle if return is a valid recon task id.
hd($result);
if (is_array($result) === true) {
if ($result['result'] === 0) {
// Success.
ui_print_success_message($result['msg']);
// TODO: Show task progress before redirect to main discovery menu.
} else {
// Failed.
ui_print_error_message($result['msg']);
}
$classname_selected = null;
}
}
if ($classname_selected === null) {
@ -67,13 +84,14 @@ if ($classname_selected === null) {
$classname = basename($classpath, '.class.php');
$obj = new $classname();
$wiz_data = $obj->load();
hd($wiz_data);
?>
<li>
<li class="discovery">
<a href="<?php echo $wiz_data['url']; ?>">
<img src="<?php echo 'wizards/'.$wiz_data['icon']; ?>" alt="<?php echo $classname; ?>">
<br><label><?php echo $wiz_data['label']; ?></label>
<div class="data_container">
<?php html_print_image($wiz_data['icon']); ?>
<br><label id="text_wizard"><?php echo io_safe_output($wiz_data['label']); ?></label>
</div>
</a>
</li>

View File

@ -0,0 +1,351 @@
<?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 __DIR__.'/Wizard.main.php';
require_once $config['homedir'].'/include/functions_users.php';
/**
* Defined as wizard to guide user to explore running tasks.
*/
class DiscoveryTaskList extends Wizard
{
/**
* Constructor.
*
* @param integer $page Start page, by default 0.
* @param string $msg Custom default mesage.
* @param string $icon Custom icon.
* @param string $label Custom label.
*
* @return class HostDevices
*/
public function __construct(
int $page=0,
string $msg='Default message. Not set.',
string $icon='images/wizard/tasklist.svg',
string $label='Task list'
) {
$this->setBreadcrum([]);
$this->task = [];
$this->msg = $msg;
$this->icon = $icon;
$this->label = __($label);
$this->page = $page;
$this->url = ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist'
);
return $this;
}
/**
* Implements run method.
*
* @return mixed Returns null if wizard is ongoing. Result if done.
*/
public function run()
{
// Load styles.
parent::run();
$delete = (bool) get_parameter('delete', false);
if ($delete) {
return $this->deleteTask();
}
return $this->showList();
}
/**
* Implements load method.
*
* @return mixed Skeleton for button.
*/
public function load()
{
return [
'icon' => $this->icon,
'label' => $this->label,
'url' => $this->url,
];
}
/**
* Delete a recon task.
*
* @return void
*/
public function deleteTask()
{
global $config;
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access recon task viewer'
);
include 'general/noaccess.php';
return;
}
$task = get_parameter('task', null);
if ($task !== null) {
db_process_sql_delete(
'trecon_task',
['id_rt' => $task]
);
}
return [
'result' => 0,
'msg' => __('Task successfully deleted'),
'id' => false,
];
}
/**
* Show complete list of running tasks.
*
* @return boolean Success or not.
*/
public function showList()
{
global $config;
check_login();
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access recon task viewer'
);
include 'general/noaccess.php';
return false;
}
// Get all recon servers.
$servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3');
if ($servers === false) {
$servers = [];
ui_print_error_message(__('Discovery Server is disabled'));
return false;
} else {
$recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task');
if ($recon_task === false) {
include_once $config['homedir'].'/general/firts_task/recon_view.php';
return false;
} else {
include_once $config['homedir'].'/include/functions_graph.php';
include_once $config['homedir'].'/include/functions_servers.php';
include_once $config['homedir'].'/include/functions_network_profiles.php';
$modules_server = 0;
$total_modules = 0;
$total_modules_data = 0;
// --------------------------------
// FORCE A RECON TASK
// --------------------------------
if (check_acl($config['id_user'], 0, 'PM')) {
if (isset($_GET['force'])) {
$id = (int) get_parameter_get('force', 0);
servers_force_recon_task($id);
header(
'Location: '.ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist'
)
);
}
}
foreach ($servers as $serverItem) {
$id_server = $serverItem['id_server'];
$server_name = servers_get_name($id_server);
$recon_tasks = db_get_all_rows_field_filter('trecon_task', 'id_recon_server', $id_server);
// Show network tasks for Recon Server.
if ($recon_tasks === false) {
$recon_tasks = [];
}
$table = new StdClass();
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = '100%';
$table->class = 'databox data';
$table->head = [];
$table->data = [];
$table->align = [];
$table->headstyle = [];
for ($i = 0; $i < 9; $i++) {
$table->headstyle[$i] = 'text-align: left;';
}
$table->head[0] = __('Force');
$table->align[0] = 'left';
$table->head[1] = __('Task name');
$table->align[1] = 'left';
$table->head[2] = __('Interval');
$table->align[2] = 'left';
$table->head[3] = __('Network');
$table->align[3] = 'left';
$table->head[4] = __('Status');
$table->align[4] = 'left';
$table->head[5] = __('Template');
$table->align[5] = 'left';
$table->head[6] = __('Progress');
$table->align[6] = 'left';
$table->head[7] = __('Updated at');
$table->align[7] = 'left';
$table->head[8] = __('Operations');
$table->align[8] = 'left';
foreach ($recon_tasks as $task) {
$data = [];
if ($task['disabled'] == 0) {
$data[0] = '<a href="'.ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&server_id='.$id_server.'&force='.$task['id_rt']
).'">';
$data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]);
$data[0] .= '</a>';
} else {
$data[0] = '';
}
$data[1] = '<b>'.$task['name'].'</b>';
$data[2] = human_time_description_raw($task['interval_sweep']);
if ($task['id_recon_script'] == 0) {
$data[3] = $task['subnet'];
} else {
$data[3] = '-';
}
if ($task['status'] <= 0) {
$data[4] = __('Done');
} else {
$data[4] = __('Pending');
}
if ($task['id_recon_script'] == 0) {
// Network recon task.
$data[5] = html_print_image('images/network.png', true, ['title' => __('Network recon task')]).'&nbsp;&nbsp;';
$data[5] .= network_profiles_get_name($task['id_network_profile']);
} else {
// APP recon task.
$data[5] = html_print_image('images/plugin.png', true).'&nbsp;&nbsp;';
$data[5] .= db_get_sql(sprintf('SELECT name FROM trecon_script WHERE id_recon_script = %d', $task['id_recon_script']));
}
if ($task['status'] <= 0 || $task['status'] > 100) {
$data[6] = '-';
} else {
$data[6] = progress_bar($task['status'], 100, 20, __('Progress').':'.$task['status'].'%', 1);
}
$data[7] = ui_print_timestamp($task['utimestamp'], true);
if (check_acl($config['id_user'], $task['id_group'], 'PM')) {
$data[8] = '<a href="'.ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan&page=0&task='.$task['id_rt']
).'">'.html_print_image(
'images/wrench_orange.png',
true
).'</a>';
$data[8] .= '<a href="'.ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&delete=1&task='.$task['id_rt']
).'">'.html_print_image(
'images/cross.png',
true
).'</a>';
} else {
$data[8] = '';
}
array_push($table->data, $data);
}
if (empty($table->data)) {
echo '<div class="nf">'.__('Server').' '.$server_name.' '.__('has no recon tasks assigned').'</div>';
} else {
html_print_table($table);
}
unset($table);
}
}
}
$form = [
'form' => [
'method' => 'POST',
'action' => ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery'
),
],
'inputs' => [
[
'arguments' => [
'name' => 'submit',
'label' => __('Go back'),
'type' => 'submit',
'attributes' => 'class="sub cancel"',
'return' => true,
],
],
],
];
$this->printForm($form);
return true;
}
}

View File

@ -31,56 +31,12 @@ require_once $config['homedir'].'/include/functions_users.php';
enterprise_include('include/class/CSVImportAgents.class.php');
/**
* Undocumented class
* Wizard section Host&devices.
* Provides classic recon task creation.
* In enterprise environments, provides also CSV agent import features.
*/
class HostDevices extends Wizard
{
// CSV constants.
const HDW_CSV_NOT_DATA = 0;
const HDW_CSV_DUPLICATED = 0;
const HDW_CSV_GROUP_EXISTS = 0;
/**
* Undocumented variable
*
* @var array
*/
public $values = [];
/**
* Undocumented variable
*
* @var [type]
*/
public $result;
/**
* Undocumented variable
*
* @var [type]
*/
public $msg;
/**
* Undocumented variable
*
* @var [type]
*/
public $icon;
/**
* Undocumented variable
*
* @var [type]
*/
public $label;
/**
* Undocumented variable
*
* @var [type]
*/
public $url;
/**
* Stores all needed parameters to create a recon task.
@ -91,7 +47,7 @@ class HostDevices extends Wizard
/**
* Undocumented function.
* Constructor.
*
* @param integer $page Start page, by default 0.
* @param string $msg Mensajito.
@ -103,7 +59,7 @@ class HostDevices extends Wizard
public function __construct(
int $page=0,
string $msg='Default message. Not set.',
string $icon='hostDevices.png',
string $icon='images/wizard/hostdevices.svg',
string $label='Host & Devices'
) {
$this->setBreadcrum([]);
@ -122,9 +78,9 @@ class HostDevices extends Wizard
/**
* Undocumented function
* Run wizard manager.
*
* @return void
* @return mixed Returns null if wizard is ongoing. Result if done.
*/
public function run()
{
@ -138,9 +94,24 @@ class HostDevices extends Wizard
if ($mode === null) {
$this->setBreadcrum(['<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>']);
$this->printHeader();
echo '<a href="'.$this->url.'&mode=importcsv" alt="importcsv">Importar csv</a>';
echo '<a href="'.$this->url.'&mode=netscan" alt="netscan">Escanear red</a>';
echo '<div id="contenedor_principal">';
echo '<div id="contenedor_imagen_texto">';
echo '<div id="imagen">';
echo '<a href="'.$this->url.'&mode=importcsv" alt="importcsv"><img src="images/wizard/csv_image.svg" alt="importcsv"></a>';
echo '</div>';
echo '<div class="texto">';
echo '<a href="'.$this->url.'&mode=importcsv" alt="importcsv" id="text_wizard">'.__('Import CSV').'</a>';
echo '</div>';
echo '</div>';
echo '<div id="contenedor_imagen_texto">';
echo '<div id="imagen">';
echo '<a href="'.$this->url.'&mode=netscan" alt="netscan"><img src="images/wizard/csv_image.svg" alt="importcsv"></a>';
echo '</div>';
echo '<div class="texto">';
echo '<a href="'.$this->url.'&mode=netscan" alt="netscan" id="text_wizard">'.__('Escanear red').'</a>';
echo '</div>';
echo '</div>';
echo '</div>';
return;
}
@ -160,13 +131,17 @@ class HostDevices extends Wizard
}
if ($mode == 'netscan') {
$this->setBreadcrum(
[
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>',
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan">Net scan</a>',
]
);
$this->printHeader();
if ($this->page != 3) {
// Do not paint breadcrum in last page. Redirected.
$this->setBreadcrum(
[
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>',
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan">Net scan</a>',
]
);
$this->printHeader();
}
return $this->runNetScan();
}
@ -257,6 +232,8 @@ class HostDevices extends Wizard
if ($task !== false) {
$this->task = $task;
$this->msg = __('This network scan task has been already defined. Please edit it or create a new one.');
return false;
}
}
@ -334,6 +311,8 @@ class HostDevices extends Wizard
$parent_detection = get_parameter_switch('parent_detection');
$parent_recursion = get_parameter_switch('parent_recursion');
$vlan_enabled = get_parameter_switch('vlan_enabled');
$wmi_enabled = get_parameter_switch('wmi_enabled');
$resolve_names = get_parameter_switch('resolve_names');
$snmp_version = get_parameter('snmp_version', null);
$community = get_parameter('community', null);
$snmp_context = get_parameter('snmp_context', null);
@ -357,6 +336,8 @@ class HostDevices extends Wizard
$this->task['parent_detection'] = $parent_detection;
$this->task['parent_recursion'] = $parent_recursion;
$this->task['vlan_enabled'] = $vlan_enabled;
$this->task['wmi_enabled'] = $wmi_enabled;
$this->task['resolve_names'] = $resolve_names;
$this->task['snmp_version'] = $snmp_version;
$this->task['snmp_auth_user'] = $snmp_auth_user;
$this->task['snmp_auth_pass'] = $snmp_auth_pass;
@ -395,7 +376,12 @@ class HostDevices extends Wizard
}
$interval = get_parameter('interval', 0);
$id_os = get_parameter('id_os', 0);
$recon_ports = get_parameter('recon_ports', '');
$this->task['id_os'] = $id_os;
$this->task['interval_sweep'] = $interval;
$this->task['recon_ports'] = $recon_ports;
if ($this->task['disabled'] == 2) {
// Wizard finished.
@ -615,11 +601,12 @@ class HostDevices extends Wizard
$form['inputs'][] = [
'label' => '<b>'.__('Group').'</b>',
'arguments' => [
'name' => 'id_group',
'privilege' => 'PM',
'type' => 'select_groups',
'selected' => $this->task['id_group'],
'return' => true,
'name' => 'id_group',
'returnAllGroup' => false,
'privilege' => 'PM',
'type' => 'select_groups',
'selected' => $this->task['id_group'],
'return' => true,
],
];
@ -640,14 +627,20 @@ class HostDevices extends Wizard
],
];
$task_url = '';
if (isset($this->task['id_rt'])) {
$task_url = '&task='.$this->task['id_rt'];
}
$form['form'] = [
'method' => 'POST',
'action' => $this->url.'&mode=netscan&page='.($this->page + 1),
'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url,
];
// XXX: Could be improved validating inputs before continue (JS)
// Print NetScan page 0.
$this->printForm($form);
$this->printGoBackButton();
}
}
@ -682,25 +675,26 @@ class HostDevices extends Wizard
$form['inputs'][] = [
'label' => __('Module template'),
'arguments' => [
'name' => 'id_network_profile',
'type' => 'select_from_sql',
'sql' => 'SELECT id_np, name
'name' => 'id_network_profile',
'type' => 'select_from_sql',
'sql' => 'SELECT id_np, name
FROM tnetwork_profile
ORDER BY name',
'return' => true,
'return' => true,
'selected' => $this->task['id_network_profile'],
],
];
// Feature configuration.
// Input: Module template.
// Input: SNMP enabled.
$form['inputs'][] = [
'label' => __('SNMP enabled'),
'arguments' => [
'name' => 'snmp_enabled',
'type' => 'switch',
'return' => true,
'value' => 1,
'value' => (isset($this->task['snmp_enabled'])) ? $this->task['snmp_enabled'] : 1,
'onclick' => 'extraSNMP();',
],
@ -708,21 +702,22 @@ class HostDevices extends Wizard
// SNMP CONFIGURATION.
$form['inputs'][] = [
'hidden' => 0,
'hidden' => 1,
'block_id' => 'snmp_extra',
'block_content' => [
[
'label' => __('SNMP version'),
'arguments' => [
'name' => 'snmp_version',
'fields' => [
'name' => 'snmp_version',
'fields' => [
'1' => 'v. 1',
'2c' => 'v. 2c',
'3' => 'v. 3',
],
'type' => 'select',
'script' => 'SNMPExtraShow(this.value)',
'return' => true,
'type' => 'select',
'script' => 'SNMPExtraShow(this.value)',
'selected' => $this->task['snmp_version'],
'return' => true,
],
],
],
@ -743,6 +738,7 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'community',
'type' => 'text',
'value' => $this->task['snmp_community'],
'size' => 25,
'return' => true,
@ -761,6 +757,7 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'snmp_context',
'type' => 'text',
'value' => $this->task['snmp_community'],
'size' => 15,
'return' => true,
@ -771,6 +768,7 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'snmp_auth_user',
'type' => 'text',
'value' => $this->task['snmp_auth_user'],
'size' => 15,
'return' => true,
@ -786,6 +784,7 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'snmp_auth_pass',
'type' => 'password',
'value' => $this->task['snmp_auth_pass'],
'size' => 15,
'return' => true,
@ -794,14 +793,15 @@ class HostDevices extends Wizard
[
'label' => '<b>'.__('Privacy method').'</b>',
'arguments' => [
'name' => 'snmp_privacy_method',
'type' => 'select',
'fields' => [
'name' => 'snmp_privacy_method',
'type' => 'select',
'fields' => [
'DES' => __('DES'),
'AES' => __('AES'),
],
'size' => 15,
'return' => true,
'selected' => $this->task['snmp_privacy_method'],
'size' => 15,
'return' => true,
],
],
@ -815,6 +815,7 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'snmp_privacy_pass',
'type' => 'password',
'value' => $this->task['snmp_privacy_pass'],
'size' => 15,
'return' => true,
@ -823,29 +824,31 @@ class HostDevices extends Wizard
[
'label' => '<b>'.__('Auth method').'</b>',
'arguments' => [
'name' => 'snmp_auth_method',
'type' => 'select',
'fields' => [
'name' => 'snmp_auth_method',
'type' => 'select',
'fields' => [
'MD5' => __('MD5'),
'SHA' => __('SHA'),
],
'size' => 15,
'return' => true,
'selected' => $this->task['snmp_auth_method'],
'size' => 15,
'return' => true,
],
],
[
'label' => '<b>'.__('Security level').'</b>',
'arguments' => [
'name' => 'snmp_security_level',
'type' => 'select',
'fields' => [
'name' => 'snmp_security_level',
'type' => 'select',
'fields' => [
'noAuthNoPriv' => __('Not auth and not privacy method'),
'authNoPriv' => __('Auth and not privacy method'),
'authPriv' => __('Auth and privacy method'),
],
'size' => 15,
'return' => true,
'selected' => $this->task['snmp_security_level'],
'size' => 15,
'return' => true,
],
],
@ -859,33 +862,38 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'wmi_enabled',
'type' => 'switch',
'value' => (isset($this->task['wmi_enabled'])) ? $this->task['wmi_enabled'] : 0,
'return' => true,
'onclick' => "\$('#wmi_extra').toggle();",
'onclick' => 'toggleWMI();',
],
];
// WMI CONFIGURATION.
$form['inputs'][] = [
'label' => __('WMI Auth. strings'),
'hidden' => 1,
'id' => 'wmi_extra',
'arguments' => [
'name' => 'auth_strings',
'type' => 'text',
'return' => true,
'block_id' => 'wmi_extra',
'hidden' => 1,
'block_content' => [
[
'label' => __('WMI Auth. strings'),
'arguments' => [
'name' => 'auth_strings',
'type' => 'text',
'value' => $this->task['auth_strings'],
'return' => true,
],
],
],
];
// Input: Module template.
// Input: Enforce os detection.
$form['inputs'][] = [
'label' => __('OS detection'),
'arguments' => [
'name' => 'os_detect',
'type' => 'switch',
'return' => true,
'value' => 1,
'value' => (isset($this->task['os_detect'])) ? $this->task['os_detect'] : 1,
],
];
@ -897,6 +905,7 @@ class HostDevices extends Wizard
'name' => 'resolve_names',
'type' => 'switch',
'return' => true,
'value' => (isset($this->task['resolve_names'])) ? $this->task['resolve_names'] : 0,
],
];
@ -907,7 +916,7 @@ class HostDevices extends Wizard
'name' => 'parent_detection',
'type' => 'switch',
'return' => true,
'value' => 1,
'value' => (isset($this->task['parent_detection'])) ? $this->task['parent_detection'] : 1,
],
];
@ -918,7 +927,7 @@ class HostDevices extends Wizard
'name' => 'parent_recursion',
'type' => 'switch',
'return' => true,
'value' => 1,
'value' => (isset($this->task['parent_recursion'])) ? $this->task['parent_recursion'] : 1,
],
];
@ -929,7 +938,7 @@ class HostDevices extends Wizard
'name' => 'vlan_enabled',
'type' => 'switch',
'return' => true,
'value' => 1,
'value' => (isset($this->task['vlan_enabled'])) ? $this->task['vlan_enabled'] : 1,
],
];
@ -948,10 +957,12 @@ class HostDevices extends Wizard
function SNMPExtraShow(target) {
$("#snmp_options_basic").hide();
$("#snmp_options_v3").hide();
if (target == 3) {
$("#snmp_options_v3").show();
} else {
$("#snmp_options_basic").show();
if (document.getElementsByName("snmp_enabled")[0].checked) {
if (target == 3) {
$("#snmp_options_v3").show();
} else {
$("#snmp_options_basic").show();
}
}
}
@ -979,8 +990,16 @@ function extraSNMP() {
}
}
function toggleWMI() {
if (document.getElementsByName("wmi_enabled")[0].checked)
$("#wmi_extra").show();
else
$("#wmi_extra").hide();
}
$(function() {
SNMPExtraShow($("#snmp_version").val())
SNMPExtraShow($("#snmp_version").val());
toggleWMI();
});
';
@ -995,10 +1014,40 @@ $(function() {
if ($this->page == 2) {
// Interval and schedules.
$interv_manual = 0;
if ((int) $interval == 0) {
if ((int) $this->task['interval_sweep'] == 0) {
$interv_manual = 1;
}
// Filter: OS.
$form['inputs'][] = [
'label' => '<b>'.__('Filter by OS').'</b>',
'arguments' => [
'type' => 'select_from_sql',
'sql' => 'SELECT id_os, name
FROM tconfig_os
ORDER BY name',
'name' => 'id_os',
'return' => 'true',
'nothing' => __('Any'),
'selected' => $this->task['id_os'],
],
];
// Filter: Ports.
$form['inputs'][] = [
'label' => '<b>'.__('Filter by ports').'</b>'.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
),
'arguments' => [
'type' => 'text',
'name' => 'recon_ports',
'return' => 'true',
'recon_ports' => $this->task['recon_ports'],
],
];
// Schedule.
$form['inputs'][] = [
'label' => '<b>'.__('Interval').'</b>'.ui_print_help_tip(
__('Manual interval means that it will be executed only On-demand'),
@ -1016,7 +1065,7 @@ $(function() {
],
'extra' => '<span id="interval_manual_container">'.html_print_extended_select_for_time(
'interval',
$interval,
$this->task['interval_sweep'],
'',
'',
'0',
@ -1082,6 +1131,7 @@ $("select#interval_manual_defined").change(function() {
}).change();';
$this->printForm($form);
return null;
}
if ($this->page == 3) {

View File

@ -20,6 +20,41 @@ class Wizard
*/
public $page;
/**
* Target icon to be shown in discovery wizard list.
*
* @var string
*/
public $icon;
/**
* Target label to be shown in discovery wizard list.
*
* @var string
*/
public $label;
/**
* This wizard's url.
*
* @var string
*/
public $url;
/**
* Result of wizard execution (0 - ok, 1 - not ok).
*
* @var integer
*/
public $result;
/**
* Message to be delivered to user.
*
* @var string
*/
public $msg;
/**
* Setter for breadcrum
@ -285,13 +320,13 @@ class Wizard
);
case 'submit':
return html_print_submit_button(
return '<div class="action-buttons" style="width: 100%">'.html_print_submit_button(
((isset($data['label']) === true) ? $data['label'] : 'OK'),
((isset($data['name']) === true) ? $data['name'] : ''),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
((isset($data['return']) === true) ? $data['return'] : false)
);
).'</div>';
case 'checkbox':
return html_print_checkbox(
@ -316,6 +351,37 @@ class Wizard
}
/**
* Prints a go back button redirecting to main page.
*
* @return void
*/
public function printGoBackButton()
{
$form = [
'form' => [
'method' => 'POST',
'action' => ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery'
),
],
'inputs' => [
[
'arguments' => [
'name' => 'submit',
'label' => __('Go back'),
'type' => 'submit',
'attributes' => 'class="sub cancel"',
'return' => true,
],
],
],
];
$this->printForm($form);
}
/**
* Print a block of inputs.
*

View File

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<path d="M 17.660156 4 C 16.320156 4 15.059141 4.5209375 14.119141 5.4609375 L 5.4609375 14.119141 C 4.5209375 15.069141 4 16.320156 4 17.660156 L 4 57 C 4 58.65 5.35 60 7 60 L 47 60 C 48.65 60 50 58.65 50 57 L 50 46 L 58 46 C 59.1 46 60 45.1 60 44 L 60 24 C 60 22.9 59.1 22 58 22 L 50 22 L 50 7 C 50 5.35 48.65 4 47 4 L 17.660156 4 z M 18 6 L 47 6 C 47.55 6 48 6.45 48 7 L 48 22 L 16 22 C 14.9 22 14 22.9 14 24 L 14 44 C 14 45.1 14.9 46 16 46 L 48 46 L 48 57 C 48 57.55 47.55 58 47 58 L 7 58 C 6.45 58 6 57.55 6 57 L 6 18 L 15 18 C 16.654 18 18 16.654 18 15 L 18 6 z M 16 6.4980469 L 16 15 C 16 15.552 15.552 16 15 16 L 6.5019531 16 C 6.6119531 15.834 6.7388594 15.679063 6.8808594 15.539062 L 15.539062 6.8808594 C 15.681062 6.7368594 15.836 6.6080469 16 6.4980469 z M 16 24 L 48 24 L 50 24 L 58 24 L 58 44 L 50 44 L 48 44 L 16 44 L 16 24 z M 27 28 C 25.346 28 24 29.346 24 31 L 24 37 C 24 38.654 25.346 40 27 40 L 29 40 C 30.654 40 32 38.654 32 37 C 32 36.447 31.553 36 31 36 C 30.447 36 30 36.447 30 37 C 30 37.552 29.552 38 29 38 L 27 38 C 26.448 38 26 37.552 26 37 L 26 31 C 26 30.448 26.448 30 27 30 L 29 30 C 29.552 30 30 30.448 30 31 C 30 31.553 30.447 32 31 32 C 31.553 32 32 31.553 32 31 C 32 29.346 30.654 28 29 28 L 27 28 z M 37 28 C 35.346 28 34 29.346 34 31 L 34 32 C 34 33.654 35.346 35 37 35 L 39 35 C 39.552 35 40 35.448 40 36 L 40 37 C 40 37.552 39.552 38 39 38 L 37 38 C 36.448 38 36 37.552 36 37 C 36 36.447 35.553 36 35 36 C 34.447 36 34 36.447 34 37 C 34 38.654 35.346 40 37 40 L 39 40 C 40.654 40 42 38.654 42 37 L 42 36 C 42 34.346 40.654 33 39 33 L 37 33 C 36.448 33 36 32.552 36 32 L 36 31 C 36 30.448 36.448 30 37 30 L 39 30 C 39.552 30 40 30.448 40 31 C 40 31.553 40.447 32 41 32 C 41.553 32 42 31.553 42 31 C 42 29.346 40.654 28 39 28 L 37 28 z M 45.109375 28.005859 C 44.980234 27.991641 44.845391 28.003719 44.712891 28.042969 C 44.183891 28.201969 43.884969 28.759109 44.042969 29.287109 L 47.042969 39.287109 C 47.169969 39.710109 47.559 40 48 40 C 48.441 40 48.830031 39.710109 48.957031 39.287109 L 51.957031 29.287109 C 52.115031 28.759109 51.816109 28.201969 51.287109 28.042969 C 50.755109 27.885969 50.200969 28.183891 50.042969 28.712891 L 48 35.519531 L 45.957031 28.712891 C 45.837781 28.316141 45.496797 28.048516 45.109375 28.005859 z M 9 52 C 8.447 52 8 52.447 8 53 L 8 55 C 8 55.553 8.447 56 9 56 C 9.553 56 10 55.553 10 55 L 10 53 C 10 52.447 9.553 52 9 52 z M 14 52 C 13.447 52 13 52.447 13 53 L 13 55 C 13 55.553 13.447 56 14 56 C 14.553 56 15 55.553 15 55 L 15 53 C 15 52.447 14.553 52 14 52 z M 19 52 C 18.447 52 18 52.447 18 53 L 18 55 C 18 55.553 18.447 56 19 56 C 19.553 56 20 55.553 20 55 L 20 53 C 20 52.447 19.553 52 19 52 z M 24 52 C 23.447 52 23 52.447 23 53 L 23 55 C 23 55.553 23.447 56 24 56 C 24.553 56 25 55.553 25 55 L 25 53 C 25 52.447 24.553 52 24 52 z M 29 52 C 28.447 52 28 52.447 28 53 L 28 55 C 28 55.553 28.447 56 29 56 C 29.553 56 30 55.553 30 55 L 30 53 C 30 52.447 29.553 52 29 52 z M 34 52 C 33.447 52 33 52.447 33 53 L 33 55 C 33 55.553 33.447 56 34 56 C 34.553 56 35 55.553 35 55 L 35 53 C 35 52.447 34.553 52 34 52 z M 39 52 C 38.447 52 38 52.447 38 53 L 38 55 C 38 55.553 38.447 56 39 56 C 39.553 56 40 55.553 40 55 L 40 53 C 40 52.447 39.553 52 39 52 z M 44 52 C 43.447 52 43 52.447 43 53 L 43 55 C 43 55.553 43.447 56 44 56 C 44.553 56 45 55.553 45 55 L 45 53 C 45 52.447 44.553 52 44 52 z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<path d="M 17.660156 4 C 16.320156 4 15.059141 4.5209375 14.119141 5.4609375 L 5.4609375 14.119141 C 4.5209375 15.069141 4 16.320156 4 17.660156 L 4 57 C 4 58.65 5.35 60 7 60 L 47 60 C 48.65 60 50 58.65 50 57 L 50 46 L 58 46 C 59.1 46 60 45.1 60 44 L 60 24 C 60 22.9 59.1 22 58 22 L 50 22 L 50 7 C 50 5.35 48.65 4 47 4 L 17.660156 4 z M 18 6 L 47 6 C 47.55 6 48 6.45 48 7 L 48 22 L 16 22 C 14.9 22 14 22.9 14 24 L 14 44 C 14 45.1 14.9 46 16 46 L 48 46 L 48 57 C 48 57.55 47.55 58 47 58 L 7 58 C 6.45 58 6 57.55 6 57 L 6 18 L 15 18 C 16.654 18 18 16.654 18 15 L 18 6 z M 16 6.4980469 L 16 15 C 16 15.552 15.552 16 15 16 L 6.5019531 16 C 6.6119531 15.834 6.7388594 15.679063 6.8808594 15.539062 L 15.539062 6.8808594 C 15.681062 6.7368594 15.836 6.6080469 16 6.4980469 z M 16 24 L 48 24 L 50 24 L 58 24 L 58 44 L 50 44 L 48 44 L 16 44 L 16 24 z M 27 28 C 25.346 28 24 29.346 24 31 L 24 37 C 24 38.654 25.346 40 27 40 L 29 40 C 30.654 40 32 38.654 32 37 C 32 36.447 31.553 36 31 36 C 30.447 36 30 36.447 30 37 C 30 37.552 29.552 38 29 38 L 27 38 C 26.448 38 26 37.552 26 37 L 26 31 C 26 30.448 26.448 30 27 30 L 29 30 C 29.552 30 30 30.448 30 31 C 30 31.553 30.447 32 31 32 C 31.553 32 32 31.553 32 31 C 32 29.346 30.654 28 29 28 L 27 28 z M 37 28 C 35.346 28 34 29.346 34 31 L 34 32 C 34 33.654 35.346 35 37 35 L 39 35 C 39.552 35 40 35.448 40 36 L 40 37 C 40 37.552 39.552 38 39 38 L 37 38 C 36.448 38 36 37.552 36 37 C 36 36.447 35.553 36 35 36 C 34.447 36 34 36.447 34 37 C 34 38.654 35.346 40 37 40 L 39 40 C 40.654 40 42 38.654 42 37 L 42 36 C 42 34.346 40.654 33 39 33 L 37 33 C 36.448 33 36 32.552 36 32 L 36 31 C 36 30.448 36.448 30 37 30 L 39 30 C 39.552 30 40 30.448 40 31 C 40 31.553 40.447 32 41 32 C 41.553 32 42 31.553 42 31 C 42 29.346 40.654 28 39 28 L 37 28 z M 45.109375 28.005859 C 44.980234 27.991641 44.845391 28.003719 44.712891 28.042969 C 44.183891 28.201969 43.884969 28.759109 44.042969 29.287109 L 47.042969 39.287109 C 47.169969 39.710109 47.559 40 48 40 C 48.441 40 48.830031 39.710109 48.957031 39.287109 L 51.957031 29.287109 C 52.115031 28.759109 51.816109 28.201969 51.287109 28.042969 C 50.755109 27.885969 50.200969 28.183891 50.042969 28.712891 L 48 35.519531 L 45.957031 28.712891 C 45.837781 28.316141 45.496797 28.048516 45.109375 28.005859 z M 9 52 C 8.447 52 8 52.447 8 53 L 8 55 C 8 55.553 8.447 56 9 56 C 9.553 56 10 55.553 10 55 L 10 53 C 10 52.447 9.553 52 9 52 z M 14 52 C 13.447 52 13 52.447 13 53 L 13 55 C 13 55.553 13.447 56 14 56 C 14.553 56 15 55.553 15 55 L 15 53 C 15 52.447 14.553 52 14 52 z M 19 52 C 18.447 52 18 52.447 18 53 L 18 55 C 18 55.553 18.447 56 19 56 C 19.553 56 20 55.553 20 55 L 20 53 C 20 52.447 19.553 52 19 52 z M 24 52 C 23.447 52 23 52.447 23 53 L 23 55 C 23 55.553 23.447 56 24 56 C 24.553 56 25 55.553 25 55 L 25 53 C 25 52.447 24.553 52 24 52 z M 29 52 C 28.447 52 28 52.447 28 53 L 28 55 C 28 55.553 28.447 56 29 56 C 29.553 56 30 55.553 30 55 L 30 53 C 30 52.447 29.553 52 29 52 z M 34 52 C 33.447 52 33 52.447 33 53 L 33 55 C 33 55.553 33.447 56 34 56 C 34.553 56 35 55.553 35 55 L 35 53 C 35 52.447 34.553 52 34 52 z M 39 52 C 38.447 52 38 52.447 38 53 L 38 55 C 38 55.553 38.447 56 39 56 C 39.553 56 40 55.553 40 55 L 40 53 C 40 52.447 39.553 52 39 52 z M 44 52 C 43.447 52 43 52.447 43 53 L 43 55 C 43 55.553 43.447 56 44 56 C 44.553 56 45 55.553 45 55 L 45 53 C 45 52.447 44.553 52 44 52 z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<path d="M 17.660156 4 C 16.320156 4 15.059141 4.5209375 14.119141 5.4609375 L 5.4609375 14.119141 C 4.5209375 15.069141 4 16.320156 4 17.660156 L 4 57 C 4 58.65 5.35 60 7 60 L 47 60 C 48.65 60 50 58.65 50 57 L 50 46 L 58 46 C 59.1 46 60 45.1 60 44 L 60 24 C 60 22.9 59.1 22 58 22 L 50 22 L 50 7 C 50 5.35 48.65 4 47 4 L 17.660156 4 z M 18 6 L 47 6 C 47.55 6 48 6.45 48 7 L 48 22 L 16 22 C 14.9 22 14 22.9 14 24 L 14 44 C 14 45.1 14.9 46 16 46 L 48 46 L 48 57 C 48 57.55 47.55 58 47 58 L 7 58 C 6.45 58 6 57.55 6 57 L 6 18 L 15 18 C 16.654 18 18 16.654 18 15 L 18 6 z M 16 6.4980469 L 16 15 C 16 15.552 15.552 16 15 16 L 6.5019531 16 C 6.6119531 15.834 6.7388594 15.679063 6.8808594 15.539062 L 15.539062 6.8808594 C 15.681062 6.7368594 15.836 6.6080469 16 6.4980469 z M 16 24 L 48 24 L 50 24 L 58 24 L 58 44 L 50 44 L 48 44 L 16 44 L 16 24 z M 27 28 C 25.346 28 24 29.346 24 31 L 24 37 C 24 38.654 25.346 40 27 40 L 29 40 C 30.654 40 32 38.654 32 37 C 32 36.447 31.553 36 31 36 C 30.447 36 30 36.447 30 37 C 30 37.552 29.552 38 29 38 L 27 38 C 26.448 38 26 37.552 26 37 L 26 31 C 26 30.448 26.448 30 27 30 L 29 30 C 29.552 30 30 30.448 30 31 C 30 31.553 30.447 32 31 32 C 31.553 32 32 31.553 32 31 C 32 29.346 30.654 28 29 28 L 27 28 z M 37 28 C 35.346 28 34 29.346 34 31 L 34 32 C 34 33.654 35.346 35 37 35 L 39 35 C 39.552 35 40 35.448 40 36 L 40 37 C 40 37.552 39.552 38 39 38 L 37 38 C 36.448 38 36 37.552 36 37 C 36 36.447 35.553 36 35 36 C 34.447 36 34 36.447 34 37 C 34 38.654 35.346 40 37 40 L 39 40 C 40.654 40 42 38.654 42 37 L 42 36 C 42 34.346 40.654 33 39 33 L 37 33 C 36.448 33 36 32.552 36 32 L 36 31 C 36 30.448 36.448 30 37 30 L 39 30 C 39.552 30 40 30.448 40 31 C 40 31.553 40.447 32 41 32 C 41.553 32 42 31.553 42 31 C 42 29.346 40.654 28 39 28 L 37 28 z M 45.109375 28.005859 C 44.980234 27.991641 44.845391 28.003719 44.712891 28.042969 C 44.183891 28.201969 43.884969 28.759109 44.042969 29.287109 L 47.042969 39.287109 C 47.169969 39.710109 47.559 40 48 40 C 48.441 40 48.830031 39.710109 48.957031 39.287109 L 51.957031 29.287109 C 52.115031 28.759109 51.816109 28.201969 51.287109 28.042969 C 50.755109 27.885969 50.200969 28.183891 50.042969 28.712891 L 48 35.519531 L 45.957031 28.712891 C 45.837781 28.316141 45.496797 28.048516 45.109375 28.005859 z M 9 52 C 8.447 52 8 52.447 8 53 L 8 55 C 8 55.553 8.447 56 9 56 C 9.553 56 10 55.553 10 55 L 10 53 C 10 52.447 9.553 52 9 52 z M 14 52 C 13.447 52 13 52.447 13 53 L 13 55 C 13 55.553 13.447 56 14 56 C 14.553 56 15 55.553 15 55 L 15 53 C 15 52.447 14.553 52 14 52 z M 19 52 C 18.447 52 18 52.447 18 53 L 18 55 C 18 55.553 18.447 56 19 56 C 19.553 56 20 55.553 20 55 L 20 53 C 20 52.447 19.553 52 19 52 z M 24 52 C 23.447 52 23 52.447 23 53 L 23 55 C 23 55.553 23.447 56 24 56 C 24.553 56 25 55.553 25 55 L 25 53 C 25 52.447 24.553 52 24 52 z M 29 52 C 28.447 52 28 52.447 28 53 L 28 55 C 28 55.553 28.447 56 29 56 C 29.553 56 30 55.553 30 55 L 30 53 C 30 52.447 29.553 52 29 52 z M 34 52 C 33.447 52 33 52.447 33 53 L 33 55 C 33 55.553 33.447 56 34 56 C 34.553 56 35 55.553 35 55 L 35 53 C 35 52.447 34.553 52 34 52 z M 39 52 C 38.447 52 38 52.447 38 53 L 38 55 C 38 55.553 38.447 56 39 56 C 39.553 56 40 55.553 40 55 L 40 53 C 40 52.447 39.553 52 39 52 z M 44 52 C 43.447 52 43 52.447 43 53 L 43 55 C 43 55.553 43.447 56 44 56 C 44.553 56 45 55.553 45 55 L 45 53 C 45 52.447 44.553 52 44 52 z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -862,9 +862,11 @@ function get_parameter_checkbox($name, $default='')
*/
function get_parameter_switch($name, $default='')
{
$data = get_parameter($name, 0);
$data = get_parameter($name, null);
if ($data == 'on') {
if ($data === null) {
return 0;
} else if ($data == 'on') {
return 1;
}

View File

@ -1,3 +1,72 @@
/*
* Discovery css global
*/
li.discovery {
display: inline-block;
float: left;
width: 250px;
height: 120px;
margin: 15px;
}
li.discovery > a {
text-decoration: none;
}
li.discovery > a:hover {
color: #000;
}
li.discovery img {
height: 90px;
}
li.discovery > a label {
cursor: pointer;
}
div.data_container {
width: 100%;
height: 100%;
text-align: center;
padding-top: 30px;
padding-bottom: 30px;
}
div.data_container:hover {
box-shadow: 2px 2px 10px #ddd;
}
/*
* TODO: This may be at hostdevices.css
*/
#contenedor_principal {
height: auto;
position: relative;
margin: auto;
}
#contenedor_imagen_texto {
width: 11%;
height: auto;
position: relative;
display: inline-block;
vertical-align: top;
overflow: hidden;
margin-right: 5%;
}
#imagen {
width: 15%;
height: auto;
position: relative;
display: inline;
}
.texto {
height: auto;
text-align: center;
}
#text_wizard {
font-weight: bolder;
text-decoration: none;
font-size: 24px;
}

View File

@ -1500,6 +1500,9 @@ sub snmp_get_command {
my $command = "snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v$self->{'snmp_version'} -On -Oe ";
if ($self->{'snmp_version'} eq "3") {
if ($self->{'community'}) { # Context
$command .= " -N $self->{'community'} ";
}
$command .= " -l$self->{'snmp_security_level'} ";
if ($self->{'snmp_security_level'} ne "noAuthNoPriv") {
$command .= " -u$self->{'snmp_auth_user'} -a$self->{'snmp_auth_method'} -A$self->{'snmp_auth_pass'} ";