Merge branch 'ent-3431-discovery-host-devices' into 'ent-3430-discovery'
Ent 3431 discovery host devices See merge request artica/pandorafms!2170 Former-commit-id: a6b76549bbc925fa6c48a01b88e57895a8aa9f3e
This commit is contained in:
commit
219ad87bda
|
@ -1406,6 +1406,9 @@ ALTER TABLE twidget_dashboard MODIFY options LONGTEXT NOT NULL default "";
|
|||
ALTER TABLE trecon_task ADD `alias_as_name` int(2) unsigned default '0';
|
||||
ALTER TABLE trecon_task ADD `snmp_enabled` int(2) unsigned default '0';
|
||||
ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0';
|
||||
ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0';
|
||||
ALTER TABLE trecon_task ADD `auth_strings` text;
|
||||
ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0';
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `twidget` AND Table `twidget_dashboard`
|
||||
|
|
|
@ -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' => __('Recon server')]); ?>
|
||||
<?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>
|
||||
|
|
|
@ -200,11 +200,18 @@ if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, '
|
|||
$menu_godmode['gservers']['id'] = 'god-servers';
|
||||
|
||||
$sub = [];
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
$sub['godmode/servers/discovery']['text'] = __('Discover');
|
||||
$sub['godmode/servers/discovery']['id'] = 'Discover';
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||
$sub['godmode/servers/modificar_server']['text'] = __('Manage servers');
|
||||
$sub['godmode/servers/modificar_server']['id'] = 'Manage servers';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This subtabs are only for Pandora Admin
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
enterprise_hook('ha_cluster');
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'AW')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Server Management'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
ui_require_css_file('discovery');
|
||||
|
||||
ui_print_page_header(__('Discover'), '', false, '', true);
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param [type] $str
|
||||
* @return void
|
||||
*/
|
||||
function get_wiz_class($str)
|
||||
{
|
||||
switch ($str) {
|
||||
case 'hd':
|
||||
return 'HostDevices';
|
||||
|
||||
case 'tasklist':
|
||||
return 'DiscoveryTaskList';
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CLASS LOADER.
|
||||
*/
|
||||
|
||||
// Dynamic class loader.
|
||||
$classes = glob($config['homedir'].'/godmode/wizards/*.class.php');
|
||||
foreach ($classes as $classpath) {
|
||||
include_once $classpath;
|
||||
}
|
||||
|
||||
|
||||
$wiz_in_use = get_parameter('wiz', null);
|
||||
$page = get_parameter('page', 0);
|
||||
|
||||
$classname_selected = get_wiz_class($wiz_in_use);
|
||||
|
||||
// Else: class not found pseudo exception.
|
||||
if ($classname_selected !== null) {
|
||||
$wiz = new $classname_selected($page);
|
||||
$result = $wiz->run();
|
||||
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) {
|
||||
// Load classes and print selector.
|
||||
$wiz_data = [];
|
||||
foreach ($classes as $classpath) {
|
||||
$classname = basename($classpath, '.class.php');
|
||||
$obj = new $classname();
|
||||
$wiz_data[] = $obj->load();
|
||||
}
|
||||
|
||||
Wizard::printBigButtonsList($wiz_data);
|
||||
}
|
|
@ -248,9 +248,9 @@ $table->rowclass[17] = 'recon_script';
|
|||
$table->data[0][0] = '<b>'.__('Task name').'</b>';
|
||||
$table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true);
|
||||
|
||||
// Recon server
|
||||
$table->data[1][0] = '<b>'.__('Recon server').ui_print_help_tip(
|
||||
__('You must select a Recon Server for the Task, otherwise the Recon Task will never run'),
|
||||
// Discovery server
|
||||
$table->data[1][0] = '<b>'.__('Discovery server').ui_print_help_tip(
|
||||
__('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'),
|
||||
true
|
||||
);
|
||||
|
||||
|
|
|
@ -32,12 +32,6 @@ require_once $config['homedir'].'/include/functions_notifications.php';
|
|||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
|
||||
db_pandora_audit('ACL Violation', 'Trying to access Setup Management');
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
// AJAX actions.
|
||||
$source = get_parameter('source', '');
|
||||
$users = get_parameter('users', '');
|
||||
|
@ -102,6 +96,10 @@ if (get_parameter('check_new_notifications', 0)) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (messages_get_count() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$messages = messages_get_overview(
|
||||
'timestamp',
|
||||
'ASC',
|
||||
|
|
|
@ -0,0 +1,376 @@
|
|||
<?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')]).' ';
|
||||
$data[5] .= network_profiles_get_name($task['id_network_profile']);
|
||||
} else {
|
||||
// APP recon task.
|
||||
$data[5] = html_print_image('images/plugin.png', true).' ';
|
||||
$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')) {
|
||||
// Check if is a H&D, Cloud or Application.
|
||||
$data[8] = '<a href="'.ui_get_full_url(
|
||||
sprintf(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&page=0&task=%d',
|
||||
$this->getTargetWiz($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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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':
|
||||
return 'wiz=app&mode=vmware';
|
||||
|
||||
default:
|
||||
return 'wiz=hd&mode=netscan';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,614 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Interfaz tope gama que obliga a implementar metodos.
|
||||
*/
|
||||
class Wizard
|
||||
{
|
||||
|
||||
/**
|
||||
* Breadcrum
|
||||
*
|
||||
* @var array.
|
||||
*/
|
||||
public $breadcrum;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param array $str Breadcrum.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setBreadcrum(array $str)
|
||||
{
|
||||
$this->breadcrum = $str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for breadcrum
|
||||
*
|
||||
* @return array Breadcrum.
|
||||
*/
|
||||
public function getBreadcrum()
|
||||
{
|
||||
return $this->breadcrum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setter for label
|
||||
*
|
||||
* @param string $str Label.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setLabel(string $str)
|
||||
{
|
||||
$this->label = $str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for label
|
||||
*
|
||||
* @return array Breadcrum.
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return units associated to target interval (in seconds).
|
||||
*
|
||||
* @param integer $interval Target interval.
|
||||
*
|
||||
* @return integer Unit.
|
||||
*/
|
||||
public function getTimeUnit($interval)
|
||||
{
|
||||
$units = [
|
||||
1,
|
||||
60,
|
||||
3600,
|
||||
86400,
|
||||
604800,
|
||||
2592000,
|
||||
31104000,
|
||||
];
|
||||
|
||||
$size = count($units);
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
if ($interval < $units[$i]) {
|
||||
if (($i - 1) < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return $units[($i - 1)];
|
||||
}
|
||||
}
|
||||
|
||||
return $units[-1];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builder for breadcrum
|
||||
*
|
||||
* @param array $urls Array of urls to be stored in breadcrum.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function prepareBreadcrum(array $urls)
|
||||
{
|
||||
$bc = [];
|
||||
$i = 0;
|
||||
foreach ($urls as $url) {
|
||||
if ($url['selected'] == 1) {
|
||||
$class = 'selected';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
|
||||
$bc[$i] = '<a href="'.$url['link'].'" class="text_color">';
|
||||
$bc[$i] .= '<div class="arrow_box '.$class.'">'.$url['label'];
|
||||
$bc[$i++] .= '</div></a>';
|
||||
}
|
||||
|
||||
$this->setBreadcrum($bc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To be overwritten.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
ui_require_css_file('wizard');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To be overwritten.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print breadcrum to follow flow.
|
||||
*
|
||||
* @return string Breadcrum HTML code.
|
||||
*/
|
||||
public function printBreadcrum()
|
||||
{
|
||||
return '<h1>'.implode('', $this->breadcrum).'</h1>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a header for current wizard.
|
||||
*
|
||||
* @param boolean $return Return HTML or print it.
|
||||
*
|
||||
* @return string HTML code for header.
|
||||
*/
|
||||
public function printHeader(bool $return=false)
|
||||
{
|
||||
$output = $this->printBreadcrum();
|
||||
if ($return === false) {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print input using functions html lib.
|
||||
*
|
||||
* @param array $data Input definition.
|
||||
*
|
||||
* @return string HTML code for desired input.
|
||||
*/
|
||||
public function printInput($data)
|
||||
{
|
||||
if (is_array($data) === false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
switch ($data['type']) {
|
||||
case 'text':
|
||||
return html_print_input_text(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : true),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||
);
|
||||
|
||||
case 'image':
|
||||
return html_print_input_image(
|
||||
$data['name'],
|
||||
$data['src'],
|
||||
$data['value'],
|
||||
((isset($data['style']) === true) ? $data['style'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
|
||||
case 'text_extended':
|
||||
return html_print_input_text_extended(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
$data['id'],
|
||||
$data['alt'],
|
||||
$data['size'],
|
||||
$data['maxlength'],
|
||||
$data['disabled'],
|
||||
$data['script'],
|
||||
$data['attributes'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['password']) === true) ? $data['password'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : '')
|
||||
);
|
||||
|
||||
case 'password':
|
||||
return html_print_input_password(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : '')
|
||||
);
|
||||
|
||||
case 'text':
|
||||
return html_print_input_text(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||
);
|
||||
|
||||
case 'image':
|
||||
return html_print_input_image(
|
||||
$data['name'],
|
||||
$data['src'],
|
||||
$data['value'],
|
||||
((isset($data['style']) === true) ? $data['style'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
|
||||
case 'hidden':
|
||||
return html_print_input_hidden(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : false)
|
||||
);
|
||||
|
||||
case 'hidden_extended':
|
||||
return html_print_input_hidden_extended(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
$data['id'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : false)
|
||||
);
|
||||
|
||||
case 'color':
|
||||
return html_print_input_color(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['class']) === true) ? $data['class'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false)
|
||||
);
|
||||
|
||||
case 'file':
|
||||
return html_print_input_file(
|
||||
$data['name'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
|
||||
case 'select':
|
||||
return html_print_select(
|
||||
$data['fields'],
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['modal']) === true) ? $data['modal'] : false),
|
||||
((isset($data['message']) === true) ? $data['message'] : ''),
|
||||
((isset($data['select_all']) === true) ? $data['select_all'] : false)
|
||||
);
|
||||
|
||||
case 'select_from_sql':
|
||||
return html_print_select_from_sql(
|
||||
$data['sql'],
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT)
|
||||
);
|
||||
|
||||
case 'select_groups':
|
||||
return html_print_select_groups(
|
||||
((isset($data['id_user']) === true) ? $data['id_user'] : false),
|
||||
((isset($data['privilege']) === true) ? $data['privilege'] : 'AR'),
|
||||
((isset($data['returnAllGroup']) === true) ? $data['returnAllGroup'] : true),
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||
((isset($data['id_group']) === true) ? $data['id_group'] : false),
|
||||
((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'),
|
||||
((isset($data['strict_user']) === true) ? $data['strict_user'] : false),
|
||||
((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false),
|
||||
((isset($data['include_groups']) === true) ? $data['include_groups'] : false)
|
||||
);
|
||||
|
||||
case 'submit':
|
||||
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(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['checked']) === true) ? $data['checked'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['disabled_hidden']) === true) ? $data['disabled_hidden'] : false)
|
||||
);
|
||||
|
||||
case 'switch':
|
||||
return html_print_switch($data);
|
||||
|
||||
case 'textarea':
|
||||
return html_print_textarea(
|
||||
$data['name'],
|
||||
$data['rows'],
|
||||
$data['columns'],
|
||||
((isset($data['value']) === true) ? $data['value'] : ''),
|
||||
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : '')
|
||||
);
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a go back button redirecting to main page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function printGoBackButton($url=null)
|
||||
{
|
||||
if (isset($url) === false) {
|
||||
$url = ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery'
|
||||
);
|
||||
}
|
||||
|
||||
$form = [
|
||||
'form' => [
|
||||
'method' => 'POST',
|
||||
'action' => $url,
|
||||
],
|
||||
'inputs' => [
|
||||
[
|
||||
'arguments' => [
|
||||
'name' => 'submit',
|
||||
'label' => __('Go back'),
|
||||
'type' => 'submit',
|
||||
'attributes' => 'class="sub cancel"',
|
||||
'return' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$this->printForm($form);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a block of inputs.
|
||||
*
|
||||
* @param array $input Definition of target block to be printed.
|
||||
* @param boolean $return Return as string or direct output.
|
||||
*
|
||||
* @return string HTML content.
|
||||
*/
|
||||
public function printBlock(array $input, bool $return=false)
|
||||
{
|
||||
$output = '';
|
||||
if ($input['hidden'] == 1) {
|
||||
$class = ' class="hidden"';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
|
||||
if (is_array($input['block_content']) === true) {
|
||||
// Print independent block of inputs.
|
||||
$output .= '<li id="'.$input['block_id'].'" '.$class.'>';
|
||||
$output .= '<ul class="wizard">';
|
||||
foreach ($input['block_content'] as $input) {
|
||||
$output .= $this->printBlock($input, $return);
|
||||
}
|
||||
|
||||
$output .= '</ul></li>';
|
||||
} else {
|
||||
if ($input['arguments']['type'] != 'hidden') {
|
||||
$output .= '<li id="'.$input['id'].'" '.$class.'>';
|
||||
$output .= '<label>'.$input['label'].'</label>';
|
||||
$output .= $this->printInput($input['arguments']);
|
||||
// Allow dynamic content.
|
||||
$output .= $input['extra'];
|
||||
$output .= '</li>';
|
||||
} else {
|
||||
$output .= $this->printInput($input['arguments']);
|
||||
// Allow dynamic content.
|
||||
$output .= $input['extra'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($return === false) {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a form.
|
||||
*
|
||||
* @param array $data Definition of target form to be printed.
|
||||
* @param boolean $return Return as string or direct output.
|
||||
*
|
||||
* @return string HTML code.
|
||||
*/
|
||||
public function printForm(array $data, bool $return=false)
|
||||
{
|
||||
$form = $data['form'];
|
||||
$inputs = $data['inputs'];
|
||||
$js = $data['js'];
|
||||
|
||||
$output = '<form enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
|
||||
$output .= '" '.$form['extra'].'>';
|
||||
|
||||
$output .= '<ul class="wizard">';
|
||||
|
||||
foreach ($inputs as $input) {
|
||||
$output .= $this->printBlock($input, true);
|
||||
}
|
||||
|
||||
$output .= '</ul>';
|
||||
$output .= '</form>';
|
||||
$output .= '<script>'.$js.'</script>';
|
||||
|
||||
if ($return === false) {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a big button element (huge image, big text and link).
|
||||
*
|
||||
* @param array $data Element data (link, image...).
|
||||
*
|
||||
* @return void Only prints the element.
|
||||
*/
|
||||
public static function printBigButtonElement($data)
|
||||
{
|
||||
if (isset($data['url']) === false) {
|
||||
$data['url'] = '#';
|
||||
}
|
||||
|
||||
?>
|
||||
<li class="discovery">
|
||||
<a href="<?php echo $data['url']; ?>">
|
||||
<div class="data_container">
|
||||
<?php html_print_image($data['icon']); ?>
|
||||
<br><label id="text_wizard">
|
||||
<?php echo io_safe_output($data['label']); ?>
|
||||
</label>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a list of big buttons elements.
|
||||
*
|
||||
* @param array $list_data Array of data for printBigButtonElement.
|
||||
*
|
||||
* @return void Print the full list.
|
||||
*/
|
||||
public static function printBigButtonsList($list_data)
|
||||
{
|
||||
echo '<ul>';
|
||||
array_map('self::printBigButtonElement', $list_data);
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
global $config;
|
||||
require $config['homedir'].'/godmode/wizards/Wizard.interface.php';
|
||||
|
||||
$obj = new HostDevices();
|
||||
|
||||
$obj->load();
|
|
@ -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 |
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
||||
<path style="line-height:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;block-progression:tb;isolation:auto;mix-blend-mode:normal" d="M 4 5 L 4 6 L 4 13 L 28 13 L 28 5 L 4 5 z M 6 7 L 26 7 L 26 11 L 6 11 L 6 7 z M 8 8 A 1 1 0 0 0 7 9 A 1 1 0 0 0 8 10 A 1 1 0 0 0 9 9 A 1 1 0 0 0 8 8 z M 11 8 A 1 1 0 0 0 10 9 A 1 1 0 0 0 11 10 A 1 1 0 0 0 12 9 A 1 1 0 0 0 11 8 z M 14 8 A 1 1 0 0 0 13 9 A 1 1 0 0 0 14 10 A 1 1 0 0 0 15 9 A 1 1 0 0 0 14 8 z M 4 14 L 4 27 L 28 27 L 28 14 L 26 14 L 26 25 L 6 25 L 6 14 L 4 14 z M 8 15 L 8 16 L 8 23 L 16 23 L 16 15 L 8 15 z M 18 15 L 18 17 L 24 17 L 24 15 L 18 15 z M 10 17 L 14 17 L 14 21 L 10 21 L 10 17 z M 18 18 L 18 20 L 24 20 L 24 18 L 18 18 z M 18 21 L 18 23 L 24 23 L 24 21 L 18 21 z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 913 B |
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
|
||||
<path style="line-height:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;block-progression:tb;isolation:auto;mix-blend-mode:normal" d="M 1.5 3 A 0.50005 0.50005 0 0 0 1 3.5 L 1 5.5 A 0.50005 0.50005 0 0 0 1.5 6 L 3.5 6 A 0.50005 0.50005 0 0 0 4 5.5 L 4 3.5 A 0.50005 0.50005 0 0 0 3.5 3 L 1.5 3 z M 8.5 3 A 0.50005 0.50005 0 0 0 8 3.5 L 8 5.5 A 0.50005 0.50005 0 0 0 8.5 6 L 10.5 6 A 0.50005 0.50005 0 0 0 11 5.5 L 11 3.5 A 0.50005 0.50005 0 0 0 10.5 3 L 8.5 3 z M 2 4 L 3 4 L 3 5 L 2 5 L 2 4 z M 5 4 L 5 5 L 7 5 L 7 4 L 5 4 z M 9 4 L 10 4 L 10 5 L 9 5 L 9 4 z M 12 4 L 12 5 L 14 5 L 14 4 L 12 4 z M 1.5 7 A 0.50005 0.50005 0 0 0 1 7.5 L 1 9.5 A 0.50005 0.50005 0 0 0 1.5 10 L 3.5 10 A 0.50005 0.50005 0 0 0 4 9.5 L 4 7.5 A 0.50005 0.50005 0 0 0 3.5 7 L 1.5 7 z M 8.5 7 A 0.50005 0.50005 0 0 0 8 7.5 L 8 9.5 A 0.50005 0.50005 0 0 0 8.5 10 L 10.5 10 A 0.50005 0.50005 0 0 0 11 9.5 L 11 7.5 A 0.50005 0.50005 0 0 0 10.5 7 L 8.5 7 z M 2 8 L 3 8 L 3 9 L 2 9 L 2 8 z M 5 8 L 5 9 L 7 9 L 7 8 L 5 8 z M 9 8 L 10 8 L 10 9 L 9 9 L 9 8 z M 12 8 L 12 9 L 14 9 L 14 8 L 12 8 z M 1.5 11 A 0.50005 0.50005 0 0 0 1 11.5 L 1 13.5 A 0.50005 0.50005 0 0 0 1.5 14 L 3.5 14 A 0.50005 0.50005 0 0 0 4 13.5 L 4 11.5 A 0.50005 0.50005 0 0 0 3.5 11 L 1.5 11 z M 8.5 11 A 0.50005 0.50005 0 0 0 8 11.5 L 8 13.5 A 0.50005 0.50005 0 0 0 8.5 14 L 10.5 14 A 0.50005 0.50005 0 0 0 11 13.5 L 11 11.5 A 0.50005 0.50005 0 0 0 10.5 11 L 8.5 11 z M 2 12 L 3 12 L 3 13 L 2 13 L 2 12 z M 5 12 L 5 13 L 7 13 L 7 12 L 5 12 z M 9 12 L 10 12 L 10 13 L 9 13 L 9 12 z M 12 12 L 12 13 L 14 13 L 14 12 L 12 12 z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.7 KiB |
|
@ -501,6 +501,7 @@ class ConsoleSupervisor
|
|||
case 'NOTIF.UPDATEMANAGER.OPENSETUP':
|
||||
case 'NOTIF.UPDATEMANAGER.UPDATE':
|
||||
case 'NOTIF.UPDATEMANAGER.MINOR':
|
||||
case 'NOTIF.CRON.CONFIGURED':
|
||||
default:
|
||||
// NOTIF.SERVER.STATUS.
|
||||
// NOTIF.SERVER.STATUS.ID_SERVER.
|
||||
|
@ -937,57 +938,66 @@ class ConsoleSupervisor
|
|||
);
|
||||
|
||||
$time = time();
|
||||
foreach ($queue_state as $queue) {
|
||||
$key = $queue['id_server'];
|
||||
$type = $queue['server_type'];
|
||||
$new_data[$key] = $queue['queued_modules'];
|
||||
if (is_array($queue_state) === true) {
|
||||
foreach ($queue_state as $queue) {
|
||||
$key = $queue['id_server'];
|
||||
$type = $queue['server_type'];
|
||||
$new_data[$key] = $queue['queued_modules'];
|
||||
|
||||
// Compare queue increments in a not over 900 seconds.
|
||||
if (empty($previous[$key]['modules'])
|
||||
|| ($time - $previous[$key]['utime']) > 900
|
||||
) {
|
||||
$previous[$key]['modules'] = 0;
|
||||
}
|
||||
|
||||
$modules_queued = ($queue['queued_modules'] - $previous[$key]['modules']);
|
||||
|
||||
// 50 Modules queued since last check. Or more than 1500 queued.
|
||||
if ($modules_queued > $MAX_GROWN
|
||||
|| $queue['queued_modules'] > $MAX_QUEUE
|
||||
) {
|
||||
$msg = 'Queue has grown %d modules. Total %d';
|
||||
if ($modules_queued <= 0) {
|
||||
$msg = 'Queue is decreasing in %d modules. But there are %d queued.';
|
||||
$modules_queued *= -1;
|
||||
// Compare queue increments in a not over 900 seconds.
|
||||
if (empty($previous[$key]['modules'])
|
||||
|| ($time - $previous[$key]['utime']) > 900
|
||||
) {
|
||||
$previous[$key]['modules'] = 0;
|
||||
}
|
||||
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.SERVER.QUEUE.'.$key,
|
||||
'title' => __(
|
||||
'%s (%s) performance is being lacked.',
|
||||
servers_get_server_string_name($type),
|
||||
$queue['name']
|
||||
),
|
||||
'message' => __(
|
||||
$msg,
|
||||
$modules_queued,
|
||||
$queue['queued_modules']
|
||||
),
|
||||
'url' => ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60'
|
||||
),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->cleanNotifications('NOTIF.SERVER.QUEUE.'.$key);
|
||||
$modules_queued = ($queue['queued_modules'] - $previous[$key]['modules']);
|
||||
|
||||
// 50 Modules queued since last check. Or more than 1500 queued.
|
||||
if ($modules_queued > $MAX_GROWN
|
||||
|| $queue['queued_modules'] > $MAX_QUEUE
|
||||
) {
|
||||
$msg = 'Queue has grown %d modules. Total %d';
|
||||
if ($modules_queued <= 0) {
|
||||
$msg = 'Queue is decreasing in %d modules. But there are %d queued.';
|
||||
$modules_queued *= -1;
|
||||
}
|
||||
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.SERVER.QUEUE.'.$key,
|
||||
'title' => __(
|
||||
'%s (%s) performance is being lacked.',
|
||||
servers_get_server_string_name($type),
|
||||
$queue['name']
|
||||
),
|
||||
'message' => __(
|
||||
$msg,
|
||||
$modules_queued,
|
||||
$queue['queued_modules']
|
||||
),
|
||||
'url' => ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60'
|
||||
),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->cleanNotifications('NOTIF.SERVER.QUEUE.'.$key);
|
||||
}
|
||||
|
||||
$new[$key]['modules'] = $queue['queued_modules'];
|
||||
$new[$key]['utime'] = $time;
|
||||
}
|
||||
|
||||
$new[$key]['modules'] = $queue['queued_modules'];
|
||||
$new[$key]['utime'] = $time;
|
||||
}
|
||||
// Update file content.
|
||||
file_put_contents($idx_file, json_encode($new));
|
||||
} else {
|
||||
// No queue data, ignore.
|
||||
unlink($idx_file);
|
||||
|
||||
file_put_contents($idx_file, json_encode($new));
|
||||
// Clean notifications.
|
||||
$this->cleanNotifications('NOTIF.SERVER.QUEUE.%');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1370,7 +1380,10 @@ class ConsoleSupervisor
|
|||
[
|
||||
'type' => 'NOTIF.PANDORADB',
|
||||
'title' => __('Database maintance problem'),
|
||||
'message' => __('Your database is not maintained correctly. It seems that more than 48hrs have passed without proper maintenance. Please review documents of %s on how to perform this maintenance process (DB Tool) and enable it as soon as possible.', get_product_name()),
|
||||
'message' => __(
|
||||
'Your database is not maintained correctly. It seems that more than 48hrs have passed without proper maintenance. Please review documents of %s on how to perform this maintenance process (DB Tool) and enable it as soon as possible.',
|
||||
io_safe_output(get_product_name())
|
||||
),
|
||||
'url' => ui_get_full_url(
|
||||
'index.php?sec=general&sec2=godmode/setup/setup§ion=perf'
|
||||
),
|
||||
|
@ -2072,4 +2085,55 @@ class ConsoleSupervisor
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if CRON utility has been configured.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function checkCronRunning()
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Check if DiscoveryCronTasks is running. Warn user if not.
|
||||
if ($config['cron_last_run'] == 0
|
||||
|| (get_system_time() - $config['cron_last_run']) > 3600
|
||||
) {
|
||||
$message_conf_cron = __('DiscoveryConsoleTasks is not running properly');
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||
$message_conf_cron .= __('Discovery relies on a proper setup of cron, the time-based scheduling service');
|
||||
$message_conf_cron .= '. '.__('Please, add the following line to your crontab file:');
|
||||
$message_conf_cron .= '<pre>* * * * * <user> wget -q -O - --no-check-certificate ';
|
||||
$message_conf_cron .= str_replace(
|
||||
ENTERPRISE_DIR.'/meta/',
|
||||
'',
|
||||
ui_get_full_url(false)
|
||||
);
|
||||
$message_conf_cron .= ENTERPRISE_DIR.'/'.EXTENSIONS_DIR;
|
||||
$message_conf_cron .= '/cron/cron.php >> ';
|
||||
$message_conf_cron .= $config['homedir'].'/pandora_console.log</pre>';
|
||||
}
|
||||
|
||||
if (isset($config['cron_last_run']) === true) {
|
||||
$message_conf_cron .= __('Last execution').': ';
|
||||
$message_conf_cron .= date('Y/m/d H:i:s', $config['cron_last_run']);
|
||||
$message_conf_cron .= __('Please check process is no locked.');
|
||||
}
|
||||
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.CRON.CONFIGURED',
|
||||
'title' => __('DiscoveryConsoleTasks is not configured.'),
|
||||
'message' => __($message_conf_cron),
|
||||
'url' => ui_get_full_url(
|
||||
'index.php?extension_in_menu=gservers&sec=extensions&sec2=enterprise/extensions/cron'
|
||||
),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->cleanNotifications('NOTIF.CRON.CONFIGURED');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ define('PASSSWORD_POLICIES_EXPIRED', 2);
|
|||
define('SERVER_TYPE_DATA', 0);
|
||||
define('SERVER_TYPE_NETWORK', 1);
|
||||
define('SERVER_TYPE_SNMP', 2);
|
||||
define('SERVER_TYPE_RECON', 3);
|
||||
define('SERVER_TYPE_DISCOVERY', 3);
|
||||
define('SERVER_TYPE_PLUGIN', 4);
|
||||
define('SERVER_TYPE_PREDICTION', 5);
|
||||
define('SERVER_TYPE_WMI', 6);
|
||||
|
|
|
@ -706,6 +706,7 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
|
|||
$i = 1;
|
||||
$max = count($values);
|
||||
foreach ($values as $field => $value) {
|
||||
$negative = false;
|
||||
if (is_numeric($field)) {
|
||||
// User provide the exact operation to do
|
||||
$query .= $value;
|
||||
|
@ -718,6 +719,11 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field[0] == '!') {
|
||||
$negative = true;
|
||||
$field = substr($field, 1);
|
||||
}
|
||||
|
||||
if ($field[0] != '`') {
|
||||
// If the field is as <table>.<field>, don't scape.
|
||||
if (strstr($field, '.') === false) {
|
||||
|
@ -732,7 +738,8 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
|
|||
} else if (is_float($value) || is_double($value)) {
|
||||
$query .= sprintf('%s = %f', $field, $value);
|
||||
} else if (is_array($value)) {
|
||||
$query .= sprintf('%s IN ("%s")', $field, implode('", "', $value));
|
||||
$not = $negative ? ' NOT ' : '';
|
||||
$query .= sprintf('%s %sIN ("%s")', $field, $not, implode('", "', $value));
|
||||
} else {
|
||||
if ($value === '') {
|
||||
// Search empty string
|
||||
|
|
|
@ -852,6 +852,28 @@ function get_parameter_checkbox($name, $default='')
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transforms a swicth data (on - non present) to a int value.
|
||||
*
|
||||
* @param string $name Variable, switch name.
|
||||
* @param string $default Default value.
|
||||
*
|
||||
* @return integer Value, 1 on, 0 off.
|
||||
*/
|
||||
function get_parameter_switch($name, $default='')
|
||||
{
|
||||
$data = get_parameter($name, null);
|
||||
|
||||
if ($data === null) {
|
||||
return 0;
|
||||
} else if ($data == 'on') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function get_cookie($name, $default='')
|
||||
{
|
||||
if (isset($_COOKIE[$name])) {
|
||||
|
|
|
@ -2673,9 +2673,14 @@ function config_check()
|
|||
include_once __DIR__.'/class/ConsoleSupervisor.php';
|
||||
|
||||
// Enterprise customers launch supervisor using discovery task.
|
||||
if (license_free()) {
|
||||
if (enterprise_installed() === false) {
|
||||
$supervisor = new ConsoleSupervisor(false);
|
||||
$supervisor->run();
|
||||
} else if ($config['cron_last_run'] == 0
|
||||
|| (get_system_time() - $config['cron_last_run']) > 3600
|
||||
) {
|
||||
$supervisor = new ConsoleSupervisor(false);
|
||||
$supervisor->checkCronRunning();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1356,7 +1356,7 @@ function events_print_type_description($type, $return=false)
|
|||
break;
|
||||
|
||||
case 'recon_host_detected';
|
||||
$output .= __('Recon server detected a new host');
|
||||
$output .= __('Discovery server detected a new host');
|
||||
break;
|
||||
|
||||
case 'new_agent';
|
||||
|
|
|
@ -178,7 +178,8 @@ function extensions_get_extensions($enterprise=false, $rel_path='')
|
|||
function extensions_is_enabled_extension($name)
|
||||
{
|
||||
global $config;
|
||||
return isset($config['extensions'][$name]);
|
||||
return isset($config['extensions'][$name])
|
||||
|| isset($config['extensions'][$name.'.php']);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3016,6 +3016,7 @@ function html_print_switch($attributes=[])
|
|||
'id',
|
||||
'class',
|
||||
'name',
|
||||
'onclick',
|
||||
];
|
||||
foreach ($valid_attrs as $va) {
|
||||
if (!isset($attributes[$va])) {
|
||||
|
|
|
@ -356,42 +356,59 @@ function messages_get_count(
|
|||
|
||||
if (!empty($incl_read)) {
|
||||
// Do not filter.
|
||||
$read = '';
|
||||
$read = ' 1=1 ';
|
||||
} else {
|
||||
// Retrieve only unread messages.
|
||||
$read = 'where t.read is null';
|
||||
$read = ' t.read is null';
|
||||
}
|
||||
|
||||
if ($ignore_source === true) {
|
||||
$source_select = '';
|
||||
$source_sql = '';
|
||||
$source_extra = '';
|
||||
} else {
|
||||
$source_sql = 'INNER JOIN tnotification_source ns
|
||||
ON tm.id_source = ns.id
|
||||
AND ns.enabled = 1';
|
||||
$source_select = ',IF(ns.user_editable,nsu.enabled,ns.enabled) as enabled';
|
||||
|
||||
// Row in tnotification_source_user could exist or not.
|
||||
$source_sql = sprintf(
|
||||
'INNER JOIN (
|
||||
tnotification_source ns
|
||||
LEFT JOIN tnotification_source_user nsu
|
||||
ON ns.id=nsu.id_source
|
||||
AND nsu.id_user="test")
|
||||
ON tm.id_source=ns.id',
|
||||
$user
|
||||
);
|
||||
$source_extra = 'AND (t.enabled=1 OR t.enabled is null)';
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT count(*) FROM (
|
||||
SELECT DISTINCT tm.*, utimestamp_read > 0 as "read"
|
||||
FROM tmensajes tm
|
||||
%s
|
||||
LEFT JOIN tnotification_user nu
|
||||
ON tm.id_mensaje=nu.id_mensaje
|
||||
AND nu.id_user="%s"
|
||||
LEFT JOIN (tnotification_group ng
|
||||
INNER JOIN tusuario_perfil up
|
||||
ON ng.id_group=up.id_grupo
|
||||
AND up.id_grupo=ng.id_group
|
||||
) ON tm.id_mensaje=ng.id_mensaje
|
||||
'SELECT count(*) as "n" FROM (
|
||||
SELECT
|
||||
tm.*,
|
||||
utimestamp_read > 0 as "read"
|
||||
%s
|
||||
FROM tmensajes tm
|
||||
%s
|
||||
LEFT JOIN tnotification_user nu
|
||||
ON tm.id_mensaje=nu.id_mensaje
|
||||
AND nu.id_user="%s"
|
||||
LEFT JOIN (tnotification_group ng
|
||||
INNER JOIN tusuario_perfil up
|
||||
ON ng.id_group=up.id_grupo
|
||||
AND up.id_grupo=ng.id_group)
|
||||
ON tm.id_mensaje=ng.id_mensaje
|
||||
WHERE utimestamp_erased is null
|
||||
AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0))
|
||||
) t
|
||||
%s',
|
||||
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)
|
||||
) t
|
||||
WHERE %s %s',
|
||||
$source_select,
|
||||
$source_sql,
|
||||
$user,
|
||||
$user,
|
||||
$user,
|
||||
$read
|
||||
$read,
|
||||
$source_extra
|
||||
);
|
||||
|
||||
return (int) db_get_sql($sql);
|
||||
|
@ -478,7 +495,11 @@ function messages_get_overview(
|
|||
if ($incl_source_info) {
|
||||
$source_fields = ', tns.*';
|
||||
$source_join = 'INNER JOIN tnotification_source tns
|
||||
ON tns.id=tm.id_source';
|
||||
ON tns.id=tm.id_source
|
||||
INNER JOIN tnotification_source_user nsu
|
||||
ON nsu.id_source=tns.id
|
||||
AND nsu.enabled = 1
|
||||
OR tns.enabled = 1';
|
||||
}
|
||||
|
||||
// Using distinct because could be double assignment due group/user.
|
||||
|
@ -496,7 +517,7 @@ function messages_get_overview(
|
|||
) ON tm.id_mensaje=ng.id_mensaje
|
||||
%s
|
||||
WHERE utimestamp_erased is null
|
||||
AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0))
|
||||
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)
|
||||
) t
|
||||
%s
|
||||
%s
|
||||
|
|
|
@ -145,7 +145,7 @@ function check_notification_readable(int $id_message)
|
|||
AND up.id_grupo=ng.id_group
|
||||
) ON tm.id_mensaje=ng.id_mensaje
|
||||
WHERE utimestamp_erased is null
|
||||
AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0))',
|
||||
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)',
|
||||
$config['id_user'],
|
||||
$id_message,
|
||||
$config['id_user'],
|
||||
|
@ -525,7 +525,7 @@ function notifications_build_user_enable_return($status, $enabled)
|
|||
function notifications_get_user_label_status($source, $user, $label)
|
||||
{
|
||||
// If not enabled, it cannot be modificable.
|
||||
if (!$source['enabled'] || !$source[$label]) {
|
||||
if (!$source['enabled']) {
|
||||
return notifications_build_user_enable_return(false, false);
|
||||
}
|
||||
|
||||
|
@ -551,7 +551,10 @@ function notifications_get_user_label_status($source, $user, $label)
|
|||
);
|
||||
// No group found, return no permissions.
|
||||
$value = empty($common_groups) ? false : $source[$label];
|
||||
return notifications_build_user_enable_return($value, false);
|
||||
return notifications_build_user_enable_return(
|
||||
$value,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -570,7 +573,6 @@ function notifications_set_user_label_status($source, $user, $label, $value)
|
|||
$source_info = notifications_get_all_sources(['id' => $source]);
|
||||
if (!isset($source_info[0])
|
||||
|| !$source_info[0]['enabled']
|
||||
|| !$source_info[0][$label]
|
||||
|| !$source_info[0]['user_editable']
|
||||
) {
|
||||
return false;
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
* ============================================================================
|
||||
*/
|
||||
|
||||
require_once __DIR__.'/constants.php';
|
||||
|
||||
|
||||
/**
|
||||
* Get a server.
|
||||
|
@ -203,7 +205,7 @@ function servers_get_performance()
|
|||
case SERVER_TYPE_EXPORT:
|
||||
case SERVER_TYPE_INVENTORY:
|
||||
case SERVER_TYPE_EVENT:
|
||||
case SERVER_TYPE_RECON:
|
||||
case SERVER_TYPE_DISCOVERY:
|
||||
case SERVER_TYPE_SYSLOG:
|
||||
break;
|
||||
}
|
||||
|
@ -424,8 +426,8 @@ function servers_get_info($id_server=-1)
|
|||
$id_modulo = 0;
|
||||
break;
|
||||
|
||||
case SERVER_TYPE_RECON:
|
||||
$server['img'] = html_print_image('images/recon.png', true, ['title' => __('Recon server')]);
|
||||
case SERVER_TYPE_DISCOVERY:
|
||||
$server['img'] = html_print_image('images/recon.png', true, ['title' => __('Discovery server')]);
|
||||
$server['type'] = 'recon';
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
|
@ -598,11 +600,11 @@ function servers_get_info($id_server=-1)
|
|||
$server['lag'] = 0;
|
||||
$server['module_lag'] = 0;
|
||||
}
|
||||
// Recon server
|
||||
else if ($server['server_type'] == SERVER_TYPE_RECON) {
|
||||
// Discovery server
|
||||
else if ($server['server_type'] == SERVER_TYPE_DISCOVERY) {
|
||||
$server['name'] = '<a href="index.php?sec=estado&sec2=operation/servers/recon_view&server_id='.$server['id_server'].'">'.$server['name'].'</a>';
|
||||
|
||||
// Total jobs running on this recon server
|
||||
// Total jobs running on this Discovery server
|
||||
$server['modules'] = db_get_sql(
|
||||
'SELECT COUNT(id_rt)
|
||||
FROM trecon_task
|
||||
|
@ -978,7 +980,7 @@ function servers_get_server_string_name(int $server)
|
|||
case SERVER_TYPE_EVENT:
|
||||
return __('Event server');
|
||||
|
||||
case SERVER_TYPE_RECON:
|
||||
case SERVER_TYPE_DISCOVERY:
|
||||
return __('Discovery server');
|
||||
|
||||
case SERVER_TYPE_SYSLOG:
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<p>The "ReconScripts" allows to work with more flexible capabilities. The recon scripts are developped in an individual way with completely specific targets, such as the network plugins or the agent plugins. Each ReconScript is different and has one purpose.</p>
|
||||
|
||||
<p>Its basic idea consist on "detect" things in the system it recognizes and automatically log in one monitoring (network, plugin or wmi) so in a completely customized way we could automatically log in requests in an Oracle database, new virtual host in a VmWare that is managed with VirtualCenter or we also can detect new requests in an WebLogic application Server. It is possible to do an script or application that does the task that are wanted and schedule its execution through the Recon Server.</p>
|
||||
<p>Its basic idea consist on "detect" things in the system it recognizes and automatically log in one monitoring (network, plugin or wmi) so in a completely customized way we could automatically log in requests in an Oracle database, new virtual host in a VmWare that is managed with VirtualCenter or we also can detect new requests in an WebLogic application Server. It is possible to do an script or application that does the task that are wanted and schedule its execution through the Discovery Server.</p>
|
||||
|
||||
<p>A field with importance is:</p>
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ If you choose to edit or create a new task of network recon, then you should fil
|
|||
|
||||
Name of the discovery task. It's only a descriptive value to could distinguish the task in case it would have several of them with different values of filter or template. <br><br>
|
||||
|
||||
<b>Recon server</b><br>
|
||||
<b>Discovery server</b><br>
|
||||
|
||||
Recon Server assigned to the task. If you have several Recon Servers, then you have to select here which of them you want to do the recon task. <br><br>
|
||||
Discovery Server assigned to the task. If you have several Discovery Servers, then you have to select here which of them you want to do the recon task. <br><br>
|
||||
|
||||
<b>Mode</b><br>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
検出タスクの名前です。フィルターやテンプレートとは異なり、タスクを区別しやすい説明を入れるだけです。<br><br>
|
||||
|
||||
<b>自動検出サーバ(Recon server)</b><br>
|
||||
<b>自動検出サーバ(Discovery server)</b><br>
|
||||
|
||||
タスクを割り当てる自動検出サーバです。複数の自動検出サーバがある場合は、自動検出タスクをどのサーバで実行するかを選択します。<br><br>
|
||||
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
.texto {
|
||||
height: auto;
|
||||
text-align: center;
|
||||
}
|
||||
#text_wizard {
|
||||
font-weight: bolder;
|
||||
text-decoration: none;
|
||||
font-size: 24px;
|
||||
}
|
||||
.text_color {
|
||||
color: white;
|
||||
margin-left: 25px;
|
||||
}
|
||||
.text_color:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
.arrow_box {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
background: #ccc;
|
||||
padding: 14px;
|
||||
margin-left: 20px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.arrow_box:after,
|
||||
.arrow_box:before {
|
||||
top: 50%;
|
||||
border: solid transparent;
|
||||
content: " ";
|
||||
height: 0;
|
||||
width: 0;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
.arrow_box.selected {
|
||||
background: #82b92e;
|
||||
}
|
||||
|
||||
.arrow_box:after {
|
||||
left: 0%;
|
||||
border-left-color: white;
|
||||
border-width: 20px;
|
||||
margin-top: -20px;
|
||||
}
|
||||
.arrow_box:before {
|
||||
left: 100%;
|
||||
border-left-color: #ccc;
|
||||
border-width: 20px;
|
||||
margin-top: -20px;
|
||||
}
|
||||
.arrow_box.selected:before {
|
||||
border-left-color: #82b92e;
|
||||
}
|
|
@ -4305,6 +4305,7 @@ div#dialog_messages table th:last-child {
|
|||
position: absolute;
|
||||
width: 400px;
|
||||
margin-top: -5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
#notification-wrapper::before {
|
||||
content: "";
|
||||
|
@ -4338,12 +4339,15 @@ div#dialog_messages table th:last-child {
|
|||
background: whitesmoke;
|
||||
height: 100px;
|
||||
margin: 7px;
|
||||
border: #cccccc solid 1px;
|
||||
border: #e4e4e4 solid 1px;
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
align-items: center;
|
||||
padding: 5px;
|
||||
}
|
||||
.notification-item:hover {
|
||||
border: #ccc solid 1px;
|
||||
}
|
||||
.notification-item > * {
|
||||
padding-left: 15px;
|
||||
pointer-events: none;
|
||||
|
@ -4357,6 +4361,9 @@ div#dialog_messages table th:last-child {
|
|||
width: 87%;
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
overflow: hidden;
|
||||
max-height: 83px;
|
||||
line-height: 1.4em;
|
||||
}
|
||||
.notification-item img {
|
||||
max-width: 100%;
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Discovery > Wizard css global style
|
||||
*/
|
||||
|
||||
ul.wizard {
|
||||
}
|
||||
|
||||
ul.wizard li {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
ul.wizard li > label:not(.p-switch) {
|
||||
width: 250px;
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
ul.wizard li > textarea {
|
||||
width: 250px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
|
@ -1,16 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Extension to manage a list of gateways and the node address where they should
|
||||
* point to.
|
||||
*
|
||||
* @category Extensions
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2012 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.
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
|
@ -113,7 +129,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.731';
|
||||
$build = '190208';
|
||||
$build = '190214';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -106,7 +106,12 @@ if ($read_message) {
|
|||
$dst_name = $message['id_usuario_destino'];
|
||||
}
|
||||
|
||||
echo '<h1>Conversation with '.$user_name.'</h1>';
|
||||
if (isset($user_name) !== true || empty($user_name) === true) {
|
||||
echo '<h1>Notification</h1>';
|
||||
} else {
|
||||
echo '<h1>Conversation with '.$user_name.'</h1>';
|
||||
}
|
||||
|
||||
echo '<h2>Subject: '.$message['subject'].'</h2>';
|
||||
|
||||
$conversation = [];
|
||||
|
|
|
@ -30,7 +30,7 @@ $servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3');
|
|||
if ($servers === false) {
|
||||
$servers = [];
|
||||
ui_print_page_header(__('Recon View'), 'images/op_recon.png', false, '', false);
|
||||
ui_print_error_message(__('Recon Server is disabled'));
|
||||
ui_print_error_message(__('Discovery Server is disabled'));
|
||||
return;
|
||||
} else {
|
||||
$recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task');
|
||||
|
|
|
@ -14,51 +14,8 @@
|
|||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
enterprise_hook('open_meta_frame');
|
||||
|
||||
require_once $config['homedir'].'/include/functions_profile.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_groups.php';
|
||||
require_once $config['homedir'].'/include/functions_visual_map.php';
|
||||
|
||||
$meta = false;
|
||||
if (enterprise_installed() && defined('METACONSOLE')) {
|
||||
$meta = true;
|
||||
}
|
||||
|
||||
$id = get_parameter_get('id', $config['id_user']);
|
||||
// ID given as parameter
|
||||
$status = get_parameter('status', -1);
|
||||
// Flag to print action status message
|
||||
$user_info = get_user_info($id);
|
||||
$id = $user_info['id_user'];
|
||||
// This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem)
|
||||
if ((!check_acl($config['id_user'], users_get_groups($id), 'UM'))
|
||||
and ($id != $config['id_user'])
|
||||
) {
|
||||
db_pandora_audit('ACL Violation', 'Trying to view a user without privileges');
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info
|
||||
if (($config['id_user'] == $id || check_acl($config['id_user'], users_get_groups($id), 'UM')) && $config['user_can_update_info']) {
|
||||
$view_mode = false;
|
||||
} else {
|
||||
$view_mode = true;
|
||||
}
|
||||
|
||||
// Header
|
||||
if ($meta) {
|
||||
user_meta_print_header();
|
||||
$url = 'index.php?sec=advanced&sec2=advanced/users_setup&tab=user_edit';
|
||||
} else {
|
||||
ui_print_page_header(__('User detail editor'), 'images/op_workspace.png', false, '', false, '');
|
||||
$url = 'index.php?sec=workspace&sec2=operation/users/user_edit';
|
||||
}
|
||||
|
||||
// Load the header
|
||||
require $config['homedir'].'/operation/users/user_edit_header.php';
|
||||
|
||||
// Update user info
|
||||
if (isset($_GET['modified']) && !$view_mode) {
|
||||
|
@ -535,7 +492,7 @@ $table->rowclass[] = '';
|
|||
$table->rowstyle[] = '';
|
||||
$table->data[] = $data;
|
||||
|
||||
echo '<form name="user_mod" method="post" action="'.$url.'&modified=1&id='.$id.'&pure='.$config['pure'].'">';
|
||||
echo '<form name="user_mod" method="post" action="'.$urls['main'].'&modified=1&id='.$id.'&pure='.$config['pure'].'">';
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
|
|
|
@ -782,6 +782,9 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
|
|||
`snmp_privacy_method` varchar(25) NOT NULL default '',
|
||||
`snmp_privacy_pass` varchar(255) NOT NULL default '',
|
||||
`snmp_security_level` varchar(25) NOT NULL default '',
|
||||
`wmi_enabled` tinyint(1) unsigned DEFAULT '0',
|
||||
`auth_strings` text,
|
||||
`autoconfiguration_enabled` tinyint(1) unsigned default '0',
|
||||
PRIMARY KEY (`id_rt`),
|
||||
KEY `recon_task_daemon` (`id_recon_server`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
|
@ -33,7 +33,7 @@ use PandoraFMS::Core;
|
|||
use PandoraFMS::DataServer;
|
||||
use PandoraFMS::NetworkServer;
|
||||
use PandoraFMS::SNMPServer;
|
||||
use PandoraFMS::ReconServer;
|
||||
use PandoraFMS::DiscoveryServer;
|
||||
use PandoraFMS::WMIServer;
|
||||
use PandoraFMS::PluginServer;
|
||||
use PandoraFMS::PredictionServer;
|
||||
|
@ -123,7 +123,7 @@ sub pandora_startup () {
|
|||
pandora_reset_server (\%Config, $DBH);
|
||||
push (@Servers, new PandoraFMS::DataServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::NetworkServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::ReconServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::DiscoveryServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::SNMPServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::WMIServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::PluginServer (\%Config, $DBH));
|
||||
|
|
|
@ -179,6 +179,7 @@ our @EXPORT = qw(
|
|||
pandora_evaluate_alert
|
||||
pandora_evaluate_snmp_alerts
|
||||
pandora_event
|
||||
pandora_extended_event
|
||||
pandora_execute_alert
|
||||
pandora_execute_action
|
||||
pandora_exec_forced_alerts
|
||||
|
@ -3270,11 +3271,11 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) {
|
|||
|
||||
# Create the event
|
||||
logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10);
|
||||
db_do ($dbh, 'INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status)
|
||||
my $event_id = db_insert ($dbh, 'id_evento','INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, $module_data, $module_status);
|
||||
|
||||
|
||||
# Do not write to the event file
|
||||
return if ($pa_config->{'event_file'} eq '');
|
||||
return $event_id if ($pa_config->{'event_file'} eq '');
|
||||
|
||||
# Add a header when the event file is created
|
||||
my $header = undef;
|
||||
|
@ -3285,7 +3286,7 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) {
|
|||
# Open the event file for writing
|
||||
if (! open (EVENT_FILE, '>>' . $pa_config->{'event_file'})) {
|
||||
logger($pa_config, "Error opening event file " . $pa_config->{'event_file'} . ": $!", 10);
|
||||
return;
|
||||
return $event_id;
|
||||
}
|
||||
|
||||
# Resolve ids
|
||||
|
@ -3308,6 +3309,29 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) {
|
|||
print EVENT_FILE "$agent_name,".safe_output($group_name)."," . safe_output ($evento) . ",$timestamp,$event_status,$utimestamp,$event_type,".safe_output($module_name).",".safe_output($alert_name).",$severity,".safe_output($comment).",".safe_output($module_tags).",$source,$id_extra,$user_name,".safe_output($critical_instructions).",".safe_output($warning_instructions).",".safe_output($unknown_instructions).",$ack_utimestamp\n";
|
||||
|
||||
close (EVENT_FILE);
|
||||
|
||||
return $event_id;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< pandora_extended_event (I<$pa_config>, I<$dbh>, I<$event_id>, I<$description>) >>
|
||||
|
||||
Creates an extended event linked to an existing main event id.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_extended_event($$$$) {
|
||||
my ($pa_config, $dbh, $event_id, $description) = @_;
|
||||
|
||||
return unless defined($event_id) && "$event_id" ne "" && $event_id > 0;
|
||||
|
||||
return db_do(
|
||||
$dbh,
|
||||
'INSERT INTO tevent_extended (id_evento, utimestamp, description) VALUES (?,?,?)',
|
||||
$event_id,
|
||||
time(),
|
||||
safe_input($description)
|
||||
);
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
@ -4544,7 +4568,7 @@ sub pandora_server_statistics ($$) {
|
|||
$server->{"lag"} = 0;
|
||||
$server->{"module_lag"} = 0;
|
||||
# Recon server
|
||||
} elsif ($server->{"server_type"} == RECONSERVER) {
|
||||
} elsif ($server->{"server_type"} == DISCOVERYSERVER) {
|
||||
|
||||
# Total jobs running on this recon server
|
||||
$server->{"modules"} = get_db_value ($dbh, "SELECT COUNT(id_rt) FROM trecon_task WHERE id_recon_server = ?", $server->{"id_server"});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package PandoraFMS::ReconServer;
|
||||
package PandoraFMS::DiscoveryServer;
|
||||
##########################################################################
|
||||
# Pandora FMS Recon Server.
|
||||
# Pandora FMS Discovery Server.
|
||||
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||
##########################################################################
|
||||
# Copyright (c) 2005-2009 Artica Soluciones Tecnologicas S.L
|
||||
|
@ -57,16 +57,16 @@ use constant OS_ROUTER => 17;
|
|||
use constant OS_SWITCH => 18;
|
||||
|
||||
########################################################################################
|
||||
# Recon Server class constructor.
|
||||
# Discovery Server class constructor.
|
||||
########################################################################################
|
||||
sub new ($$$$$$) {
|
||||
my ($class, $config, $dbh) = @_;
|
||||
|
||||
return undef unless $config->{'reconserver'} == 1;
|
||||
return undef unless $config->{'reconserver'} == 1 || $config->{'discoveryserver'} == 1;
|
||||
|
||||
if (! -e $config->{'nmap'}) {
|
||||
logger ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Recon Server not found.", 1);
|
||||
print_message ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Recon Server not found.", 1);
|
||||
logger ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Discovery Server not found.", 1);
|
||||
print_message ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Discovery Server not found.", 1);
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
@ -78,14 +78,14 @@ sub new ($$$$$$) {
|
|||
|
||||
# Restart automatic recon tasks.
|
||||
db_do ($dbh, 'UPDATE trecon_task SET utimestamp = 0 WHERE id_recon_server = ? AND status <> -1 AND interval_sweep > 0',
|
||||
get_server_id ($dbh, $config->{'servername'}, RECONSERVER));
|
||||
get_server_id ($dbh, $config->{'servername'}, DISCOVERYSERVER));
|
||||
|
||||
# Reset (but do not restart) manual recon tasks.
|
||||
db_do ($dbh, 'UPDATE trecon_task SET status = -1 WHERE id_recon_server = ? AND status <> -1 AND interval_sweep = 0',
|
||||
get_server_id ($dbh, $config->{'servername'}, RECONSERVER));
|
||||
get_server_id ($dbh, $config->{'servername'}, DISCOVERYSERVER));
|
||||
|
||||
# Call the constructor of the parent class
|
||||
my $self = $class->SUPER::new($config, RECONSERVER, \&PandoraFMS::ReconServer::data_producer, \&PandoraFMS::ReconServer::data_consumer, $dbh);
|
||||
my $self = $class->SUPER::new($config, DISCOVERYSERVER, \&PandoraFMS::DiscoveryServer::data_producer, \&PandoraFMS::DiscoveryServer::data_consumer, $dbh);
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
|
@ -98,7 +98,7 @@ sub run ($) {
|
|||
my $self = shift;
|
||||
my $pa_config = $self->getConfig ();
|
||||
|
||||
print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Recon Server.", 1);
|
||||
print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Discovery Server.", 1);
|
||||
$self->setNumThreads ($pa_config->{'recon_threads'});
|
||||
$self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem);
|
||||
}
|
||||
|
@ -121,9 +121,10 @@ sub data_producer ($) {
|
|||
# Status -1 means "done".
|
||||
|
||||
my @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
|
||||
WHERE id_recon_server = ?
|
||||
AND disabled = 0
|
||||
AND utimestamp = 0 OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP())', $server_id);
|
||||
WHERE id_recon_server = ?
|
||||
AND disabled = 0
|
||||
AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
|
||||
OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id);
|
||||
foreach my $row (@rows) {
|
||||
|
||||
# Update task status
|
||||
|
@ -154,12 +155,15 @@ sub data_consumer ($$) {
|
|||
logger($pa_config, 'Starting recon task for net ' . $task->{'subnet'} . '.', 10);
|
||||
}
|
||||
|
||||
# Call nmap
|
||||
my $nmap_args = '-nsP -PE --max-retries '.$pa_config->{'icmp_checks'}.' --host-timeout '.$pa_config->{'networktimeout'}.'s -T'.$pa_config->{'recon_timing_template'};
|
||||
my $np = new PandoraFMS::NmapParser;
|
||||
eval {
|
||||
my @subnets = split(/,/, safe_output($task->{'subnet'}));
|
||||
my @communities = split(/,/, safe_output($task->{'snmp_community'}));
|
||||
my @auth_strings = ();
|
||||
if(defined($task->{'auth_strings'})) {
|
||||
@auth_strings = split(/,/, safe_output($task->{'auth_strings'}));
|
||||
}
|
||||
|
||||
my $main_event = pandora_event($pa_config, "[Discovery] Execution summary",$task->{'id_group'}, 0, 0, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
my $recon = new PandoraFMS::Recon::Base(
|
||||
communities => \@communities,
|
||||
|
@ -186,6 +190,10 @@ sub data_consumer ($$) {
|
|||
subnets => \@subnets,
|
||||
task_id => $task->{'id_rt'},
|
||||
vlan_cache_enabled => $task->{'vlan_enabled'},
|
||||
wmi_enabled => $task->{'wmi_enabled'},
|
||||
auth_strings_array => \@auth_strings,
|
||||
autoconfiguration_enabled => $task->{'autoconfiguration_enabled'},
|
||||
main_event_id => $main_event,
|
||||
%{$pa_config}
|
||||
);
|
||||
|
||||
|
@ -441,7 +449,23 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
$location->{'longitude'}, $location->{'latitude'}
|
||||
);
|
||||
return undef unless defined ($agent_id) and ($agent_id > 0);
|
||||
pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'});
|
||||
|
||||
# Autoconfigure agent
|
||||
if (defined($self->{'autoconfiguration_enabled'}) && $self->{'autoconfiguration_enabled'} == 1) {
|
||||
my $agent_data = PandoraFMS::DB::get_db_single_row($self->{'dbh'}, 'SELECT * FROM tagente WHERE id_agente = ?', $agent_id);
|
||||
# Update agent configuration once, after create agent.
|
||||
enterprise_hook('autoconfigure_agent', [$self->{'pa_config'}, $host_name, $agent_id, $agent_data, $self->{'dbh'}, 1]);
|
||||
}
|
||||
|
||||
if (defined($self->{'main_event_id'})) {
|
||||
my $addresses_str = join(',', safe_output($self->get_addresses($device)));
|
||||
pandora_extended_event(
|
||||
$self->{'pa_config'}, $self->{'dbh'}, $self->{'main_event_id'},
|
||||
"[Discovery] New " . safe_output($self->get_device_type($device)) . " found " . $host_name . " (" . $addresses_str . ") Agent $agent_id."
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$agent_learning = 1;
|
||||
|
||||
# Create network profile modules for the agent
|
||||
|
@ -748,6 +772,35 @@ sub PandoraFMS::Recon::Base::set_parent($$$) {
|
|||
db_do($self->{'dbh'}, 'UPDATE tagente SET id_parent=? WHERE id_agente=?', $agent_parent->{'id_agente'}, $agent->{'id_agente'});
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Create a WMI module for the given agent.
|
||||
##########################################################################
|
||||
sub PandoraFMS::Recon::Base::wmi_module {
|
||||
my ($self, $agent_id, $target, $wmi_query, $wmi_auth, $column,
|
||||
$module_name, $module_description, $module_type, $unit) = @_;
|
||||
|
||||
# Check whether the module already exists.
|
||||
my $module_id = get_agent_module_id($self->{'dbh'}, $module_name, $agent_id);
|
||||
return if ($module_id > 0);
|
||||
|
||||
my ($user, $pass) = ($wmi_auth ne '') ? split('%', $wmi_auth) : (undef, undef);
|
||||
my %module = (
|
||||
'descripcion' => safe_input($module_description),
|
||||
'id_agente' => $agent_id,
|
||||
'id_modulo' => 6,
|
||||
'id_tipo_modulo' => get_module_id($self->{'dbh'}, $module_type),
|
||||
'ip_target' => $target,
|
||||
'nombre' => safe_input($module_name),
|
||||
'plugin_pass' => defined($pass) ? $pass : '',
|
||||
'plugin_user' => defined($user) ? $user : '',
|
||||
'snmp_oid' => $wmi_query,
|
||||
'tcp_port' => $column,
|
||||
'unit' => defined($unit) ? $unit : ''
|
||||
);
|
||||
|
||||
pandora_create_module_from_hash($self->{'pa_config'}, \%module, $self->{'dbh'});
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Update recon task status.
|
||||
##########################################################################
|
|
@ -123,6 +123,12 @@ sub new {
|
|||
# Globally enable/disable SNMP scans.
|
||||
snmp_enabled => 1,
|
||||
|
||||
# Globally enable/disable WMI scans.
|
||||
wmi_enabled => 0,
|
||||
auth_strings_array => [],
|
||||
wmi_timeout => 3,
|
||||
timeout_cmd => '',
|
||||
|
||||
# Switch to switch connections. Used to properly connect hosts
|
||||
# that are connected to a switch wich is in turn connected to another switch,
|
||||
# since the hosts will show up in the latter's switch AFT too.
|
||||
|
@ -160,6 +166,7 @@ sub new {
|
|||
snmp_timeout => 2,
|
||||
snmp_version => 1,
|
||||
subnets => [],
|
||||
autoconfiguration_enabled => 0,
|
||||
@_,
|
||||
|
||||
};
|
||||
|
@ -217,6 +224,19 @@ sub new {
|
|||
}
|
||||
}
|
||||
|
||||
# Prepare auth array.
|
||||
# WMI could be launched with '-N' - no pass - argument.
|
||||
if ($self->{'wmi_enabled'} == 1){
|
||||
if (defined($self->{'auth_strings_str'})) {
|
||||
@{$self->{'auth_strings_array'}} = split(',', $self->{'auth_strings_str'});
|
||||
}
|
||||
|
||||
# Timeout available only in linux environments.
|
||||
if ($^O =~ /lin/i && defined($self->{'plugin_exec'}) && defined($self->{'wmi_timeout'})) {
|
||||
$self->{'timeout_cmd'} = $self->{'plugin_exec'}.' '.$self->{'wmi_timeout'}.' ';
|
||||
}
|
||||
}
|
||||
|
||||
# Remove all snmp related values if disabled
|
||||
if (!$self->{'snmp_enabled'}) {
|
||||
$self->{'communities'} = [];
|
||||
|
@ -1312,6 +1332,9 @@ sub scan_subnet($) {
|
|||
$progress += $step;
|
||||
|
||||
$self->snmp_discovery($host);
|
||||
|
||||
# Add wmi scan if enabled.
|
||||
$self->wmi_scan($host) if ($self->{'wmi_enabled'} == 1);
|
||||
}
|
||||
}
|
||||
# ping scan.
|
||||
|
@ -1330,6 +1353,9 @@ sub scan_subnet($) {
|
|||
next if ($self->ping($host) == 0);
|
||||
|
||||
$self->snmp_discovery($host);
|
||||
|
||||
# Add wmi scan if enabled.
|
||||
$self->wmi_scan($host) if ($self->{'wmi_enabled'} == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1475,6 +1501,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'} ";
|
||||
|
@ -1579,6 +1608,168 @@ sub traceroute_connectivity($$) {
|
|||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Returns the credentials with which the host responds to WMI queries or
|
||||
# undef if it does not respond to WMI.
|
||||
##########################################################################
|
||||
sub responds_to_wmi {
|
||||
my ($self, $target) = @_;
|
||||
|
||||
foreach my $auth (@{$self->{'auth_strings_array'}}) {
|
||||
my @output;
|
||||
if ($auth ne '') {
|
||||
@output = `$self->{'timeout_cmd'}$self->{'wmi_client'} -U $auth //$target "SELECT * FROM Win32_ComputerSystem" 2>&1`;
|
||||
} else {
|
||||
@output = `$self->{'timeout_cmd'}$self->{'wmi_client'} -N //$target "SELECT * FROM Win32_ComputerSystem" 2>&1`;
|
||||
}
|
||||
|
||||
foreach my $line (@output) {
|
||||
chomp($line);
|
||||
return $auth if ($line =~ m/^CLASS: Win32_ComputerSystem$/);
|
||||
}
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Add wmi modules to the given host.
|
||||
##########################################################################
|
||||
sub wmi_scan {
|
||||
my ($self, $target) = @_;
|
||||
|
||||
$self->call('message', "[".$target."] Checking WMI.", 5);
|
||||
|
||||
my $auth = $self->responds_to_wmi($target);
|
||||
return unless defined($auth);
|
||||
|
||||
$self->call('message', "[".$target."] WMI available.", 10);
|
||||
# Create the agent if it does not exist.
|
||||
my $agent_id = $self->call('create_agent', $target);
|
||||
next unless defined($agent_id);
|
||||
|
||||
# CPU.
|
||||
my @cpus = $self->wmi_get_value_array($target, $auth, 'SELECT DeviceId FROM Win32_Processor', 0);
|
||||
foreach my $cpu (@cpus) {
|
||||
$self->call(
|
||||
'wmi_module',
|
||||
(
|
||||
$agent_id,
|
||||
$target,
|
||||
"SELECT LoadPercentage FROM Win32_Processor WHERE DeviceId='$cpu'",
|
||||
$auth,
|
||||
1,
|
||||
"CPU Load $cpu",
|
||||
"Load for $cpu (%)",
|
||||
'generic_data'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
# Memory.
|
||||
my $mem = $self->wmi_get_value($target, $auth, 'SELECT FreePhysicalMemory FROM Win32_OperatingSystem', 0);
|
||||
if (defined($mem)) {
|
||||
$self->call('wmi_module',
|
||||
(
|
||||
$agent_id,
|
||||
$target,
|
||||
"SELECT FreePhysicalMemory, TotalVisibleMemorySize FROM Win32_OperatingSystem",
|
||||
$auth,
|
||||
0,
|
||||
'FreeMemory',
|
||||
'Free memory',
|
||||
'generic_data',
|
||||
'KB'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
# Disk.
|
||||
my @units = $self->wmi_get_value_array($target, $auth, 'SELECT DeviceID FROM Win32_LogicalDisk', 0);
|
||||
foreach my $unit (@units) {
|
||||
$self->call(
|
||||
'wmi_module',
|
||||
(
|
||||
$agent_id,
|
||||
$target,
|
||||
"SELECT FreeSpace FROM Win32_LogicalDisk WHERE DeviceID='$unit'",
|
||||
$auth,
|
||||
1,
|
||||
"FreeDisk $unit",
|
||||
'Available disk space in kilobytes',
|
||||
'generic_data',
|
||||
'KB'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Extra: WMI imported methods. DO NOT EXPORT TO AVOID DOUBLE DEF.
|
||||
##########################################################################
|
||||
|
||||
##########################################################################
|
||||
# Performs a wmi get requests and returns the response as an array.
|
||||
##########################################################################
|
||||
sub wmi_get {
|
||||
my ($self, $target, $auth, $query) = @_;
|
||||
|
||||
my @output;
|
||||
if (defined($auth) && $auth ne '') {
|
||||
@output = `$self->{'timeout_cmd'}"$self->{'wmi_client'}" -U $auth //$target "$query" 2>&1`;
|
||||
}else {
|
||||
@output = `$self->{'timeout_cmd'}"$self->{'wmi_client'}" -N //$target "$query" 2>&1`;
|
||||
}
|
||||
|
||||
# Something went wrong.
|
||||
return () if ($? != 0);
|
||||
|
||||
return @output;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Performs a WMI request and returns the requested column of the first row.
|
||||
# Returns undef on error.
|
||||
##########################################################################
|
||||
sub wmi_get_value {
|
||||
my ($self, $target, $auth, $query, $column) = @_;
|
||||
my @result;
|
||||
|
||||
my @output = $self->wmi_get($target, $auth, $query);
|
||||
return undef unless defined($output[2]);
|
||||
|
||||
my $line = $output[2];
|
||||
chomp($line);
|
||||
my @columns = split(/\|/, $line);
|
||||
return undef unless defined($columns[$column]);
|
||||
|
||||
return $columns[$column];
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Performs a WMI request and returns row values for the requested column
|
||||
# in an array.
|
||||
##########################################################################
|
||||
sub wmi_get_value_array {
|
||||
my ($self, $target, $auth, $query, $column) = @_;
|
||||
my @result;
|
||||
|
||||
my @output = $self->wmi_get($target, $auth, $query);
|
||||
foreach (my $i = 2; defined($output[$i]); $i++) {
|
||||
my $line = $output[$i];
|
||||
chomp($line);
|
||||
my @columns = split(/\|/, $line);
|
||||
next unless defined($columns[$column]);
|
||||
push(@result, $columns[$column]);
|
||||
}
|
||||
|
||||
return @result;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# END: WMI imported methods.
|
||||
##########################################################################
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ our @EXPORT = qw(
|
|||
DATASERVER
|
||||
NETWORKSERVER
|
||||
SNMPCONSOLE
|
||||
RECONSERVER
|
||||
DISCOVERYSERVER
|
||||
PLUGINSERVER
|
||||
PREDICTIONSERVER
|
||||
WMISERVER
|
||||
|
@ -134,7 +134,7 @@ our @EXPORT = qw(
|
|||
use constant DATASERVER => 0;
|
||||
use constant NETWORKSERVER => 1;
|
||||
use constant SNMPCONSOLE => 2;
|
||||
use constant RECONSERVER => 3;
|
||||
use constant DISCOVERYSERVER => 3;
|
||||
use constant PLUGINSERVER => 4;
|
||||
use constant PREDICTIONSERVER => 5;
|
||||
use constant WMISERVER => 6;
|
||||
|
|
Loading…
Reference in New Issue