Merge branch 'ent-3595-discovery-fase-2' of https://brutus.artica.lan:8081/artica/pandorafms into ent-3595-discovery-fase-2
Former-commit-id: 4e097a7169f1ecb05c843076b67f98f0ea1370af
This commit is contained in:
commit
c2033715a9
|
@ -28,9 +28,10 @@
|
|||
|
||||
require_once __DIR__.'/Wizard.main.php';
|
||||
require_once $config['homedir'].'/include/functions_users.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/class/CustomNetScan.class.php');
|
||||
enterprise_include_once('include/class/ManageNetScanScripts.class.php');
|
||||
enterprise_include_once('include/functions_hostdevices.php');
|
||||
|
||||
/**
|
||||
|
@ -126,20 +127,20 @@ class HostDevices extends Wizard
|
|||
'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png',
|
||||
'label' => __('Import CSV'),
|
||||
];
|
||||
|
||||
$buttons[] = [
|
||||
'url' => $this->url.'&mode=customnetscan',
|
||||
'icon' => ENTERPRISE_DIR.'/images/wizard/customnetscan.png',
|
||||
'label' => __('Custom NetScan'),
|
||||
];
|
||||
|
||||
$buttons[] = [
|
||||
'url' => $this->url.'&mode=managenetscanscripts',
|
||||
'icon' => ENTERPRISE_DIR.'/images/wizard/managenetscanscripts.png',
|
||||
'label' => __('Manage NetScan scripts'),
|
||||
];
|
||||
}
|
||||
|
||||
$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(
|
||||
[
|
||||
[
|
||||
|
@ -165,22 +166,22 @@ class HostDevices extends Wizard
|
|||
);
|
||||
return $csv_importer->runCSV();
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode === 'customnetscan') {
|
||||
$customnetscan_importer = new CustomNetScan(
|
||||
$this->page,
|
||||
$this->breadcrum
|
||||
);
|
||||
return $customnetscan_importer->runCustomNetScan();
|
||||
}
|
||||
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 === 'managenetscanscripts') {
|
||||
$managenetscanscript_importer = new ManageNetScanScripts(
|
||||
$this->page,
|
||||
$this->breadcrum
|
||||
);
|
||||
return $managenetscanscript_importer->runManageNetScanScript();
|
||||
}
|
||||
|
||||
if ($mode == 'netscan') {
|
||||
|
|
|
@ -26,14 +26,15 @@
|
|||
* ============================================================================
|
||||
*/
|
||||
|
||||
define('CLOUDWIZARD_AWS_DESCRIPTION', 'Discovery.Cloud.AWS.EC2');
|
||||
// Begin.
|
||||
|
||||
/**
|
||||
* Global Wizard generic class. Needs to be inherited.
|
||||
*
|
||||
* Used in Hostdevices class, Applications class and others, is the core of
|
||||
* Discovery proyect.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Global Wizard generic class. Needs to be inherited.
|
||||
*
|
||||
* Used in Hostdevices class, Applications class and others, is the core of
|
||||
* Discovery proyect.
|
||||
*/
|
||||
class Wizard
|
||||
{
|
||||
|
||||
|
|
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 |
|
@ -43,9 +43,15 @@ if ($progress_task_discovery) {
|
|||
$id_task,
|
||||
90,
|
||||
460,
|
||||
50,
|
||||
'#EA5434'
|
||||
30,
|
||||
'#EA5434',
|
||||
'%',
|
||||
'',
|
||||
'#FFFFFF',
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
$result .= '</li>';
|
||||
$result .= '<li><h1>'.__('Searching devices in').' red a scanear</h1></li>';
|
||||
$result .= '<li>';
|
||||
|
@ -53,9 +59,15 @@ if ($progress_task_discovery) {
|
|||
$id_task.'_2',
|
||||
30,
|
||||
460,
|
||||
50,
|
||||
'#2751E1'
|
||||
30,
|
||||
'#2751E1',
|
||||
'%',
|
||||
'',
|
||||
'#FFFFFF',
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
$result .= '</li>';
|
||||
$result .= '<li><h1>'.__('Summary').'</h1></li>';
|
||||
$result .= '<li><span><b>'.__('Estimated').'</b>: total de host</span></li>';
|
||||
|
|
|
@ -0,0 +1,758 @@
|
|||
<?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' => $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);
|
||||
$this->printHeader();
|
||||
}
|
||||
|
||||
$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);
|
||||
$this->printHeader();
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,759 @@
|
|||
<?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' => $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);
|
||||
$this->printHeader();
|
||||
}
|
||||
|
||||
$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
|
@ -548,13 +548,28 @@ 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);
|
||||
|
|
|
@ -2202,7 +2202,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]);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1041,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');
|
||||
}
|
||||
|
|
|
@ -354,8 +354,18 @@ 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
|
||||
) {
|
||||
global $config;
|
||||
|
||||
$recipient_name = 'progress_bar_'.$id;
|
||||
|
@ -366,8 +376,19 @@ 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.',
|
||||
);
|
||||
</script>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
|
@ -1782,7 +1782,9 @@ function progress_bar_d3(
|
|||
color,
|
||||
unit,
|
||||
label,
|
||||
label_color
|
||||
label_color,
|
||||
radiusx,
|
||||
radiusy
|
||||
) {
|
||||
var startPercent = 0;
|
||||
var endPercent = parseInt(percentile) / 100;
|
||||
|
@ -1799,20 +1801,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 +1836,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);
|
||||
|
|
|
@ -4415,6 +4415,7 @@ div#header_discovery {
|
|||
width: 9px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
div#header_discovery:hover {
|
||||
|
|
|
@ -504,9 +504,9 @@ 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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -358,12 +357,12 @@ if ($new_networkmap || $save_networkmap) {
|
|||
|
||||
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(
|
||||
'Location: '.ui_get_full_url(
|
||||
$url.'&id_networkmap='.$id
|
||||
)
|
||||
);
|
||||
|
@ -733,6 +732,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');
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
@ -866,13 +866,6 @@ if ($networkmap === false) {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
$nodes_and_relations = networkmap_process_networkmap($id);
|
||||
|
||||
show_networkmap($id, $user_readonly, $nodes_and_relations, $dash_mode, $map_dash_details);
|
||||
*/
|
||||
|
||||
|
||||
include_once $config['homedir'].'/include/class/NetworkMap.class.php';
|
||||
|
||||
$map_manager = new NetworkMap(
|
||||
|
|
Loading…
Reference in New Issue