some gotty changes

This commit is contained in:
alejandro.campos@artica.es 2023-09-27 18:28:12 +02:00
parent 00c48c1c7d
commit 3f2caf9404
9 changed files with 77 additions and 154 deletions

View File

@ -5,7 +5,9 @@ require_once 'include/auth/mysql.php';
require_once 'include/functions.php';
require_once 'include/functions_db.php';
if (enterprise_installed() === true) {
global $config;
if ((bool) $config['enterprise_installed'] === true) {
return;
}
@ -13,8 +15,6 @@ if (enterprise_installed() === true) {
require_once 'include/class/DiscoveryConsoleTask.php';
require_once 'include/class/ConsoleSupervisor.php';
global $config;
db_process_sql_update(
'tconfig',
['value' => get_system_time()],
@ -28,4 +28,4 @@ $tasks->run();
if (is_reporting_console_node() === true) {
$supervisor = new ConsoleSupervisor();
$supervisor->run();
}
}

View File

@ -485,8 +485,8 @@ if ($access_console_node === true) {
$sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications');
$sub2['godmode/setup/setup&section=notifications']['refr'] = 0;
$sub2['godmode/setup/setup&section=websocket_engine']['text'] = __('QuickShell');
$sub2['godmode/setup/setup&section=websocket_engine']['refr'] = 0;
$sub2['godmode/setup/setup&section=quickshell']['text'] = __('QuickShell');
$sub2['godmode/setup/setup&section=quickshell']['refr'] = 0;
$sub2['godmode/setup/setup&section=external_tools']['text'] = __('External Tools');
$sub2['godmode/setup/setup&section=external_tools']['refr'] = 0;

View File

@ -221,9 +221,9 @@ $buttons['notifications'] = [
).'</a>',
];
$buttons['websocket_engine'] = [
$buttons['quickshell'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=websocket_engine').'">'.html_print_image(
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=quickshell').'">'.html_print_image(
'images/websocket_small.png',
true,
[
@ -325,8 +325,8 @@ switch ($section) {
$subpage = __('Notifications');
break;
case 'websocket_engine':
$buttons['websocket_engine']['active'] = true;
case 'quickshell':
$buttons['quickshell']['active'] = true;
$subpage = __('QuickShell');
$help_header = 'quickshell_settings';
break;
@ -454,8 +454,8 @@ switch ($section) {
include_once $config['homedir'].'/godmode/setup/setup_notifications.php';
break;
case 'websocket_engine':
include_once $config['homedir'].'/godmode/setup/setup_websocket_engine.php';
case 'quickshell':
include_once $config['homedir'].'/godmode/setup/setup_quickshell.php';
break;
case 'external_tools':

View File

@ -0,0 +1,53 @@
<?php
/**
* Settings for Pandora Websocket engine.
*
* @category UI file
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 Pandora FMS
* Please see https://pandorafms.com/community/ 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.
* ============================================================================
*/
global $config;
$url = ui_get_full_url(
'index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=quickshell&amp;pure='.$config['pure']
);
echo '<form class="max_floating_element_size" id="form_setup" method="post" action="'.$url.'">';
if (function_exists('quickShellSettings') === true) {
quickShellSettings();
}
$action_btns = html_print_submit_button(
__('Update'),
'update_button',
false,
[ 'icon' => 'update' ],
true
);
html_print_action_buttons(
$action_btns
);
echo '</form>';

View File

@ -1,121 +0,0 @@
<?php
/**
* Settings for Pandora Websocket engine.
*
* @category UI file
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 Pandora FMS
* Please see https://pandorafms.com/community/ 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.
* ============================================================================
*/
global $config;
$url = ui_get_full_url(
'index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=websocket_engine&amp;pure='.$config['pure']
);
echo '<form class="max_floating_element_size" id="form_setup" method="post" action="'.$url.'">';
if (function_exists('quickShellSettings') === true) {
quickShellSettings();
}
$action_btns = html_print_submit_button(
__('Update'),
'update_button',
false,
[ 'icon' => 'update' ],
true
);
html_print_action_buttons(
$action_btns
);
echo '</form>';
echo '<script>';
echo 'var server_addr = "'.$_SERVER['SERVER_ADDR'].'";';
$handle_test_js = "var handleTest = function (event) {
var ws_proxy_url = $('input#text-ws_proxy_url').val();
var ws_port = $('input#text-ws_port').val();
var httpsEnabled = window.location.protocol == 'https' ? true : false;
if (ws_proxy_url == '') {
ws_url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + ':' + ws_port;
} else {
ws_url = ws_proxy_url;
}
var showLoadingImage = function () {
$('#button-test-gotty').children('div').attr('class', 'subIcon cog rotation secondary mini');
}
var showSuccessImage = function () {
$('#button-test-gotty').children('div').attr('class', 'subIcon tick secondary mini');
}
var showFailureImage = function () {
$('#button-test-gotty').children('div').attr('class', 'subIcon fail secondary mini');
}
var hideMessage = function () {
$('span#test-gotty-message').hide();
}
var showMessage = function () {
$('span#test-gotty-message').show();
}
var changeTestMessage = function (message) {
$('span#test-gotty-message').text(message);
}
var errorMessage = '".__('WebService engine has not been started, please check documentation.')."';
hideMessage();
showLoadingImage();
var ws = new WebSocket(ws_url);
// Catch errors.
ws.onerror = () => {
showFailureImage();
changeTestMessage(errorMessage);
showMessage();
ws.close();
};
ws.onopen = () => {
showSuccessImage();
hideMessage();
ws.close();
};
ws.onclose = (event) => {
changeTestMessage(errorMessage);
hideLoadingImage();
showMessage();
};
}";
echo $handle_test_js;
echo '</script>';

View File

@ -499,9 +499,7 @@ class ConsoleSupervisor
* NOTIF.CRON.CONFIGURED
*/
if (enterprise_installed()) {
$this->checkCronRunning();
}
$this->checkCronRunning();
/*
* Check if instance is registered.

View File

@ -26,7 +26,7 @@
* ============================================================================
*/
if (enterprise_installed() === true) {
if ((bool) $config['enterprise_installed'] === true) {
enterprise_include_once('/include/functions_cron.php');
} else {
include_once $config['homedir'].'/include/functions_cron_task.php';
@ -163,6 +163,13 @@ class DiscoveryConsoleTask
// Maintenance task: schedule task 'cron_task_start_gotty' if not defined yet.
// Must do at every Cron execution.
if ((bool) $config['enterprise_installed'] === false) {
$call_func_user_task_id = db_get_value_sql('SELECT id FROM `tuser_task` WHERE `function_name` = "cron_task_call_user_function"');
if ($call_func_user_task_id === false) {
db_process_sql("INSERT INTO `tuser_task` (`function_name`, `parameters`, `name`) VALUES ('cron_task_call_user_function','a:1:{i:0;a:2:{s:11:\"description\";s:13:\"Function name\";s:4:\"type\";s:4:\"text\";}}','Call PHP function')");
}
}
$user_function_task_id = db_get_value_sql('SELECT id FROM `tuser_task_scheduled` WHERE `args` LIKE "%cron_task_start_gotty%"');
if ($user_function_task_id === false) {

View File

@ -2030,20 +2030,6 @@ function config_update_config()
}
break;
case 'websocket_engine':
if (config_update_value('ws_bind_address', get_parameter('ws_bind_address'), true) === false) {
$error_update[] = __('WebSocket bind address');
}
if (config_update_value('ws_port', get_parameter('ws_port'), true) === false) {
$error_update[] = __('WebSocket port');
}
if (config_update_value('ws_proxy_url', get_parameter('ws_proxy_url'), true) === false) {
$error_update[] = __('WebSocket proxy url');
}
break;
default:
// Ignore.
break;

View File

@ -227,7 +227,7 @@ function cron_task_run(
$args = unserialize($task_scheduled['args']);
if (enterprise_installed() === false
if ((bool) $config['enterprise_installed'] === false
&& isset($args['function_name']) === true
&& $args['function_name'] !== 'cron_task_start_gotty'
) {
@ -235,7 +235,7 @@ function cron_task_run(
return;
}
if (enterprise_installed() === true) {
if ((bool) $config['enterprise_installed'] === true) {
$task = db_get_row('tuser_task', 'id', $task_scheduled['id_user_task']);
} else {
$task = [
@ -282,7 +282,6 @@ function cron_task_run(
set_time_limit(0);
if ($task['function_name'] == 'cron_task_generate_report_by_template'
|| $task['function_name'] == 'cron_task_generate_report'
) {
@ -432,6 +431,7 @@ function cron_task_run(
function cron_task_call_user_function(string $function_name)
{
global $config;
include_once $config['homedir'].'/vendor/autoload.php';
call_user_func($function_name);