2019-02-15 18:05:59 +01:00
|
|
|
<?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';
|
2019-02-22 12:53:35 +01:00
|
|
|
require_once $config['homedir'].'/include/functions_reports.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_cron.php';
|
2019-03-01 15:26:05 +01:00
|
|
|
enterprise_include_once('include/functions_tasklist.php');
|
|
|
|
enterprise_include_once('include/functions_cron.php');
|
2019-02-15 18:05:59 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.',
|
2019-02-21 13:05:48 +01:00
|
|
|
string $icon='images/wizard/tasklist.png',
|
2019-02-15 18:05:59 +01:00
|
|
|
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.
|
|
|
|
*
|
2019-02-26 20:00:41 +01:00
|
|
|
* @param string $message Redirected input.
|
|
|
|
* @param boolean $status Redirected input.
|
|
|
|
*
|
2019-02-15 18:05:59 +01:00
|
|
|
* @return mixed Returns null if wizard is ongoing. Result if done.
|
|
|
|
*/
|
2019-02-23 12:13:54 +01:00
|
|
|
public function run($message='', $status=null)
|
2019-02-15 18:05:59 +01:00
|
|
|
{
|
2019-02-22 13:45:59 +01:00
|
|
|
global $config;
|
2019-02-15 18:05:59 +01:00
|
|
|
// Load styles.
|
|
|
|
parent::run();
|
2019-02-15 18:35:35 +01:00
|
|
|
|
2019-02-23 12:13:54 +01:00
|
|
|
$this->prepareBreadcrum(
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery',
|
|
|
|
'label' => 'Discovery',
|
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->printHeader();
|
|
|
|
|
|
|
|
// Show redirected messages from discovery.php.
|
|
|
|
if ($status === 0) {
|
|
|
|
ui_print_success_message($message);
|
|
|
|
} else if ($status !== null) {
|
|
|
|
ui_print_error_message($message);
|
|
|
|
}
|
|
|
|
|
2019-02-22 12:53:35 +01:00
|
|
|
$force_run = (bool) get_parameter('force_run');
|
|
|
|
if ($force_run === true) {
|
|
|
|
return $this->forceConsoleTask();
|
|
|
|
}
|
|
|
|
|
|
|
|
$delete_console_task = (bool) get_parameter('delete_console_task');
|
|
|
|
if ($delete_console_task === true) {
|
|
|
|
return $this->deleteConsoleTask();
|
|
|
|
}
|
2019-02-15 18:35:35 +01:00
|
|
|
|
2019-02-22 12:53:35 +01:00
|
|
|
$delete = (bool) get_parameter('delete', false);
|
|
|
|
if ($delete === true) {
|
2019-02-15 18:35:35 +01:00
|
|
|
return $this->deleteTask();
|
|
|
|
}
|
|
|
|
|
2019-02-25 11:29:39 +01:00
|
|
|
if (enterprise_installed()) {
|
|
|
|
// This check only applies to enterprise users.
|
2019-02-26 20:00:41 +01:00
|
|
|
enterprise_hook('tasklist_checkrunning');
|
2019-02-25 11:29:39 +01:00
|
|
|
|
2019-02-26 20:00:41 +01:00
|
|
|
$ret = $this->showListConsoleTask();
|
|
|
|
} else {
|
|
|
|
$ret = false;
|
2019-02-25 11:29:39 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 13:45:59 +01:00
|
|
|
$ret2 = $this->showList();
|
|
|
|
|
|
|
|
if ($ret === false && $ret2 === false) {
|
|
|
|
include_once $config['homedir'].'/general/firts_task/recon_view.php';
|
2019-02-26 20:00:41 +01:00
|
|
|
} else {
|
|
|
|
$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,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
2019-02-22 13:45:59 +01:00
|
|
|
|
2019-02-26 20:23:52 +01:00
|
|
|
$this->printForm($form);
|
|
|
|
}
|
2019-02-26 20:00:41 +01:00
|
|
|
|
2019-02-22 13:45:59 +01:00
|
|
|
return $ret;
|
2019-02-15 18:05:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements load method.
|
|
|
|
*
|
|
|
|
* @return mixed Skeleton for button.
|
|
|
|
*/
|
|
|
|
public function load()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'icon' => $this->icon,
|
|
|
|
'label' => $this->label,
|
|
|
|
'url' => $this->url,
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-15 18:35:35 +01:00
|
|
|
/**
|
|
|
|
* 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) {
|
2019-02-21 18:00:50 +01:00
|
|
|
$result = db_process_sql_delete(
|
2019-02-15 18:35:35 +01:00
|
|
|
'trecon_task',
|
|
|
|
['id_rt' => $task]
|
|
|
|
);
|
2019-02-21 18:00:50 +01:00
|
|
|
|
|
|
|
if ($result == 1) {
|
|
|
|
return [
|
|
|
|
'result' => 0,
|
|
|
|
'msg' => __('Task successfully deleted'),
|
|
|
|
'id' => false,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trick to avoid double execution.
|
|
|
|
header('Location: '.$this->url);
|
2019-02-15 18:35:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-22 12:53:35 +01:00
|
|
|
/**
|
|
|
|
* Force console task.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function forceConsoleTask()
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
$id_console_task = (int) get_parameter('id_console_task');
|
|
|
|
|
|
|
|
if ($id_console_task !== null) {
|
2019-03-01 15:26:05 +01:00
|
|
|
enterprise_hook('cron_task_run', $id_console_task, true);
|
2019-02-22 12:53:35 +01:00
|
|
|
// Trick to avoid double execution.
|
|
|
|
header('Location: '.$this->url);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a Console task.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function deleteConsoleTask()
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
$id_console_task = (int) get_parameter('id_console_task');
|
|
|
|
|
|
|
|
if ($id_console_task !== null) {
|
|
|
|
$result = db_process_sql_delete(
|
|
|
|
'tuser_task_scheduled',
|
|
|
|
['id' => $id_console_task]
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($result == 1) {
|
|
|
|
return [
|
|
|
|
'result' => 0,
|
|
|
|
'msg' => __('Console Task successfully deleted'),
|
|
|
|
'id' => false,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trick to avoid double execution.
|
|
|
|
header('Location: '.$this->url);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-15 18:05:59 +01:00
|
|
|
/**
|
|
|
|
* 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';
|
2019-02-15 18:35:35 +01:00
|
|
|
return false;
|
2019-02-15 18:05:59 +01:00
|
|
|
}
|
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
// Get all discovery servers.
|
2019-02-15 18:05:59 +01:00
|
|
|
$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'));
|
2019-02-26 20:23:52 +01:00
|
|
|
$check = db_get_all_rows_sql('SELECT * FROM trecon_task');
|
|
|
|
return (bool) $check;
|
2019-02-15 18:05:59 +01:00
|
|
|
} else {
|
2019-02-26 20:00:41 +01:00
|
|
|
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'
|
|
|
|
)
|
2019-02-22 12:53:35 +01:00
|
|
|
);
|
2019-02-26 20:00:41 +01:00
|
|
|
}
|
|
|
|
}
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-03-01 11:08:49 +01:00
|
|
|
$recon_tasks = db_get_all_rows_sql('SELECT * FROM trecon_task');
|
|
|
|
$user_groups = implode(',', array_keys(users_get_groups()));
|
2019-02-15 18:05:59 +01:00
|
|
|
|
2019-03-01 11:08:49 +01:00
|
|
|
// Show network tasks for Recon Server.
|
2019-02-28 12:00:43 +01:00
|
|
|
if ($recon_tasks === false) {
|
|
|
|
$recon_tasks = [];
|
|
|
|
}
|
2019-02-15 18:05:59 +01:00
|
|
|
|
2019-02-26 20:00:41 +01:00
|
|
|
$table = new StdClass();
|
|
|
|
$table->cellpadding = 4;
|
|
|
|
$table->cellspacing = 4;
|
|
|
|
$table->width = '100%';
|
|
|
|
$table->class = 'databox data';
|
|
|
|
$table->head = [];
|
|
|
|
$table->data = [];
|
|
|
|
$table->align = [];
|
|
|
|
$table->headstyle = [];
|
2019-02-28 12:00:43 +01:00
|
|
|
for ($i = 0; $i < 9; $i++) {
|
|
|
|
$table->headstyle[$i] = 'text-align: left;';
|
|
|
|
}
|
2019-02-15 18:05:59 +01:00
|
|
|
|
2019-02-26 20:00:41 +01:00
|
|
|
$table->head[0] = __('Force');
|
|
|
|
$table->align[0] = 'left';
|
2019-02-15 18:05:59 +01:00
|
|
|
|
2019-02-26 20:00:41 +01:00
|
|
|
$table->head[1] = __('Task name');
|
|
|
|
$table->align[1] = 'left';
|
2019-02-15 18:05:59 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
$table->head[2] = __('Server name');
|
2019-02-26 20:00:41 +01:00
|
|
|
$table->align[2] = 'left';
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
$table->head[3] = __('Interval');
|
2019-02-26 20:00:41 +01:00
|
|
|
$table->align[3] = 'left';
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
$table->head[4] = __('Network');
|
2019-02-26 20:00:41 +01:00
|
|
|
$table->align[4] = 'left';
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
$table->head[5] = __('Status');
|
2019-02-26 20:00:41 +01:00
|
|
|
$table->align[5] = 'left';
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
$table->head[6] = __('Task type');
|
2019-02-26 20:00:41 +01:00
|
|
|
$table->align[6] = 'left';
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
$table->head[7] = __('Progress');
|
2019-02-26 20:00:41 +01:00
|
|
|
$table->align[7] = 'left';
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
$table->head[8] = __('Updated at');
|
2019-02-26 20:00:41 +01:00
|
|
|
$table->align[8] = 'left';
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
$table->head[9] = __('Operations');
|
|
|
|
$table->align[9] = 'left';
|
|
|
|
|
|
|
|
foreach ($recon_tasks as $task) {
|
|
|
|
$data = [];
|
|
|
|
$server_name = servers_get_name($task['id_recon_server']);
|
|
|
|
|
|
|
|
// By default.
|
|
|
|
$subnet = $task['subnet'];
|
|
|
|
|
|
|
|
// Exceptions: IPAM.
|
|
|
|
$ipam = false;
|
|
|
|
if ($task['id_recon_script'] != null) {
|
|
|
|
$recon_script_name = db_get_value('name', 'trecon_script', 'id_recon_script', $task['id_recon_script']);
|
2019-03-01 11:08:49 +01:00
|
|
|
if (io_safe_output($recon_script_name) == 'IPAM Recon'
|
|
|
|
&& enterprise_installed()
|
|
|
|
) {
|
2019-02-28 12:00:43 +01:00
|
|
|
$subnet_obj = json_decode($task['macros'], true);
|
|
|
|
$subnet = $subnet_obj['1']['value'];
|
|
|
|
$tipam_task_id = db_get_value('id', 'tipam_network', 'id_recon_task', $task['id_rt']);
|
|
|
|
$ipam = true;
|
2019-02-26 20:00:41 +01:00
|
|
|
}
|
2019-02-28 12:00:43 +01:00
|
|
|
}
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
if ($task['disabled'] == 0 && $server_name !== '') {
|
|
|
|
$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 if ($task['disabled'] == 2) {
|
|
|
|
$data[0] = ui_print_help_tip(
|
|
|
|
__('This task has not been completely defined, please edit it'),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$data[0] = '';
|
|
|
|
}
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
$data[1] = '<b>'.$task['name'].'</b>';
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
$data[2] = $server_name;
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
if ($task['interval_sweep'] > 0) {
|
|
|
|
$data[3] = human_time_description_raw(
|
|
|
|
$task['interval_sweep']
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$data[3] = __('Manual');
|
|
|
|
}
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
if ($task['id_recon_script'] == 0 || $ipam === true) {
|
|
|
|
$data[4] = $subnet;
|
|
|
|
} else {
|
|
|
|
$data[4] = '-';
|
|
|
|
}
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
if ($task['status'] <= 0) {
|
|
|
|
$data[5] = __('Done');
|
|
|
|
} else {
|
|
|
|
$data[5] = __('Pending');
|
|
|
|
}
|
2019-02-26 20:00:41 +01:00
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
if ($task['id_recon_script'] == 0) {
|
|
|
|
// Discovery NetScan.
|
|
|
|
$data[6] = html_print_image(
|
|
|
|
'images/network.png',
|
|
|
|
true,
|
|
|
|
['title' => __('Discovery NetScan')]
|
|
|
|
).' ';
|
|
|
|
$data[6] .= network_profiles_get_name(
|
|
|
|
$task['id_network_profile']
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// APP recon task.
|
|
|
|
$data[6] = html_print_image(
|
|
|
|
'images/plugin.png',
|
|
|
|
true
|
|
|
|
).' ';
|
|
|
|
$data[6] .= $recon_script_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($task['status'] <= 0 || $task['status'] > 100) {
|
|
|
|
$data[7] = '-';
|
|
|
|
} else {
|
|
|
|
$data[7] = progress_bar(
|
|
|
|
$task['status'],
|
|
|
|
100,
|
|
|
|
20,
|
|
|
|
__('Progress').':'.$task['status'].'%',
|
|
|
|
1
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($task['utimestamp'] > 0) {
|
|
|
|
$data[8] = ui_print_timestamp(
|
|
|
|
$task['utimestamp'],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$data[8] = __('Not executed yet');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (check_acl(
|
|
|
|
$config['id_user'],
|
|
|
|
$task['id_group'],
|
|
|
|
'PM'
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
if ($ipam === true) {
|
|
|
|
$data[9] = '<a href="'.ui_get_full_url(
|
|
|
|
sprintf(
|
|
|
|
'index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=edit&id=%d',
|
|
|
|
$tipam_task_id
|
|
|
|
)
|
|
|
|
).'">'.html_print_image(
|
|
|
|
'images/config.png',
|
2019-02-26 20:00:41 +01:00
|
|
|
true
|
2019-02-28 12:00:43 +01:00
|
|
|
).'</a>';
|
|
|
|
$data[9] .= '<a href="'.ui_get_full_url(
|
|
|
|
'index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=delete&id='.$tipam_task_id
|
|
|
|
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
|
|
|
|
'images/cross.png',
|
|
|
|
true
|
|
|
|
).'</a>';
|
2019-02-26 20:00:41 +01:00
|
|
|
} else {
|
2019-02-28 12:00:43 +01:00
|
|
|
// Check if is a H&D, Cloud or Application or IPAM.
|
|
|
|
$data[9] = '<a href="'.ui_get_full_url(
|
2019-02-22 13:45:59 +01:00
|
|
|
sprintf(
|
|
|
|
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&task=%d',
|
2019-02-26 20:00:41 +01:00
|
|
|
$this->getTargetWiz($task),
|
|
|
|
$task['id_rt']
|
2019-02-22 13:45:59 +01:00
|
|
|
)
|
2019-02-26 20:00:41 +01:00
|
|
|
).'">'.html_print_image(
|
2019-02-22 12:53:35 +01:00
|
|
|
'images/config.png',
|
2019-02-26 20:00:41 +01:00
|
|
|
true
|
2019-02-22 13:45:59 +01:00
|
|
|
).'</a>';
|
2019-02-28 12:00:43 +01:00
|
|
|
$data[9] .= '<a href="'.ui_get_full_url(
|
2019-02-26 20:00:41 +01:00
|
|
|
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&delete=1&task='.$task['id_rt']
|
|
|
|
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
|
2019-02-22 12:53:35 +01:00
|
|
|
'images/cross.png',
|
2019-02-26 20:00:41 +01:00
|
|
|
true
|
|
|
|
).'</a>';
|
2019-02-22 12:53:35 +01:00
|
|
|
}
|
2019-02-28 12:00:43 +01:00
|
|
|
} else {
|
|
|
|
$data[9] = '';
|
2019-02-22 12:53:35 +01:00
|
|
|
}
|
|
|
|
|
2019-02-28 12:00:43 +01:00
|
|
|
array_push($table->data, $data);
|
|
|
|
}
|
|
|
|
|
2019-02-26 20:00:41 +01:00
|
|
|
echo '<h2>'.__('Server tasks').'</h2>';
|
2019-02-28 12:00:43 +01:00
|
|
|
if (empty($table->data)) {
|
|
|
|
echo '<div class="nf">'.__('Server').' '.$server_name.' '.__('has no discovery tasks assigned').'</div>';
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
html_print_table($table);
|
|
|
|
}
|
2019-02-22 12:53:35 +01:00
|
|
|
|
2019-02-26 20:00:41 +01:00
|
|
|
unset($table);
|
2019-02-22 12:53:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-26 20:00:41 +01:00
|
|
|
/**
|
|
|
|
* Show complete list of running tasks.
|
|
|
|
*
|
|
|
|
* @return boolean Success or not.
|
|
|
|
*/
|
|
|
|
public function showListConsoleTask()
|
|
|
|
{
|
|
|
|
return enterprise_hook('tasklist_showListConsoleTask', [$this]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-19 20:27:05 +01:00
|
|
|
/**
|
|
|
|
* Return target url sub-string to edit target task.
|
|
|
|
*
|
|
|
|
* @param array $task With all data.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getTargetWiz($task)
|
|
|
|
{
|
|
|
|
// TODO: Do not use description. Use recon_script ID instead.
|
|
|
|
switch ($task['description']) {
|
|
|
|
case 'Discovery.Application.VMware':
|
2019-02-21 15:35:44 +01:00
|
|
|
return 'wiz=app&mode=vmware&page=0';
|
|
|
|
|
|
|
|
case CLOUDWIZARD_AWS_DESCRIPTION:
|
|
|
|
return 'wiz=cloud&mode=amazonws&page=1';
|
2019-02-19 20:27:05 +01:00
|
|
|
|
2019-02-22 13:45:59 +01:00
|
|
|
case 'console_task':
|
|
|
|
return 'wiz=ctask';
|
|
|
|
|
2019-02-19 20:27:05 +01:00
|
|
|
default:
|
2019-03-06 17:14:32 +01:00
|
|
|
if ($task['id_recon_script'] === null) {
|
|
|
|
return 'wiz=hd&mode=netscan';
|
|
|
|
} else {
|
|
|
|
return 'wiz=hd&mode=customnetscan';
|
|
|
|
}
|
2019-02-19 20:27:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-15 18:05:59 +01:00
|
|
|
}
|