Merge develop

This commit is contained in:
Daniel Barbero Martin 2019-11-05 15:27:06 +01:00
commit e5f24ca884
42 changed files with 1496 additions and 448 deletions

View File

@ -238,19 +238,6 @@ function output_xml_report($id)
echo '<line_separator><![CDATA['.io_safe_output($item['line_separator']).']]></line_separator>';
echo '<column_separator><![CDATA['.io_safe_output($item['header_definition']).']]></column_separator>';
break;
/*
case 'TTRT':
break;
case 'TTO':
break;
case 'MTBF':
break;
case 'MTTR':
break;*/
}
echo "</item>\n";

View File

@ -375,19 +375,6 @@ function process_upload_xml_report($xml, $group_filter=0)
$values['line_separator'] = io_safe_input($item['line_separator']);
$values['column_separator'] = io_safe_input($item['column_separator']);
break;
/*
case 'TTRT':
break;
case 'TTO':
break;
case 'MTBF':
break;
case 'MTTR':
break;*/
}
if (empty($agents_item)) {

View File

@ -0,0 +1,66 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// 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; 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__.'/../include/config.php';
require_once __DIR__.'/../include/auth/mysql.php';
require_once __DIR__.'/../include/functions.php';
require_once __DIR__.'/../include/functions_db.php';
/*
* Review if sample agent is active and deploys configuration for
* visual consoles if necessary
*/
global $config;
// Deployment of sample agent for visual consoles.
if ($config['sample_agent'] == 1 && !isset($config['sample_agent_deployed'])) {
$id_agente = db_get_sql('SELECT id_agente FROM tagente WHERE nombre = "Sample_Agent";');
$modules = db_get_all_rows_filter('tagente_modulo', ['id_agente' => $id_agente], 'id_agente_modulo');
$count_modules = count($modules);
// Update of layout 1 (Rack sample).
$images_rack_server = [
'rack_server_rack',
'rack_server',
'rack_switch',
'rack_firewall',
'rack_double_server',
'rack_frame',
'rack_pdu',
];
$query = 'UPDATE `tlayout_data` SET `id_agent` = '.$id_agente.', `id_agente_modulo` = CASE ';
for ($i = 0; $i < $count_modules; $i++) {
$query .= 'WHEN `image` = "'.$images_rack_server[$i].'" THEN '.$modules[$i]['id_agente_modulo'].' ';
}
$query .= 'END WHERE `id_layout` = 1 AND `image` IN ("'.implode('","', $images_rack_server).'");';
db_process_sql($query);
// Update of layout 2 (Dashboard).
$query = 'UPDATE `tlayout_data` SET `id_agent`= '.$id_agente.', `id_agente_modulo` = CASE ';
$query .= 'WHEN `id` = 107 THEN '.$modules[0]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 108 THEN '.$modules[1]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 109 THEN '.$modules[2]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 110 THEN '.$modules[2]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 111 THEN '.$modules[3]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 112 THEN '.$modules[4]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 113 THEN '.$modules[5]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 114 THEN '.$modules[6]['id_agente_modulo'].' ';
$query .= 'END WHERE `id_layout` = 2 AND `id` IN (107,108,109,110,111,112,113,114);';
db_process_sql($query);
// This setting will avoid regenerate all the times the visual consoles.
config_update_value('sample_agent_deployed', 1);
}
extensions_add_main_function('sample_agent_deployment');

View File

@ -1,5 +1,7 @@
START TRANSACTION;
ALTER TABLE `tlayout_template_data` ADD COLUMN `cache_expiration` INTEGER UNSIGNED NOT NULL DEFAULT 0;
INSERT INTO `ttipo_modulo` VALUES
(34,'remote_cmd', 10, 'Remote execution, numeric data', 'mod_remote_cmd.png'),
(35,'remote_cmd_proc', 10, 'Remote execution, boolean data', 'mod_remote_cmd_proc.png'),
@ -22,7 +24,7 @@ CREATE TABLE `tremote_command` (
CREATE TABLE `tremote_command_target` (
`id` SERIAL,
`rcmd_id` bigint unsigned NOT NULL,
`id_agente` int(10) unsigned NOT NULL,
`id_agent` int(10) unsigned NOT NULL,
`utimestamp` int(20) unsigned NOT NULL default 0,
`stdout` text,
`stderr` text,
@ -32,4 +34,4 @@ CREATE TABLE `tremote_command_target` (
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT;
COMMIT;

View File

@ -1912,6 +1912,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
`linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0,
`linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0,
`linked_layout_node_id` INT(10) NOT NULL default 0,
`cache_expiration` INTEGER UNSIGNED NOT NULL default 0,
PRIMARY KEY(`id`),
FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8;

View File

@ -33,7 +33,7 @@ ui_require_css_file('firts_task');
);
?>
</p>
<form action="index.php?sec=estado&amp;sec2=godmode/agentes/planned_downtime.editor" method="post">
<form action="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor" method="post">
<input type="submit" class="button_task" value="<?php echo __('Create Planned Downtime'); ?>" />
</form>
</div>

View File

@ -639,6 +639,7 @@ if ($config['menu_type'] == 'classic') {
// Require specific CSS and JS.
ui_require_css_file('wizard');
ui_require_css_file('discovery');
ui_require_css_file('diagnostics');
?>
var btn_ok_text = '<?php echo __('Send'); ?>';
var btn_cancel_text = '<?php echo __('Cancel'); ?>';

View File

@ -30,6 +30,7 @@
global $config;
require_once $config['homedir'].'/include/functions_update_manager.php';
require_once $config['homedir'].'/include/class/WelcomeWindow.class.php';
if (is_ajax()) {
@ -122,6 +123,8 @@ if (is_ajax()) {
exit();
}
ui_require_css_file('register');
$initial = isset($config['initial_wizard']) !== true
@ -170,6 +173,16 @@ if (!$config['disabled_newsletter']) {
}
}
$welcome = !$registration && !$show_newsletter && !$initial;
try {
$welcome_window = new WelcomeWindow($welcome);
if ($welcome_window !== null) {
$welcome_window->run();
}
} catch (Exception $e) {
$welcome = false;
}
$newsletter = null;
?>

View File

@ -2278,6 +2278,10 @@ if ($updateGIS) {
// -----------------------------------
// Load page depending on tab selected
// -----------------------------------
if ($_SESSION['create_module'] && $config['welcome_state'] == 1) {
$edit_module = true;
}
switch ($tab) {
case 'main':
include 'agent_manager.php';

View File

@ -391,6 +391,9 @@ if ($id_agent_module) {
} else {
if (isset($moduletype) === false) {
$moduletype = (string) get_parameter('moduletype');
if ($_SESSION['create_module'] && $config['welcome_state'] == 1) {
$moduletype = 'networkserver';
}
// Clean up specific network modules fields.
$name = '';

View File

@ -827,7 +827,7 @@ $table->data[5][1] = "
</table>
</div>';
echo '<form method="POST" action="index.php?sec=estado&amp;sec2=godmode/agentes/planned_downtime.editor">';
echo '<form method="POST" action="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor">';
if ($id_downtime > 0) {
echo '<table width=100% border=0 cellpadding=4 >';
@ -929,7 +929,7 @@ if ($id_downtime > 0) {
$disabled_add_button = true;
}
echo "<form method=post action='index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor&id_downtime=$id_downtime'>";
echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&id_downtime=$id_downtime'>";
html_print_select_groups(false, $access, true, 'filter_group', $filter_group, '', '', '', false, false, true, '', false, 'min-width:180px;margin-right:15px;');
html_print_checkbox('recursion', 1, $recursion, false, false, '');
@ -939,7 +939,7 @@ if ($id_downtime > 0) {
echo '</form>';
// Show available agents to include into downtime
echo '<h4>'.__('Available agents').':</h4>';
echo "<form method=post action='index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>";
echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>";
echo html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, false, true, true, '', false, 'width: 180px;');
@ -1085,7 +1085,7 @@ if ($id_downtime > 0) {
$data[5] = '<a href="javascript:show_editor_module('.$downtime_agent['id_agente'].');">'.html_print_image('images/config.png', true, ['border' => '0', 'alt' => __('Delete')]).'</a>';
}
$data[5] .= '<a href="index.php?sec=estado&amp;sec2=godmode/agentes/planned_downtime.editor&id_agent='.$downtime_agent['id_agente'].'&delete_downtime_agent=1&id_downtime_agent='.$downtime_agent['id'].'&id_downtime='.$id_downtime.'">'.html_print_image('images/cross.png', true, ['border' => '0', 'alt' => __('Delete')]).'</a>';
$data[5] .= '<a href="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor&id_agent='.$downtime_agent['id_agente'].'&delete_downtime_agent=1&id_downtime_agent='.$downtime_agent['id'].'&id_downtime='.$id_downtime.'">'.html_print_image('images/cross.png', true, ['border' => '0', 'alt' => __('Delete')]).'</a>';
}
$table->data['agent_'.$downtime_agent['id_agente']] = $data;

View File

@ -357,7 +357,7 @@ if (!$downtimes && !$filter_performed) {
// No downtimes cause the user performed a search.
else if (!$downtimes) {
// Filter form.
echo "<form method='post' action='index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list'>";
echo "<form method='post' action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>";
html_print_table($table_form);
echo '</form>';
@ -369,7 +369,7 @@ else if (!$downtimes) {
// Create button.
if ($write_permisson) {
echo '&nbsp;';
echo '<form method="post" action="index.php?sec=estado&amp;sec2=godmode/agentes/planned_downtime.editor" style="display: inline;">';
echo '<form method="post" action="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor" style="display: inline;">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
echo '</form>';
}
@ -378,11 +378,11 @@ else if (!$downtimes) {
}
// Has downtimes.
else {
echo "<form method='post' action='index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list'>";
echo "<form method='post' action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>";
html_print_table($table_form);
echo '</form>';
ui_pagination($downtimes_number, "index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset);
ui_pagination($downtimes_number, "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset);
// User groups with AR, AD or AW permission.
$groupsAD = users_get_groups($config['id_user'], $access);
@ -476,7 +476,7 @@ else {
if (in_array($downtime['id_group'], $groupsAD)) {
// Stop button
if ($downtime['type_execution'] == 'once' && $downtime['executed'] == 1) {
$data['stop'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list'.'&stop_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cancel.png', true, ['title' => __('Stop downtime')]);
$data['stop'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'.'&stop_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cancel.png', true, ['title' => __('Stop downtime')]);
} else {
$data['stop'] = '';
}
@ -484,12 +484,12 @@ else {
// Edit & delete buttons.
if ($downtime['executed'] == 0) {
// Edit.
$data['edit'] = '<a href="index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update')]).'</a>';
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update')]).'</a>';
// Delete.
$data['delete'] = '<a id="delete_downtime" href="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list'.'&delete_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]);
$data['delete'] = '<a id="delete_downtime" href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'.'&delete_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]);
} else if ($downtime['executed'] == 1 && $downtime['type_execution'] == 'once') {
// Edit.
$data['edit'] = '<a href="index.php?sec=estado&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update')]).'</a>';
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update')]).'</a>';
// Delete.
$data['delete'] = __('N/A');
} else {
@ -515,7 +515,7 @@ else {
}
html_print_table($table);
ui_pagination($downtimes_number, "index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset, 0, false, 'offset', true, 'pagination-bottom');
ui_pagination($downtimes_number, "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset, 0, false, 'offset', true, 'pagination-bottom');
echo '<div class="action-buttons" style="width: '.$table->width.'">';
// CSV export button.
@ -532,7 +532,7 @@ else {
// Create button.
if ($write_permisson) {
echo '&nbsp;';
echo '<form method="post" action="index.php?sec=estado&amp;sec2=godmode/agentes/planned_downtime.editor" style="display: inline;">';
echo '<form method="post" action="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor" style="display: inline;">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
echo '</form>';
}
@ -559,7 +559,7 @@ $(document).ready (function () {
if (<?php echo json_encode($malformed_downtimes_exist); ?> && <?php echo json_encode($migrate_malformed == false); ?>) {
if (confirm("<?php echo __('WARNING: There are malformed planned downtimes').'.\n'.__('Do you want to migrate automatically the malformed items?'); ?>")) {
window.location.href = "index.php?sec=estado&sec2=godmode/agentes/planned_downtime.list&migrate_malformed=1";
window.location.href = "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&migrate_malformed=1";
}
}
});

View File

@ -482,51 +482,6 @@ switch ($action) {
$period = $item['period'];
break;
/*
case 'TTRT':
$description = $item['description'];
$idAgentModule = $item['id_agent_module'];
$idAgent = db_get_value_filter(
'id_agente',
'tagente_modulo',
['id_agente_modulo' => $idAgentModule]
);
$period = $item['period'];
break;
case 'TTO':
$description = $item['description'];
$idAgentModule = $item['id_agent_module'];
$idAgent = db_get_value_filter(
'id_agente',
'tagente_modulo',
['id_agente_modulo' => $idAgentModule]
);
$period = $item['period'];
break;
case 'MTBF':
$description = $item['description'];
$idAgentModule = $item['id_agent_module'];
$idAgent = db_get_value_filter(
'id_agente',
'tagente_modulo',
['id_agente_modulo' => $idAgentModule]
);
$period = $item['period'];
break;
case 'MTTR':
$description = $item['description'];
$idAgentModule = $item['id_agent_module'];
$idAgent = db_get_value_filter(
'id_agente',
'tagente_modulo',
['id_agente_modulo' => $idAgentModule]
);
$period = $item['period'];
break;
*/
case 'alert_report_module':
$description = $item['description'];
$idAgentModule = $item['id_agent_module'];
@ -791,11 +746,6 @@ switch ($action) {
case 'avg_value':
case 'projection_graph':
case 'prediction_date':
/*
case 'TTRT':
case 'TTO':
case 'MTBF':
case 'MTTR':*/
case 'simple_baseline_graph':
case 'event_report_log':
case 'increment':
@ -3757,10 +3707,6 @@ $(document).ready (function () {
case 'event_report_module':
case 'simple_graph':
case 'simple_baseline_graph':
/* case 'TTRT':
case 'TTO':
case 'MTBF':
case 'MTTR':*/
case 'prediction_date':
case 'projection_graph':
case 'avg_value':
@ -3798,10 +3744,6 @@ $(document).ready (function () {
case 'event_report_module':
case 'simple_graph':
case 'simple_baseline_graph':
/* case 'TTRT':
case 'TTO':
case 'MTBF':
case 'MTTR':*/
case 'prediction_date':
case 'projection_graph':
case 'avg_value':
@ -4833,38 +4775,6 @@ function chooseType() {
$("#row_period").show();
$("#row_historical_db_check").hide();
break;
/*
case 'TTRT':
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_historical_db_check").hide();
break;
case 'TTO':
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_historical_db_check").hide();
break;
case 'MTBF':
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_historical_db_check").hide();
break;
case 'MTTR':
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_historical_db_check").hide();
break;*/
case 'alert_report_module':
$("#row_description").show();
@ -5218,10 +5128,6 @@ function chooseType() {
case 'min_value':
case 'max_value':
case 'avg_value':
/* case 'TTRT':
case 'TTO':
case 'MTBF':
case 'MTTR':*/
case 'simple_baseline_graph':
$("#row_label").show();
break;

View File

@ -2006,11 +2006,6 @@ switch ($action) {
case 'avg_value':
case 'projection_graph':
case 'prediction_date':
/*
case 'TTRT':
case 'TTO':
case 'MTBF':
case 'MTTR':*/
case 'simple_baseline_graph':
case 'nt_top_n':
if ($label != '') {
@ -2613,11 +2608,6 @@ switch ($action) {
case 'avg_value':
case 'projection_graph':
case 'prediction_date':
/*
case 'TTRT':
case 'TTO':
case 'MTBF':
case 'MTTR':*/
case 'simple_baseline_graph':
case 'nt_top_n':
if ($label != '') {

View File

@ -0,0 +1,62 @@
<?php
/**
* Welcome window ajax controller.
*
* @category WelcomeWindow
* @package Pandora FMS
* @subpackage New Installation Welcome Window
* @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.
* ============================================================================
*/
// Begin.
global $config;
require_once $config['homedir'].'/include/class/WelcomeWindow.class.php';
if (is_ajax() === false) {
exit;
}
$ajaxPage = 'include/ajax/welcome_window';
// Control call flow.
try {
// User access and validation is being processed on class constructor.
$welcome_actions = new WelcomeWindow(true, $ajaxPage);
} catch (Exception $e) {
exit;
}
// Ajax controller.
$method = get_parameter('method', '');
if (method_exists($welcome_actions, $method) === true) {
if ($welcome_actions->ajaxMethod($method) === true) {
$welcome_actions->{$method}();
} else {
$welcome_actions->error('Unavailable method.');
}
} else {
$welcome_actions->error('Method not found. ['.$method.']');
}
// Stop any execution.
exit;

View File

@ -1801,6 +1801,7 @@ class Diagnostics extends Wizard
'id' => 'modal_form_feedback',
'onsubmit' => 'return false;',
'class' => 'modal',
'extra' => 'novalidate',
];
$inputs = [];

View File

@ -2642,8 +2642,17 @@ class NetworkMap
*/
public function loadMapData()
{
global $config;
$networkmap = $this->map;
// ACL.
$networkmap_write = check_acl(
$config['id_user'],
$networkmap['id_group'],
'MW'
);
$simulate = false;
if (isset($networkmap['__simulated']) === false) {
$networkmap['filter'] = json_decode(
@ -2711,6 +2720,7 @@ class NetworkMap
$output .= 'var networkmap_center = [ '.$networkmap['center_x'].', '.$networkmap['center_y']."];\n";
$output .= 'var networkmap_dimensions = [ '.$networkmap['width'].', '.$networkmap['height']."];\n";
$output .= 'var enterprise_installed = '.((int) enterprise_installed()).";\n";
$output .= 'var networkmap_write = '.$networkmap_write.";\n";
$output .= 'var node_radius = '.$networkmap['filter']['node_radius'].";\n";
$output .= 'var networkmap_holding_area_dimensions = '.json_encode($networkmap['filter']['holding_area']).";\n";
$output .= "var networkmap = {'nodes': [], 'links': []};\n";

View File

@ -0,0 +1,760 @@
<?php
/**
* Welcome to Pandora FMS feature.
*
* @category Class
* @package Pandora FMS
* @subpackage New Installation Welcome Window
* @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.
* ============================================================================
*/
// Begin.
global $config;
require_once $config['homedir'].'/godmode/wizards/Wizard.main.php';
/**
* Class WelcomeWindow.
*/
class WelcomeWindow extends Wizard
{
/**
* Allowed methods to be called using AJAX request.
*
* @var array
*/
public $AJAXMethods = [
'loadWelcomeWindow',
'cancelWelcome',
];
/**
* Url of controller.
*
* @var string
*/
public $ajaxController;
/**
* Current step.
*
* @var integer
*/
public $step;
/**
* Current agent (created example).
*
* @var integer
*/
public $agent;
/**
* Generates a JSON error.
*
* @param string $msg Error message.
*
* @return void
*/
public function error($msg)
{
echo json_encode(
['error' => $msg]
);
}
/**
* Checks if target method is available to be called using AJAX.
*
* @param string $method Target method.
*
* @return boolean True allowed, false not.
*/
public function ajaxMethod($method)
{
global $config;
// Check access.
check_login();
return in_array($method, $this->AJAXMethods);
}
/**
* Constructor.
*
* @param boolean $must_run Must run or not.
* @param string $ajax_controller Controller.
*
* @return object
* @throws Exception On error.
*/
public function __construct(
bool $must_run=false,
$ajax_controller='include/ajax/welcome_window'
) {
$this->ajaxController = $ajax_controller;
if ($this->initialize($must_run) !== true) {
throw new Exception('Must not be shown');
}
return $this;
}
/**
* Main method.
*
* @return void
*/
public function run()
{
ui_require_css_file('new_installation_welcome_window');
echo '<div id="welcome_modal_window" style="display: none"; >';
?>
<script type="text/javascript">
load_modal({
target: $('#welcome_modal_window'),
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
modal: {
title: "<?php echo __('Welcome to Pandora FMS'); ?>",
cancel: '<?php echo __('Ignore'); ?>',
ok: '<?php echo __('Cancel'); ?>'
},
onshow: {
page: '<?php echo $this->ajaxController; ?>',
method: 'loadWelcomeWindow',
},
oncancel: {
page: '<?php echo $this->ajaxController; ?>',
title: "<?php echo __('Cancel Configuration Window'); ?>",
method: 'cancelWelcome',
confirm: function (fn) {
confirmDialog({
title: '<?php echo __('Are you sure?'); ?>',
message: '<?php echo __('Are you sure you want to cancel this tutorial?'); ?>',
ok: '<?php echo __('OK'); ?>',
cancel: '<?php echo __('Cancel'); ?>',
onAccept: function() {
// Continue execution.
fn();
}
})
}
}
});
</script>
<?php
echo '</div>';
}
/**
* Method to cancel welcome modal window.
*
* @return void
*/
public function cancelWelcome()
{
// Config update value.
$this->setStep(WELCOME_FINISHED);
}
/**
* Return current step.
*
* @return integer Step.
*/
public function getStep(): int
{
global $config;
$this->step = $config['welcome_state'];
return $this->step;
}
/**
* Sets current step.
*
* @param integer $step Current step.
*
* @return void
*/
public function setStep(int $step)
{
$this->step = $step;
config_update_value('welcome_state', $step);
}
/**
* Retrieve current welcome agent id.
*
* @return integer Agent id (created).
*/
public function getWelcomeAgent()
{
global $config;
return $config['welcome_id_agent'];
}
/**
* Saves current welcome agent (latest created).
*
* @param integer $id_agent Agent id.
*
* @return void
*/
public function setWelcomeAgent(int $id_agent)
{
config_update_value('welcome_id_agent', $id_agent);
}
/**
* Loads a welcome window form
*
* @return string HTML code for form.
*
* @return void Runs loadWelcomeWindow (AJAX).
*/
public function loadWelcomeWindow()
{
global $config;
$btn_configure_mail_class = 'pending';
$btn_create_agent_class = 'pending';
$btn_create_module_class = '';
$btn_create_alert_class = '';
$btn_create_discovery_class = 'pending';
switch ($this->step) {
case W_CREATE_AGENT:
$btn_configure_mail_class = ' completed';
$btn_create_agent_class = ' pending';
break;
case W_CREATE_MODULE:
$btn_configure_mail_class = ' completed';
$btn_create_agent_class = ' completed';
$btn_create_module_class = ' pending';
break;
case W_CREATE_ALERT:
$btn_configure_mail_class = ' completed';
$btn_create_agent_class = ' completed';
$btn_create_module_class = ' completed';
$btn_create_alert_class = ' pending';
break;
case W_CREATE_TASK:
$btn_configure_mail_class = ' completed';
$btn_create_agent_class = ' completed';
$btn_create_module_class = ' completed';
$btn_create_alert_class = ' completed';
$btn_create_discovery_class = ' pending';
break;
case WELCOME_FINISHED:
// Nothing left to do.
$btn_configure_mail_class = ' completed';
$btn_create_agent_class = ' completed';
$btn_create_module_class = ' completed';
$btn_create_alert_class = ' completed';
$btn_create_discovery_class = ' completed';
break;
default:
case W_CONFIGURE_MAIL:
// Nothing done yet.
$btn_configure_mail_class = ' pending';
break;
}
$form = [
'action' => '#',
'id' => 'welcome_form',
'onsubmit' => 'this.dialog("close");',
'class' => 'modal',
];
$inputs = [
[
'wrapper' => 'div',
'block_id' => 'div_configure_mail',
'class' => 'flex-row w100p',
'direct' => 1,
'block_content' => [
[
'label' => __('Please ensure mail configuration matches your needs'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_create_agent',
'id' => 'lbl_create_agent',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => 'class="go '.$btn_configure_mail_class.'"',
'name' => 'btn_email_conf',
'id' => 'btn_email_conf',
],
],
],
],[
'wrapper' => 'div',
'block_id' => 'div_create_agent',
'class' => 'flex-row w100p',
'direct' => 1,
'block_content' => [
[
'label' => __('Create an agent'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_create_agent',
'id' => 'lbl_create_agent',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => 'class="go '.$btn_create_agent_class.'"',
'name' => 'btn_create_agent',
'id' => 'btn_create_agent',
],
],
],
],
[
'label' => 'Learn to monitor',
'arguments' => [
'class' => 'class="lbl_learn"',
'name' => 'lbl_learn',
'id' => 'lbl_learn',
],
],
[
'wrapper' => 'div',
'block_id' => 'div_monitor_actions',
'class' => 'learn_content_indented flex-row w100p',
'direct' => 1,
'block_content' => [
[
'label' => __('Create a module to check if an agent is online'),
'arguments' => [
'class' => 'second_lbl',
'name' => 'lbl_check_agent',
'id' => 'lbl_check_agent',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => 'class="go '.$btn_create_module_class.'"',
'name' => 'btn_create_module',
'id' => 'btn_create_module',
],
],
],
],
[
'wrapper' => 'div',
'block_id' => 'div_monitor_actions',
'class' => 'learn_content_indented flex-row w100p',
'direct' => 1,
'block_content' => [
[
'label' => __('Be warned if something is wrong, create an alert on the module'),
'arguments' => [
'class' => 'second_lbl',
'name' => 'lbl_create_alert',
'id' => 'lbl_create_alert',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => 'class="go '.$btn_create_alert_class.'"',
'name' => 'btn_create_alert',
'id' => 'btn_create_alert',
],
],
],
],
[
'wrapper' => 'div',
'block_id' => 'div_discover',
'class' => 'flex-row w100p',
'direct' => 1,
'block_content' => [
[
'label' => __('Discover hosts and devices in your network'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_discover_devices',
'id' => 'lbl_discover_devices',
],
],
[
'arguments' => [
'label' => '',
'type' => 'button',
'attributes' => 'class="go '.$btn_create_discovery_class.'"',
'name' => 'btn_discover_devices',
'id' => 'btn_discover_devices',
],
],
],
],
[
'wrapper' => 'div',
'block_id' => 'div_not_working',
'class' => 'flex-row w100p',
'direct' => 1,
'block_content' => [
[
'label' => __('If something is not working as expected, look for this icon and report!'),
'arguments' => [
'class' => 'first_lbl',
'name' => 'lbl_not_working',
'id' => 'lbl_not_working',
],
],
[
'label' => html_print_image(
'images/feedback-header.png',
true,
[
'onclick' => '$(\'#feedback-header\').click()',
'style' => 'cursor: pointer;',
]
),
],
],
],
];
$output = $this->printForm(
[
'form' => $form,
'inputs' => $inputs,
],
true
);
$output .= $this->loadJS();
echo $output;
// Ajax methods does not continue.
exit();
}
/**
* This function acts as a constructor. Receive the condition to check with
* the global config (welcome_state) if continues
*
* @param boolean $must_run Must be run or not (check register.php).
*
* @return boolean True if initialized or false if must not run.
*/
public function initialize($must_run)
{
global $config;
if (isset($config['welcome_state']) === false) {
$this->setStep(W_CONFIGURE_MAIL);
}
// Check current page.
$sec2 = get_parameter('sec2', '');
if ($must_run === false
|| $config['welcome_state'] === WELCOME_FINISHED
) {
// Do not show if finished.
return false;
}
$this->step = $this->getStep();
$this->agent = $this->getWelcomeAgent();
/*
* Configure mail. Control current flow.
*
* On empty sec2: show current step.
* On setup page: do not show.
* After mail configuration: enable agent step.
*/
if ($this->step == W_CONFIGURE_MAIL) {
if ($sec2 === 'godmode/setup/setup'
&& get_parameter('section', '') == 'general'
&& get_parameter('update_config', false) !== false
) {
// Mail configuration have been processed.
$_SESSION['configured_mail'] = true;
$this->setStep(W_CREATE_AGENT);
} else if ($sec2 === 'godmode/setup/setup'
&& get_parameter('section', '') === 'general'
) {
// Mail configuration is being processed.
return false;
} else if (empty($sec2) === true) {
// If at main page, show welcome.
return true;
}
}
/*
* Create agent. Control current flow.
*
* On empty sec2: show current step.
* On agent creation page: do not show.
* After agent creation: enable module step.
*/
if ($this->step === W_CREATE_AGENT) {
// Create agent is pending.
if ($sec2 === 'godmode/agentes/configurar_agente'
&& get_parameter('create_agent', false) !== false
) {
// Agent have been created. Store.
$this->setWelcomeAgent(
db_get_value(
'MAX(id_agente)',
'tagente'
)
);
$this->setStep(W_CREATE_MODULE);
return true;
} else if ($sec2 === 'godmode/agentes/configurar_agente') {
// Agent is being created.
return false;
} else if (empty($sec2) === true) {
// If at main page, show welcome.
return true;
}
}
/*
* Create module. Control current flow.
*
* On empty sec2: show current step.
* On module creation page: do not show.
* After module creation: enable alert step.
*/
if ($this->step === W_CREATE_MODULE) {
// Create module is pending.
if ($sec2 === 'godmode/agentes/configurar_agente'
&& get_parameter('tab', '') === 'module'
&& get_parameter('create_module', false) !== false
) {
// Module have been created.
$this->setStep(W_CREATE_ALERT);
return true;
} else if ($sec2 === 'godmode/agentes/configurar_agente'
&& get_parameter('tab', '') === 'module'
) {
// Module is being created.
return false;
} else if (empty($sec2) === true) {
// If at main page, show welcome.
return true;
}
}
/*
* Create alert. Control current flow.
*
* On empty sec2: show current step.
* On alert creation page: do not show.
* After alert creation: enable discovery task step.
*/
if ($this->step === W_CREATE_ALERT) {
// Create alert is pending.
if ($sec2 === 'godmode/agentes/configurar_agente'
&& get_parameter('tab', '') === 'alert'
&& get_parameter('create_alert', false) !== false
) {
// Alert have been created.
$this->setStep(W_CREATE_TASK);
return true;
} else if ($sec2 === 'godmode/agentes/configurar_agente'
&& get_parameter('tab', '') === 'alert'
) {
// Alert is being created.
return false;
} else if (empty($sec2) === true) {
// If at main page, show welcome.
return true;
}
}
/*
* Create discovery task. Control current flow.
*
* On empty sec2: show current step.
* On discovery task creation page: do not show.
* After discovery task creation: finish.
*/
if ($this->step === W_CREATE_TASK) {
// Create Discovery task is pending.
// Host&Devices finishses on page 2.
if ($sec2 === 'godmode/servers/discovery'
&& get_parameter('page', 0) == 2
) {
// Discovery task have been created.
$this->setStep(WELCOME_FINISHED);
// Finished! do not show.
return false;
} else if ($sec2 == 'godmode/servers/discovery') {
// Discovery task is being created.
return false;
} else if (empty($sec2) === true) {
// If at main page, show welcome.
return true;
}
}
if ($this->step === WELCOME_FINISHED) {
// Welcome tutorial finished.
return false;
}
// Return a reference to the new object.
return false;
}
/**
* Load JS content.
* function that enables the functions to the buttons when its action is
* completed.
* Assign the url of each button.
*
* @return string HTML code for javascript functionality.
*/
public function loadJS()
{
ob_start();
?>
<script type="text/javascript">
<?php
if ($this->step > W_CREATE_AGENT) {
switch ($this->step) {
case W_CREATE_MODULE:
?>
document.getElementById("button-btn_create_module").setAttribute(
'onclick',
'checkAgentOnline()'
);
<?php
break;
case W_CREATE_ALERT:
?>
document.getElementById("button-btn_create_alert").setAttribute(
'onclick',
'createAlertModule()'
);
<?php
break;
default:
// Ignore.
break;
}
}
?>
document.getElementById("button-btn_email_conf").setAttribute(
'onclick',
'configureEmail()'
);
document.getElementById("button-btn_create_agent").setAttribute(
'onclick',
'createNewAgent()'
);
document.getElementById("button-btn_discover_devices").setAttribute(
'onclick',
'discoverDevicesNetwork()'
);
function configureEmail() {
window.location = '<?php echo ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=general#table3'); ?>';
}
function createNewAgent() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&new_agent=1&crt-2=Create+agent'); ?>';
}
function checkAgentOnline() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$this->getWelcomeAgent().''); ?>';
}
function createAlertModule() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$this->getWelcomeAgent().''); ?>';
}
function monitorRemoteCommands() {
window.location = '<?php echo ui_get_full_url(''); ?>';
}
function discoverDevicesNetwork() {
window.location = '<?php echo ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan'); ?>';
}
function reportIsNotWorking() {
}
function cierre_dialog(){
this.dialog("close");
}
</script>
<?php
return ob_get_clean();
}
}

View File

@ -648,3 +648,12 @@ define('HA_PENDING', 2);
define('HA_PROCESSING', 3);
define('HA_DISABLED', 4);
define('HA_FAILED', 5);
define('WELCOME_STARTED', 1);
define('W_CONFIGURE_MAIL', 1);
define('W_CREATE_AGENT', 2);
define('W_CREATE_MODULE', 3);
define('W_CREATE_ALERT', 4);
define('W_CREATE_TASK', 5);
define('WELCOME_FINISHED', -1);

View File

@ -1895,6 +1895,10 @@ function config_process_config()
config_update_value('unique_ip', 0);
}
if (!isset($config['welcome_state'])) {
config_update_value('welcome_state', WELCOME_STARTED);
}
/*
* Parse the ACL IP list for access API
*/

View File

@ -1905,7 +1905,7 @@ function html_print_button($label='OK', $name='', $disabled=false, $script='', $
*/
function html_print_textarea($name, $rows, $columns, $value='', $attributes='', $return=false, $class='')
{
$output = '<textarea id="textarea_'.$name.'" name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.'" class="'.$class.'">';
$output = '<textarea id="textarea_'.$name.'" name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.' class="'.$class.'">';
// $output .= io_safe_input ($value);
$output .= ($value);
$output .= '</textarea>';

View File

@ -224,7 +224,12 @@ function reporting_make_reporting_data(
// General reports with 0 period means last value
// Avoid to overwrite it by template value.
if (!empty($period) && ($content['type'] !== 'general' && $content['period'] != 0)) {
$general_last_value = false;
if ($content['type'] === 'general' && $content['period'] == 0) {
$general_last_value = true;
}
if (!empty($period) && $general_last_value === false) {
$content['period'] = $period;
}
@ -506,43 +511,6 @@ function reporting_make_reporting_data(
);
break;
/*
case 'MTTR':
$report['contents'][] = reporting_value(
$report,
$content,
'MTTR',
$pdf
);
break;
case 'MTBF':
$report['contents'][] = reporting_value(
$report,
$content,
'MTBF',
$pdf
);
break;
case 'TTO':
$report['contents'][] = reporting_value(
$report,
$content,
'TTO',
$pdf
);
break;
case 'TTRT':
$report['contents'][] = reporting_value(
$report,
$content,
'TTRT',
$pdf
);
break;
*/
case 'agent_configuration':
$report['contents'][] = io_safe_output(
reporting_agent_configuration(
@ -3276,6 +3244,7 @@ function reporting_database_serialized($report, $content)
}
$return['keys'] = $keys;
$return['agent_name_db'] = agents_get_name($id_agent);
$return['agent_name'] = $agent_alias;
$return['module_name'] = $module_name;
@ -4303,6 +4272,7 @@ function reporting_monitor_report($report, $content)
);
}
$return['agent_name_db'] = agents_get_name($id_agent);
$return['agent_name'] = $agent_alias;
$return['module_name'] = $module_name;
@ -4475,6 +4445,7 @@ function reporting_prediction_date($report, $content)
$agent_name = io_safe_output(
modules_get_agentmodule_agent_alias($content['id_agent_module'])
);
$agent_name_db = io_safe_output(modules_get_agentmodule_agent_name($content['id_agent_module']));
$return['title'] = $content['name'];
$return['subtitle'] = $agent_name.' - '.$module_name;
@ -4482,6 +4453,7 @@ function reporting_prediction_date($report, $content)
$return['date'] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$return['agent_name_db'] = $agent_name_db;
$return['agent_name'] = $agent_name;
$return['module_name'] = $module_name;
@ -4526,12 +4498,14 @@ function reporting_projection_graph(
$module_name = io_safe_output(modules_get_agentmodule_name($content['id_agent_module']));
$agent_name = io_safe_output(modules_get_agentmodule_agent_alias($content['id_agent_module']));
$agent_name_db = io_safe_output(modules_get_agentmodule_agent_name($content['id_agent_module']));
$return['title'] = $content['name'];
$return['subtitle'] = $agent_name.' - '.$module_name;
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$return['agent_name_db'] = $agent_name_db;
$return['agent_name'] = $agent_name;
$return['module_name'] = $module_name;
@ -4727,23 +4701,6 @@ function reporting_value($report, $content, $type, $pdf=false)
case 'sum':
$return['type'] = 'sumatory';
break;
/*
case 'MTTR':
$return['type'] = 'MTTR';
break;
case 'MTBF':
$return['type'] = 'MTBF';
break;
case 'TTO':
$return['type'] = 'TTO';
break;
case 'TTRT':
$return['type'] = 'TTRT';
break;*/
}
if (empty($content['name'])) {
@ -4763,23 +4720,6 @@ function reporting_value($report, $content, $type, $pdf=false)
case 'sum':
$content['name'] = __('Summatory');
break;
/*
case 'MTTR':
$content['name'] = __('MTTR');
break;
case 'MTBF':
$content['name'] = __('MTBF');
break;
case 'TTO':
$content['name'] = __('TTO');
break;
case 'TTRT':
$content['name'] = __('TTRT');
break;*/
}
}
@ -4796,6 +4736,9 @@ function reporting_value($report, $content, $type, $pdf=false)
$agent_name = io_safe_output(
modules_get_agentmodule_agent_alias($content['id_agent_module'])
);
$agent_name_db = io_safe_output(
modules_get_agentmodule_agent_name($content['id_agent_module'])
);
$unit = db_get_value(
'unit',
'tagente_modulo',
@ -4812,6 +4755,7 @@ function reporting_value($report, $content, $type, $pdf=false)
$return['id_agent'] = $content['id_agent'];
$return['id_agent_module'] = $content['id_agent_module'];
$return['agent_name_db'] = $agent_name_db;
$return['agent_name'] = $agent_name;
$return['module_name'] = $module_name;
@ -4952,51 +4896,6 @@ function reporting_value($report, $content, $type, $pdf=false)
$formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit;
}
break;
/*
case 'MTTR':
$value = reporting_get_agentmodule_mttr(
$content['id_agent_module'],
$content['period'],
$report['datetime']
);
$formated_value = null;
break;
case 'MTBF':
$value = reporting_get_agentmodule_mtbf(
$content['id_agent_module'],
$content['period'],
$report['datetime']
);
$formated_value = null;
break;
case 'TTO':
$value = reporting_get_agentmodule_tto(
$content['id_agent_module'],
$content['period'],
$report['datetime']
);
if ($value == 0) {
$formated_value = null;
} else {
$formated_value = human_time_description_raw($value);
}
break;
case 'TTRT':
$value = reporting_get_agentmodule_ttr(
$content['id_agent_module'],
$content['period'],
$report['datetime']
);
if ($value == 0) {
$formated_value = null;
} else {
$formated_value = human_time_description_raw($value);
}
break;*/
}
$return['data'] = [
@ -7755,6 +7654,7 @@ function reporting_simple_graph(
$return['title'] = $content['name'];
$return['subtitle'] = $agent_alias.' - '.$module_name;
$return['agent_name_db'] = agents_get_name($id_agent);
$return['agent_name'] = $agent_alias;
$return['module_name'] = $module_name;
$return['description'] = $content['description'];

View File

@ -288,23 +288,6 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_sum_value($table, $item, $mini);
break;
/*
case 'MTTR':
reporting_html_MTTR_value($table, $item, $mini, true, true);
break;
case 'MTBF':
reporting_html_MTBF_value($table, $item, $mini, true, true);
break;
case 'TTO':
reporting_html_TTO_value($table, $item, $mini, false, true);
break;
case 'TTRT':
reporting_html_TTRT_value($table, $item, $mini, false, true);
break;
*/
case 'agent_configuration':
reporting_html_agent_configuration($table, $item);
break;
@ -2729,31 +2712,6 @@ function reporting_html_agent_configuration(
}
/*
function reporting_html_TTRT_value(&$table, $item, $mini, $only_value=false, $check_empty=false)
{
reporting_html_value($table, $item, $mini, $only_value, $check_empty);
}
function reporting_html_TTO_value(&$table, $item, $mini, $only_value=false, $check_empty=false)
{
reporting_html_value($table, $item, $mini, $only_value, $check_empty);
}
function reporting_html_MTBF_value(&$table, $item, $mini, $only_value=false, $check_empty=false)
{
reporting_html_value($table, $item, $mini, $only_value, $check_empty);
}
function reporting_html_MTTR_value(&$table, $item, $mini, $only_value=false, $check_empty=false)
{
reporting_html_value($table, $item, $mini, $only_value, $check_empty);
}
*/
function reporting_html_sum_value(&$table, $item, $mini)
{
reporting_html_value($table, $item, $mini);

View File

@ -679,24 +679,6 @@ function reports_get_report_types($template=false, $not_editor=false)
'name' => __('Module Histogram graph'),
];
/*
$types['TTRT'] = [
'optgroup' => __('ITIL'),
'name' => __('TTRT'),
];
$types['TTO'] = [
'optgroup' => __('ITIL'),
'name' => __('TTO'),
];
$types['MTBF'] = [
'optgroup' => __('ITIL'),
'name' => __('MTBF'),
];
$types['MTTR'] = [
'optgroup' => __('ITIL'),
'name' => __('MTTR'),
];
*/
$types['SLA'] = [
'optgroup' => __('SLA'),
'name' => __('S.L.A.'),

View File

@ -14,6 +14,7 @@
/* global holding_area_dimensions */
/* global networkmap_id */
/* global enterprise_installed */
/* global networkmap_write */
/* global force */
/* global layer_graph_nodes */
/* global layer_graph_links */
@ -2087,7 +2088,12 @@ function show_menu(item, data) {
icon: "add_node",
disabled: function() {
if (enterprise_installed) {
return false;
// Check if user can write network maps.
if (networkmap_write) {
return false;
} else {
return true;
}
} else {
return true;
}
@ -2099,6 +2105,14 @@ function show_menu(item, data) {
items_list["center"] = {
name: set_center_menu,
icon: "center",
disabled: function() {
// Check if user can write network maps.
if (networkmap_write) {
return false;
} else {
return true;
}
},
callback: function(key, options) {
set_center(networkmap_id);
}
@ -2136,7 +2150,12 @@ function show_menu(item, data) {
icon: "restart_map",
disabled: function() {
if (enterprise_installed) {
return false;
// Check if user can write network maps.
if (networkmap_write) {
return false;
} else {
return true;
}
} else {
return true;
}

View File

@ -1900,6 +1900,169 @@ function load_modal(settings) {
buttons: []
})
.show();
var required_buttons = [];
if (settings.modal.cancel != undefined) {
//The variable contains a function
// that is responsible for executing the method it receives from settings
// which confirms the closure of a modal
var cancelModal = function() {
settings.target.dialog("close");
if (AJAX_RUNNING) return;
AJAX_RUNNING = 1;
var formdata = new FormData();
formdata.append("page", settings.oncancel.page);
formdata.append("method", settings.oncancel.method);
$.ajax({
method: "post",
url: settings.url,
processData: false,
contentType: false,
data: formdata,
success: function(data) {
if (typeof settings.oncancel.callback == "function") {
settings.oncancel.callback(data);
settings.target.dialog("close");
}
AJAX_RUNNING = 0;
},
error: function(data) {
// console.log(data);
AJAX_RUNNING = 0;
}
});
};
required_buttons.push({
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel",
text: settings.modal.cancel,
click: function() {
if (settings.oncancel != undefined) {
if (typeof settings.oncancel.confirm == "function") {
//receive function
settings.oncancel.confirm(cancelModal);
} else if (settings.oncancel != undefined) {
cancelModal();
}
} else {
$(this).dialog("close");
}
}
});
}
if (settings.modal.ok != undefined) {
required_buttons.push({
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
text: settings.modal.ok,
click: function() {
if (AJAX_RUNNING) return;
if (settings.onsubmit != undefined) {
if (settings.onsubmit.preaction != undefined) {
settings.onsubmit.preaction();
}
AJAX_RUNNING = 1;
if (settings.onsubmit.dataType == undefined) {
settings.onsubmit.dataType = "html";
}
var formdata = new FormData();
if (settings.extradata) {
settings.extradata.forEach(function(item) {
if (item.value != undefined)
formdata.append(item.name, item.value);
});
}
formdata.append("page", settings.onsubmit.page);
formdata.append("method", settings.onsubmit.method);
var flagError = false;
$("#" + settings.form + " :input").each(function() {
if (this.checkValidity() === false) {
$(this).attr("title", this.validationMessage);
$(this).tooltip({
tooltipClass: "uitooltip",
position: {
my: "right bottom",
at: "right top",
using: function(position, feedback) {
$(this).css(position);
$("<div>")
.addClass("arrow")
.addClass(feedback.vertical)
.addClass(feedback.horizontal)
.appendTo(this);
}
}
});
$(this).tooltip("open");
var element = $(this);
setTimeout(
function(element) {
element.tooltip("destroy");
element.removeAttr("title");
},
3000,
element
);
flagError = true;
}
if (this.type == "file") {
if ($(this).prop("files")[0]) {
formdata.append(this.name, $(this).prop("files")[0]);
}
} else {
if ($(this).attr("type") == "checkbox") {
if (this.checked) {
formdata.append(this.name, "on");
}
} else {
formdata.append(this.name, $(this).val());
}
}
});
if (flagError === false) {
$.ajax({
method: "post",
url: settings.url,
processData: false,
contentType: false,
data: formdata,
dataType: settings.onsubmit.dataType,
success: function(data) {
if (settings.ajax_callback != undefined) {
if (settings.idMsgCallback != undefined) {
settings.ajax_callback(data, settings.idMsgCallback);
} else {
settings.ajax_callback(data);
}
}
AJAX_RUNNING = 0;
}
});
} else {
AJAX_RUNNING = 0;
}
} else {
// No onsumbit configured. Directly close.
$(this).dialog("close");
}
},
error: function(data) {
// console.log(data);
AJAX_RUNNING = 0;
}
});
}
$.ajax({
method: "post",
@ -1922,105 +2085,63 @@ function load_modal(settings) {
opacity: 0.5,
background: "black"
},
buttons: [
{
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel",
text: settings.modal.cancel,
click: function() {
$(this).dialog("close");
if (typeof settings.cleanup == "function") {
settings.cleanup();
}
}
},
{
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
text: settings.modal.ok,
click: function() {
if (AJAX_RUNNING) return;
AJAX_RUNNING = 1;
if (settings.onsubmit.preaction != undefined) {
settings.onsubmit.preaction();
}
if (settings.onsubmit.dataType == undefined) {
settings.onsubmit.dataType = "html";
}
var formdata = new FormData();
if (settings.extradata) {
settings.extradata.forEach(function(item) {
if (item.value != undefined)
formdata.append(item.name, item.value);
});
}
formdata.append("page", settings.onsubmit.page);
formdata.append("method", settings.onsubmit.method);
var flagError = false;
$("#" + settings.form + " :input").each(function() {
if (this.checkValidity() === false) {
$(this).prop("title", this.validationMessage);
$(this).tooltip({
tooltipClass: "uitooltip",
position: { my: "right bottom", at: "right bottom" },
show: { duration: 200 }
});
$(this).tooltip("open");
flagError = true;
}
if (this.type == "file") {
if ($(this).prop("files")[0]) {
formdata.append(this.name, $(this).prop("files")[0]);
}
} else {
if ($(this).attr("type") == "checkbox") {
if (this.checked) {
formdata.append(this.name, "on");
}
} else {
formdata.append(this.name, $(this).val());
}
}
});
if (flagError === false) {
$.ajax({
method: "post",
url: settings.url,
processData: false,
contentType: false,
data: formdata,
dataType: settings.onsubmit.dataType,
success: function(data) {
if (settings.ajax_callback != undefined) {
if (settings.idMsgCallback != undefined) {
settings.ajax_callback(data, settings.idMsgCallback);
} else {
settings.ajax_callback(data);
}
}
AJAX_RUNNING = 0;
}
});
} else {
AJAX_RUNNING = 0;
}
}
}
],
buttons: required_buttons,
closeOnEscape: false,
open: function() {
$(".ui-dialog-titlebar-close").hide();
}
});
},
error: function(data) {
// console.log(data);
}
});
}
//Function that shows a dialog box to confirm closures of generic manners. The modal id is random
function confirmDialog(settings) {
var randomStr =
Math.random()
.toString(36)
.substring(2, 15) +
Math.random()
.toString(36)
.substring(2, 15);
$("body").append(
'<div id="confirm_' + randomStr + '">' + settings.message + "</div>"
);
$("#confirm_" + randomStr);
$("#confirm_" + randomStr)
.dialog({
title: settings.title,
close: false,
width: 350,
modal: true,
buttons: [
{
text: "Cancel",
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel",
click: function() {
$(this).dialog("close");
if (typeof settings.onDeny == "function") settings.onDeny();
}
},
{
text: "Ok",
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
click: function() {
$(this).dialog("close");
if (typeof settings.onAccept == "function") settings.onAccept();
}
}
]
})
.show();
}
/**
* Function to show modal with message Validation.
*

View File

@ -56,3 +56,11 @@
margin: 30px;
font-style: italic;
}
#modal_form_feedback {
margin: 10px;
}
#div-what-happened label {
margin-bottom: 10px;
}

View File

@ -272,20 +272,11 @@ a.ext_link {
font-size: 8pt;
}
input:invalid,
input[type="email"]:invalid {
border-bottom-color: #fb4444;
}
textarea:invalid {
border-color: #fb4444;
}
div.ui-tooltip.ui-corner-all.ui-widget-shadow.ui-widget.ui-widget-content.uitooltip {
background: grey;
opacity: 0.9;
border-radius: 4px;
box-shadow: 0 0 0px #fff;
box-shadow: 6px 5px 9px -9px black;
padding: 6px;
}
@ -297,3 +288,37 @@ div.ui-tooltip.ui-corner-all.ui-widget-shadow.ui-widget.ui-widget-content.uitool
letter-spacing: 0.03pt;
font-size: 8pt;
}
.arrow {
width: 70px;
height: 16px;
overflow: hidden;
position: absolute;
left: 50%;
margin-left: -35px;
bottom: -16px;
}
.arrow.top {
top: -16px;
bottom: auto;
}
.arrow.left {
left: 50%;
}
.arrow:after {
background: grey;
content: "";
position: absolute;
left: 20px;
top: -20px;
width: 25px;
height: 25px;
box-shadow: 6px 5px 9px -9px black;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.arrow.top:after {
bottom: -20px;
top: auto;
}

View File

@ -0,0 +1,62 @@
.modal {
overflow: hidden;
}
.welcome_modal_window {
overflow: hidden;
}
#welcome_modal_window {
/*
max-height: 100%;
height: 100%;
border-left: 1em solid #82b92f;
margin-bottom: -59px;
padding-bottom: 100px;
margin-left: -1px;
*/
}
#welcome_form ul.wizard li {
padding: 1em;
padding-bottom: 0;
padding-top: 1em;
}
#welcome_form label {
font-family: "lato-lighter", "Open Sans", sans-serif;
font-weight: normal;
}
.content_position {
display: flex;
margin-top: 5px;
font-family: "lato-lighter", "Open Sans", sans-serif;
font-weight: normal;
}
.learn_content_indented {
text-indent: 1.5em;
font-family: "lato-lighter", "Open Sans", sans-serif;
font-weight: normal;
}
#lbl_learn {
font-family: "lato-lighter", "Open Sans", sans-serif;
font-weight: normal;
}
.go {
background-repeat: no-repeat;
background-size: cover;
width: 20px;
height: 20px;
border: none;
}
.pending {
background-image: url(../../images/darrowright.png);
}
.completed {
background-image: url(../../images/input_tick.png);
}

View File

@ -430,15 +430,38 @@ if ($date_to_trap != '') {
}
if ($filter_severity != -1) {
// Test if install the enterprise to search oid in text or oid field in ttrap.
if ($config['enterprise_installed']) {
$whereSubquery .= ' AND (
(alerted = 0 AND severity = '.$filter_severity.') OR
(alerted = 1 AND priority = '.$filter_severity.'))';
} else {
$whereSubquery .= ' AND (
(alerted = 0 AND 1 = '.$filter_severity.') OR
(alerted = 1 AND priority = '.$filter_severity.'))';
// There are two special severity values aimed to match two different trap standard severities in database: warning/critical and critical/normal.
if ($filter_severity != EVENT_CRIT_OR_NORMAL && $filter_severity != EVENT_CRIT_WARNING_OR_CRITICAL) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
if ($config['enterprise_installed']) {
$whereSubquery .= ' AND (
(alerted = 0 AND severity = '.$filter_severity.') OR
(alerted = 1 AND priority = '.$filter_severity.'))';
} else {
$whereSubquery .= ' AND (
(alerted = 0 AND 1 = '.$filter_severity.') OR
(alerted = 1 AND priority = '.$filter_severity.'))';
}
} else if ($filter_severity === EVENT_CRIT_WARNING_OR_CRITICAL) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
if ($config['enterprise_installed']) {
$whereSubquery .= ' AND (
(alerted = 0 AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR
(alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
} else {
$whereSubquery .= ' AND (
(alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
}
} else if ($filter_severity === EVENT_CRIT_OR_NORMAL) {
// Test if enterprise is installed to search oid in text or oid field in ttrap.
if ($config['enterprise_installed']) {
$whereSubquery .= ' AND (
(alerted = 0 AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR
(alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
} else {
$whereSubquery .= ' AND (
(alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))';
}
}
}

View File

@ -3522,6 +3522,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
`time_format` varchar(60) NOT NULL default "time",
`timezone` varchar(60) NOT NULL default "Europe/Madrid",
`show_last_value` tinyint(1) UNSIGNED NULL default '0',
`cache_expiration` INTEGER UNSIGNED NOT NULL default 0,
PRIMARY KEY(`id`),
FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8;

View File

@ -139,6 +139,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('cr_incident_status', ''),
('cr_incident_title', ''),
('cr_incident_content', ''),
('sample_agent', '0'),
('gotty', '/usr/bin/gotty');
UNLOCK TABLES;
@ -269,7 +270,7 @@ INSERT INTO `torigen` VALUES
--
-- Identifiers 30 and 31 are reserved for Enterprise data types
INSERT INTO `ttipo_modulo` VALUES
INSERT INTO `ttipo_modulo` VALUES
(1,'generic_data',0,'Generic numeric','mod_data.png'),
(2,'generic_proc',1,'Generic boolean','mod_proc.png'),
(3,'generic_data_string',2,'Generic string','mod_string.png'),
@ -284,19 +285,15 @@ INSERT INTO `ttipo_modulo` VALUES
(15,'remote_snmp',3,'Remote SNMP network agent, numeric data','mod_snmp_data.png'),
(16,'remote_snmp_inc',3,'Remote SNMP network agent, incremental data','mod_snmp_inc.png'),
(17,'remote_snmp_string',5,'Remote SNMP network agent, alphanumeric data','mod_snmp_string.png'),
(18,'remote_snmp_proc',4,'Remote SNMP network agent, boolean data','mod_snmp_proc.png'),
(21,'async_proc', 7, 'Asyncronous proc data', 'mod_async_proc.png'),
(22,'async_data', 6, 'Asyncronous numeric data', 'mod_async_data.png'),
(18,'remote_snmp_proc',4,'Remote SNMP network agent, boolean data','mod_snmp_proc.png'),
(21,'async_proc', 7, 'Asyncronous proc data', 'mod_async_proc.png'),
(22,'async_data', 6, 'Asyncronous numeric data', 'mod_async_data.png'),
(23,'async_string', 8, 'Asyncronous string data', 'mod_async_string.png'),
(25,'web_analysis', 8, 'Web analysis data', 'module-wux.png'),
(30,'web_data',9,'Remote HTTP module to check latency','mod_web_data.png'),
(31,'web_proc',9,'Remote HTTP module to check server response','mod_web_proc.png'),
(32,'web_content_data',9,'Remote HTTP module to retrieve numeric data','mod_web_data.png'),
(33,'web_content_string',9,'Remote HTTP module to retrieve string data','mod_web_data.png'),
(34,'remote_cmd', 10, 'Remote execution, numeric data', 'mod_remote_cmd.png'),
(35,'remote_cmd_proc', 10, 'Remote execution, boolean data', 'mod_remote_cmd_proc.png'),
(36,'remote_cmd_string', 10, 'Remote execution, alphanumeric data', 'mod_remote_cmd_string.png'),
(37,'remote_cmd_inc', 10, 'Remote execution, incremental data', 'mod_remote_cmd_inc.png'),
(100,'keep_alive',-1,'KeepAlive','mod_keepalive.png');
--

View File

@ -348,6 +348,15 @@ self_monitoring 1
# Self monitoring interval (in seconds).
self_monitoring_interval 300
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
# will make sample data. Disabled by default.
sample_agent 0
# Pandora Sample Agent interval (in seconds).
sample_agent_interval 600
# Update parent from the agent xml
#update_parent 1

View File

@ -340,6 +340,15 @@ restart_delay 60
self_monitoring 1
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
# will make sample data. Disabled by default.
sample_agent 0
# Pandora Sample Agent interval (in seconds).
sample_agent_interval 600
# Update parent from the agent xml
#update_parent 1

View File

@ -382,6 +382,16 @@ sub pandora_server_tasks ($) {
pandora_self_monitoring ($pa_config, $dbh);
}
# Pandora sample agent
if (defined($pa_config->{'sample_agent'})) {
if ($pa_config->{'sample_agent'} == 1
&& !is_metaconsole($pa_config)
&& $counter % $pa_config->{'sample_agent_interval'} == 0){
pandora_sample_agent ($pa_config);
}
pandora_update_config_token ($dbh, 'sample_agent', $pa_config->{'sample_agent'});
}
# Avoid counter overflow
if ($counter >= ~0){
$counter = 0;

View File

@ -376,6 +376,15 @@ self_monitoring 1
# Self monitoring interval (in seconds).
self_monitoring_interval 300
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
# will make sample data. Disabled by default.
sample_agent 0
# Pandora Sample Agent interval (in seconds).
sample_agent_interval 600
# Update parent from the agent xml
#update_parent 1

View File

@ -330,6 +330,15 @@ restart_delay 60
# Self monitoring interval (in seconds).
#self_monitoring_interval 300
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
# will make sample data. Disabled by default.
sample_agent 0
# Pandora Sample Agent interval (in seconds).
sample_agent_interval 600
# Update parent from the agent xml
#update_parent 1

View File

@ -79,7 +79,7 @@ sub help_screen {
sub pandora_init {
my $pa_config = $_[0];
my $init_string = $_[1];
print "\n$init_string $pandora_version Build $pandora_build Copyright (c) 2004-2018 " . pandora_get_initial_copyright_notice() . "\n";
print "\n$init_string $pandora_version Build $pandora_build Copyright (c) 2004-20".substr($pandora_build,0,2)." " . pandora_get_initial_copyright_notice() . "\n";
print "This program is OpenSource, licensed under the terms of GPL License version 2.\n";
print "You can download latest versions and documentation at official web page.\n\n";
@ -398,6 +398,12 @@ sub pandora_load_config {
# Self monitoring interval
$pa_config->{'self_monitoring_interval'} = 300; # 5.1SP1
# Sample Agent
$pa_config->{'sample_agent'} = 0;
# Sample agent interval
$pa_config->{'sample_agent_interval'} = 600;
# Process XML data files as a stack
$pa_config->{"dataserver_lifo"} = 0; # 5.0
@ -950,6 +956,12 @@ sub pandora_load_config {
elsif ($parametro =~ m/^self_monitoring_interval\s+([0-9]*)/i) {
$pa_config->{'self_monitoring_interval'} = clean_blank($1);
}
elsif ($parametro =~ m/^sample_agent\s+([0-1])/i) {
$pa_config->{'sample_agent'} = clean_blank($1);
}
elsif ($parametro =~ m/^sample_agent_interval\s+([0-9]*)/i) {
$pa_config->{'sample_agent_interval'} = clean_blank($1);
}
elsif ($parametro =~ m/^update_parent\s+([0-1])/i) {
$pa_config->{'update_parent'} = clean_blank($1);
}

View File

@ -100,6 +100,8 @@ Exported Functions:
=item * C<pandora_self_monitoring>
=item * C<pandora_sample_agent>
=back
=head1 METHODS
@ -122,6 +124,7 @@ use threads::shared;
use JSON qw(decode_json encode_json);
use MIME::Base64;
use Text::ParseWords;
use Math::Trig; # Math functions
# Debugging
#use Data::Dumper;
@ -248,6 +251,7 @@ our @EXPORT = qw(
pandora_group_statistics
pandora_server_statistics
pandora_self_monitoring
pandora_sample_agent
pandora_process_policy_queue
subst_alert_macros
subst_column_macros
@ -5236,6 +5240,83 @@ sub pandora_self_monitoring ($$) {
print XMLFILE $xml_output;
close (XMLFILE);
}
##########################################################################
=head2 C<< xml_module_template (I<$module_name>, I<$module_type>, I<$module_data>) >>
Module template for sample agent
=cut
##########################################################################
sub xml_module_template ($$$) {
my ($module_name, $module_type, $module_data) = @_;
my $output = "<module>\n";
$module_name = "<![CDATA[".$module_name."]]>" if $module_name =~ /[\s+.]+/;
$module_data = "<![CDATA[".$module_data."]]>" if $module_data =~ /[\s+.]+/;
$output .= "\t<name>".$module_name."</name>\n";
$output .= "\t<type>".$module_type."</type>\n";
$output .= "\t<data>".$module_data."</data>\n";
$output .= "</module>\n";
return $output;
}
##########################################################################
=head2 C<< pandora_sample_agent (I<$pa_config>) >>
Pandora agent for make sample data
=cut
##########################################################################
sub pandora_sample_agent ($) {
my ($pa_config) = @_;
my $utimestamp = time ();
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
# First line
my $xml_output = "<?xml version='1.0' encoding='UTF-8'?>\n";
# Header
$xml_output = "<agent_data agent_name='Sample_Agent' agent_alias='Sample_Agent' description='Agent for sample generation purposes' group='Servers' os_name='$OS' os_version='$OS_VERSION' interval='".$pa_config->{'sample_agent_interval'}."' version='" . $pa_config->{'version'} . "' timestamp='".$timestamp."'>\n";
# Boolean ever return TRUE
$xml_output .= xml_module_template ("Boolean ever true", "generic_proc","1");
# Boolean return TRUE at 80% of times
my $sample_boolean_mostly_true = 1;
$sample_boolean_mostly_true = 0 if rand(9) > 7;
$xml_output .= xml_module_template ("Boolean mostly true", "generic_proc",$sample_boolean_mostly_true);
# Boolean return false at 80% of times
my $sample_boolean_mostly_false = 0;
$sample_boolean_mostly_false = 1 if rand(9) > 7;
$xml_output .= xml_module_template ("Boolean mostly false", "generic_proc", $sample_boolean_mostly_false);
# Boolean ever return FALSE
$xml_output .= xml_module_template ("Boolean ever false", "generic_proc","0");
# Random integer between 0 and 100
$xml_output .= xml_module_template ("Random integer values", "generic_data",int(rand(100)));
# Random values obtained with sinusoidal curves between 0 and 100 values
my $b = 1;
my $sample_serie_curve = 1 + cos(deg2rad($b));
$b = $b + rand(20)/10;
$b = 0 if ($b > 180);
$sample_serie_curve = $sample_serie_curve * $b * 10;
$sample_serie_curve =~ s/\,/\./g;
$xml_output .= xml_module_template ("Random serie curve", "generic_data", $sample_serie_curve);
# String with 10 random characters
my $sample_random_text = "";
my @characters = ('a'..'z','A'..'Z');
for (1...10){
$sample_random_text .= $characters[int(rand(@characters))];
}
$xml_output .= xml_module_template ("Random text", "generic_data_string", $sample_random_text);
# End of xml
$xml_output .= "</agent_data>";
# File path definition
my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{'servername'}.".sample.".$utimestamp.".data";
# Opening, Writing and closing of XML
open (my $xmlfile, ">", $filename) or die "[FATAL] Could not open sample XML file for deploying monitorization at '$filename'";
print $xmlfile $xml_output;
close ($xmlfile);
}
##########################################################################
=head2 C<< set_master (I<$pa_config>, I<$dbh>) >>

View File

@ -5895,9 +5895,16 @@ sub cli_stop_downtime () {
exist_check($downtime_id,'planned downtime',$downtime_id);
my $current_time = time;
my $downtime_date_to = get_db_value ($dbh, 'SELECT date_to FROM tplanned_downtime WHERE id=?', $downtime_id);
if($current_time >= $downtime_date_to) {
my $data = get_db_single_row ($dbh, 'SELECT date_to, type_execution, executed FROM tplanned_downtime WHERE id=?', $downtime_id);
if( $data->{'type_execution'} eq 'periodically' && $data->{'executed'} == 1){
print_log "[ERROR] Planned_downtime '$downtime_name' cannot be stopped.\n";
print_log "[INFO] Periodical and running planned downtime cannot be stopped.\n\n";
exit;
}
if($current_time >= $data->{'date_to'}) {
print_log "[INFO] Planned_downtime '$downtime_name' is already stopped\n\n";
exit;
}