ent 7914 status scaling based on time

This commit is contained in:
edu.corral 2022-11-04 12:13:38 +01:00
commit 341fe37def
39 changed files with 915 additions and 43 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.765-221102 Version: 7.0NG.765-221104
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.765-221102" pandora_version="7.0NG.765-221104"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.765'; use constant AGENT_VERSION => '7.0NG.765';
use constant AGENT_BUILD => '221102'; use constant AGENT_BUILD => '221104';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221102 %define release 221104
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221102 %define release 221104
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.765" PI_VERSION="7.0NG.765"
PI_BUILD="221102" PI_BUILD="221104"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{221102} {221104}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.765 Build 221102") #define PANDORA_VERSION ("7.0NG.765 Build 221104")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.765(Build 221102))" VALUE "ProductVersion", "(7.0NG.765(Build 221104))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.765-221102 Version: 7.0NG.765-221104
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.765-221102" pandora_version="7.0NG.765-221104"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -59,7 +59,7 @@ if ($id_group) {
} }
} }
$table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->class = 'databox filters'; $table->class = 'databox filters';
$table->style[0] = 'font-weight: bold'; $table->style[0] = 'font-weight: bold';

View File

@ -137,7 +137,13 @@ if (isset($_GET['server'])) {
if ($server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) { if ($server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) {
$buttons['agent_editor'] = [ $buttons['agent_editor'] = [
'active' => false, 'active' => false,
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=agent_editor&pure='.$pure.'">'.html_print_image('images/agent.png', true, ['title' => __('Advanced editor')]).'</a>', 'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=agent_editor&pure='.$pure.'">'.html_print_image('images/agent.png', true, ['title' => __('Manage agents')]).'</a>',
];
$buttons['collections'] = [
'active' => false,
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=collections&pure='.$pure.'">'.html_print_image('images/collection.png', true, ['title' => __('Collections')]).'</a>',
]; ];
} }
@ -160,6 +166,8 @@ if (isset($_GET['server'])) {
} }
} else if ($tab === 'agent_editor' && $server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) { } else if ($tab === 'agent_editor' && $server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) {
$advanced_editor = 'agent_editor'; $advanced_editor = 'agent_editor';
} else if ($tab === 'collections' && $server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) {
$advanced_editor = 'collections';
} }
enterprise_include('godmode/servers/server_disk_conf_editor.php'); enterprise_include('godmode/servers/server_disk_conf_editor.php');

View File

@ -549,6 +549,43 @@ if ($create_user) {
$password_new = ''; $password_new = '';
$password_confirm = ''; $password_confirm = '';
$new_user = true; $new_user = true;
} else {
$pm = db_get_value_filter('pandora_management', 'tperfil', ['id_perfil' => $profile2]);
if ((int) $pm === 1) {
$user_source = db_get_value_filter(
'id_source',
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
if ($user_source === false) {
$notificationSources = db_get_all_rows_filter('tnotification_source', [], 'id');
foreach ($notificationSources as $notification) {
if ((int) $notification['id'] === 1 || (int) $notification['id'] === 5) {
$notification_user = db_get_value_filter(
'id_source',
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
if ($notification_user === false) {
@db_process_sql_insert(
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
}
}
}
}
}
} }
ui_print_result_message( ui_print_result_message(
@ -845,6 +882,43 @@ if ($add_profile && empty($json_profile)) {
$return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy); $return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy);
if ($return === false) { if ($return === false) {
$is_err = true; $is_err = true;
} else {
$pm = db_get_value_filter('pandora_management', 'tperfil', ['id_perfil' => $profile2]);
if ((int) $pm === 1) {
$user_source = db_get_value_filter(
'id_source',
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
if ($user_source === false) {
$notificationSources = db_get_all_rows_filter('tnotification_source', [], 'id');
foreach ($notificationSources as $notification) {
if ((int) $notification['id'] === 1 || (int) $notification['id'] === 5) {
$notification_user = db_get_value_filter(
'id_source',
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
if ($notification_user === false) {
@db_process_sql_insert(
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
}
}
}
}
}
} }
ui_print_result_message( ui_print_result_message(

View File

@ -809,7 +809,44 @@ function update_user(string $id_user, array $values)
return false; return false;
} }
return db_process_sql_update('tusuario', $values, ['id_user' => $id_user]); $output = db_process_sql_update('tusuario', $values, ['id_user' => $id_user]);
if (isset($values['is_admin']) === true && (bool) $values['is_admin'] === true) {
// Administrator user must be activated in all notifications sections.
$notificationSources = db_get_all_rows_filter('tnotification_source', [], 'id');
foreach ($notificationSources as $notification) {
$user_source = db_get_value_filter(
'id_source',
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id_user,
]
);
if ($user_source !== false) {
@db_process_sql_update(
'tnotification_source_user',
['enabled' => 1],
[
'id_source' => $notification['id'],
'id_user' => $id_user,
]
);
} else if ((int) $notification['id'] === 1 || (int) $notification['id'] === 5) {
@db_process_sql_insert(
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id_user,
]
);
}
}
}
return $output;
} }

View File

@ -679,7 +679,6 @@ class ConsoleSupervisor
$max_age = 0; $max_age = 0;
break; break;
case 'NOTIF.LICENSE.EXPIRATION':
case 'NOTIF.FILES.ATTACHMENT': case 'NOTIF.FILES.ATTACHMENT':
case 'NOTIF.FILES.DATAIN': case 'NOTIF.FILES.DATAIN':
case 'NOTIF.FILES.DATAIN.BADXML': case 'NOTIF.FILES.DATAIN.BADXML':
@ -846,7 +845,9 @@ class ConsoleSupervisor
} }
// Expiry. // Expiry.
if (($days_to_expiry <= 15) && ($days_to_expiry > 0)) { if (($days_to_expiry <= 15) && ($days_to_expiry > 0)
&& ((is_user_admin($config['id_user'])) || (check_acl($config['id_user'], 0, 'PM')))
) {
if ($config['license_mode'] == 1) { if ($config['license_mode'] == 1) {
$title = __('License is about to expire'); $title = __('License is about to expire');
$msg = 'Your license will expire in %d days. Please, contact our sales department.'; $msg = 'Your license will expire in %d days. Please, contact our sales department.';
@ -867,7 +868,7 @@ class ConsoleSupervisor
'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license',
] ]
); );
} else if ($days_to_expiry < 0) { } else if (($days_to_expiry <= 0) && ((is_user_admin($config['id_user'])) || (check_acl($config['id_user'], 0, 'PM')))) {
if ($config['license_mode'] == 1) { if ($config['license_mode'] == 1) {
$title = __('Expired license'); $title = __('Expired license');
$msg = __('Your license has expired. Please, contact our sales department.'); $msg = __('Your license has expired. Please, contact our sales department.');

View File

@ -0,0 +1,689 @@
<?php
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
/**
* Controller for collections
*
* @category Controller
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 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;
// Necessary classes for extends.
require_once $config['homedir'].'/include/class/HTML.class.php';
require_once $config['homedir'].'/include/functions_servers.php';
enterprise_include_once('include/functions_satellite.php');
enterprise_include_once('include/functions_collection.php');
/**
* Class SatelliteCollection
*/
class SatelliteCollection extends HTML
{
/**
* Allowed methods to be called using AJAX request.
*
* @var array
*/
public $AJAXMethods = [
'draw',
'addCollection',
'deleteCollection',
'loadModal',
];
/**
* Ajax page.
*
* @var string
*/
private $ajaxController;
/**
* Class constructor
*
* @param string $ajaxController Ajax controller.
*/
public function __construct(string $ajaxController)
{
global $config;
check_login();
if (check_acl($config['id_user'], 0, 'PM') === false
&& is_user_admin($config['id_user']) === true
) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Satellite agents'
);
include 'general/noaccess.php';
return;
}
// Set the ajax controller.
$this->ajaxController = $ajaxController;
// Capture all parameters before start.
$this->satellite_server = (int) get_parameter('server_remote');
if ($this->satellite_server !== 0) {
$this->satellite_name = servers_get_name($this->satellite_server);
$this->satellite_config = (array) config_satellite_get_config_file($this->satellite_name);
}
}
/**
* Run view
*
* @return void
*/
public function run()
{
// Javascript.
ui_require_jquery_file('pandora');
// CSS.
ui_require_css_file('wizard');
ui_require_css_file('discovery');
$this->createBlock();
if (is_metaconsole() === true) {
// Only in case of Metaconsole, format the frame.
open_meta_frame();
}
// Datatables list.
try {
$columns = [
'name',
'dir',
'description',
'actions',
];
$column_names = [
__('Name'),
__('Dir'),
__('Description'),
__('Actions'),
];
$this->tableId = 'satellite_collections';
// Load datatables user interface.
ui_print_datatable(
[
'id' => $this->tableId,
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,
'ajax_data' => [
'method' => 'draw',
'server_remote' => $this->satellite_server,
],
'ajax_postprocces' => 'process_datatables_item(item)',
'no_sortable_columns' => [
0,
1,
2,
3,
],
'search_button_class' => 'sub filter float-right',
'form' => [
'inputs' => [
[
'label' => __('Search'),
'type' => 'text',
'name' => 'filter_search',
'size' => 12,
],
],
],
]
);
} catch (Exception $e) {
echo $e->getMessage();
}
if (is_metaconsole() === true) {
// Close the frame.
close_meta_frame();
}
echo '<div id="aux" class="invisible"></div>';
echo '<div id="msg" class="invisible"></div>';
// Load own javascript file.
echo $this->loadJS();
}
/**
* Get the data for draw the table.
*
* @return void.
*/
public function draw()
{
global $config;
// Init data.
$data = [];
// Count of total records.
$count = 0;
// Catch post parameters.
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
$order = get_datatable_order(true);
$filters = get_parameter('filter', []);
try {
ob_start();
// Gets all collections (database).
$collections = collection_get_collections(null, $filters['filter_search']);
if (empty($collections) === false) {
$data = $collections;
}
// All satellite conf collections.
foreach ($this->satellite_config as $line) {
$regex = '/^file_collection\s(\S+)/m';
if (preg_match($regex, $line, $matches, PREG_OFFSET_CAPTURE, 0) > 0) {
$key = array_search($matches[1][0], array_column($data, 'short_name'));
if ($key !== false) {
$data[$key]['delete'] = true;
}
}
}
if (empty($data) === false) {
$data = array_reduce(
$data,
function ($carry, $item) {
// Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields.
$tmp = (object) $item;
$delete = (int) isset($tmp->delete);
$tmp->dir = $tmp->short_name;
$tmp->actions = '';
$tmp->actions .= html_print_image(
($delete === 0) ? 'images/add.png' : 'images/cross.png',
true,
[
'border' => '0',
'class' => 'action_button_img mrgn_lft_05em invert_filter',
'onclick' => ($delete === 0)
? 'add_collection(\''.$tmp->short_name.'\')'
: 'delete_collection(\''.$tmp->short_name.'\')',
]
);
$carry[] = $tmp;
return $carry;
}
);
}
if (empty($data) === true) {
$total = 0;
$data = [];
} else {
$total = count($data);
$data = array_slice($data, $start, $length, false);
}
echo json_encode(
[
'data' => $data,
'recordsTotal' => $total,
'recordsFiltered' => $total,
]
);
// Capture output.
$response = ob_get_clean();
} catch (Exception $e) {
echo json_encode(['error' => $e->getMessage()]);
exit;
}
// If not valid, show error with issue.
json_decode($response);
if (json_last_error() === JSON_ERROR_NONE) {
// If valid dump.
echo $response;
} else {
echo json_encode(
['error' => $response]
);
}
exit;
}
/**
* Add collection to satellite conf.
*
* @return void
*/
public function addCollection()
{
$short_name = get_parameter('short_name');
if ($this->parseSatelliteConf('add', $short_name) === false) {
$this->ajaxMsg('error', __('Error adding collection'));
} else {
$this->ajaxMsg('result', _('Collection '.$short_name.' added.'));
}
exit;
}
/**
* Delete collection to satellite conf.
*
* @return void
*/
public function deleteCollection()
{
$short_name = get_parameter('short_name');
if ($this->parseSatelliteConf('delete', $short_name) === false) {
$this->ajaxMsg('error', __('Error deleting collection'));
} else {
$this->ajaxMsg('result', _('Collection '.$short_name.' deleted.'));
}
exit;
}
/**
* Parse satellite configuration .
*
* @param string $action Action to perform (add, delete).
* @param string $short_name Short name.
*
* @return boolean
*/
private function parseSatelliteConf(string $action, string $short_name)
{
switch ($action) {
case 'delete':
$pos = preg_grep('/^file_collection '.$short_name.'/', $this->satellite_config);
if (empty($pos) === false) {
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
unset($this->satellite_config[$key_pos]);
}
$conf = implode('', $this->satellite_config);
break;
default:
case 'add':
$pos = preg_grep('/^file_collection/', $this->satellite_config);
if (empty($pos) === false) {
$string_collection = 'file_collection '.$short_name."\n";
$key_pos = array_keys($pos)[(count($pos) - 1)];
$array1 = array_slice($this->satellite_config, 0, ($key_pos + 1));
$array2 = array_slice($this->satellite_config, ($key_pos + 1));
$array_merge = array_merge($array1, [$string_collection], $array2);
$this->satellite_config = $array_merge;
// Check config.
if (empty($this->satellite_config) === true) {
return false;
}
} else {
$pos = preg_grep('/^\#\sFile\scollections/', $this->satellite_config);
$string_collection = 'file_collection '.$short_name."\n";
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
$key_pos++;
$array1 = array_slice($this->satellite_config, 0, $key_pos);
$array2 = array_slice($this->satellite_config, $key_pos);
// Add collection to conf.
$array_merge = array_merge($array1, [$string_collection], $array2);
$this->satellite_config = $array_merge;
// Check config.
if (empty($this->satellite_config) === true) {
return false;
}
}
$conf = implode('', $this->satellite_config);
break;
}
return $this->saveAgent($conf);
}
/**
* Saves agent to satellite cofiguration file.
*
* @param string $new_conf Config file.
*
* @return boolean|void
*/
private function saveAgent(string $new_conf)
{
global $config;
if (empty($new_conf) === true) {
return false;
}
db_pandora_audit(
AUDIT_LOG_SYSTEM,
'Update remote config for server '.$this->satellite_name
);
// Convert to config file encoding.
$encoding = config_satellite_get_encoding($new_conf);
if ($encoding !== false) {
$converted_server_config = mb_convert_encoding($new_conf, $encoding, 'UTF-8');
if ($converted_server_config !== false) {
$new_conf = $converted_server_config;
}
}
// Get filenames.
if ($this->satellite_server !== false) {
$files = config_satellite_get_satellite_config_filenames($this->satellite_name);
} else {
$files = [];
$files['conf'] = $config['remote_config'].'/conf/'.md5($this->satellite_name).'.srv.conf';
$files['md5'] = $config['remote_config'].'/md5/'.md5($this->satellite_name).'.srv.md5';
}
// Save configuration.
$result = file_put_contents($files['conf'], $new_conf);
if ($result === false) {
return false;
}
// Save configuration md5.
$result = file_put_contents($files['md5'], md5($new_conf));
}
/**
* 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(string $method)
{
return in_array($method, $this->AJAXMethods);
}
/**
* Minor function to dump json message as ajax response.
*
* @param string $type Type: result || error.
* @param string $msg Message.
*
* @return void
*/
private function ajaxMsg(string $type, string $msg)
{
if ($type === 'error') {
echo json_encode(
[
$type => ui_print_error_message(
__($msg),
'',
true
),
]
);
} else {
echo json_encode(
[
$type => ui_print_success_message(
__($msg),
'',
true
),
]
);
}
exit;
}
/**
* Create file_collections blocks
*
* @return void
*/
public function createBlock()
{
$init = preg_grep('/^\#\sFile\scollections/', $this->satellite_config);
if (empty($init) === true) {
$collection = "# File collections\n";
array_push($this->satellite_config, "\n");
array_push($this->satellite_config, $collection);
array_push($this->satellite_config, "\n");
$conf = implode('', $this->satellite_config);
$this->saveAgent($conf);
}
}
/**
* Load Javascript code.
*
* @return string.
*/
public function loadJS()
{
// Nothing for this moment.
ob_start();
// Javascript content.
?>
<script type="text/javascript">
/**
* Add collection.
*/
function add_collection(short_name) {
$('#aux').empty();
$('#aux').text('<?php echo __('Are you sure?'); ?>');
$('#aux').dialog({
title: '<?php echo __('Add collection'); ?>',
buttons: [{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: '<?php echo __('Cancel'); ?>',
click: function(e) {
$(this).dialog('close');
}
},
{
text: 'Add',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/collections_satellite',
method: 'addCollection',
short_name: short_name,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function(data) {
console.log(data);
showMsg(data);
},
error: function(e) {
showMsg(e);
}
});
}
}
]
});
}
/**
* Delete collection.
*/
function delete_collection(short_name) {
$('#aux').empty();
$('#aux').text('<?php echo __('Are you sure?'); ?>');
$('#aux').dialog({
title: '<?php echo __('Delete collection'); ?>',
buttons: [{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: '<?php echo __('Cancel'); ?>',
click: function(e) {
$(this).dialog('close');
}
},
{
text: 'Delete',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/collections_satellite',
method: 'deleteCollection',
short_name: short_name,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function(data) {
console.log(data);
showMsg(data);
},
error: function(e) {
showMsg(e);
}
});
}
}
]
});
}
/**
* Process ajax responses and shows a dialog with results.
*/
function showMsg(data) {
var title = "<?php echo __('Success'); ?>";
var dt_satellite_agents = $("#satellite_collections").DataTable();
dt_<?php echo $this->tableId; ?>.draw(false);
var text = '';
var failed = 0;
try {
data = JSON.parse(data);
text = data['result'];
} catch (err) {
title = "<?php echo __('Failed'); ?>";
text = err.message;
failed = 1;
}
if (!failed && data['error'] != undefined) {
title = "<?php echo __('Failed'); ?>";
text = data['error'];
failed = 1;
}
if (data['report'] != undefined) {
data['report'].forEach(function (item){
text += '<br>'+item;
});
}
$('#msg').empty();
$('#msg').html(text);
$('#msg').dialog({
width: 450,
position: {
my: 'center',
at: 'center',
of: window,
collision: 'fit'
},
title: title,
buttons: [
{
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
text: 'OK',
click: function(e) {
if (!failed) {
$(".ui-dialog-content").dialog("close");
$('.info').hide();
} else {
$(this).dialog('close');
}
}
}
]
});
}
</script>
<?php
// EOF Javascript content.
return ob_get_clean();
}
}

View File

@ -20,7 +20,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC221102'; $build_version = 'PC221104';
$pandora_version = 'v7.0NG.765'; $pandora_version = 'v7.0NG.765';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -125,7 +125,6 @@ function notifications_get_subtypes(?string $source=null)
$subtypes = [ $subtypes = [
'System status' => [ 'System status' => [
'NOTIF.LICENSE.LIMITED', 'NOTIF.LICENSE.LIMITED',
'NOTIF.LICENSE.EXPIRATION',
'NOTIF.FILES.ATTACHMENT', 'NOTIF.FILES.ATTACHMENT',
'NOTIF.FILES.DATAIN', 'NOTIF.FILES.DATAIN',
'NOTIF.FILES.DATAIN.BADXML', 'NOTIF.FILES.DATAIN.BADXML',

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.765'; $version = '7.0NG.765';
$build = '221102'; $build = '221104';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -122,7 +122,7 @@ if ($flag_alert == 1 && check_acl($config['id_user'], $id_group, 'AW')) {
$idAgent = get_parameter_get('id_agente', 0); $idAgent = get_parameter_get('id_agente', 0);
// Show alerts for specific agent // Show alerts for specific agent.
if ($idAgent != 0) { if ($idAgent != 0) {
$url = $url.'&id_agente='.$idAgent; $url = $url.'&id_agente='.$idAgent;
@ -179,7 +179,7 @@ if ($idAgent != 0) {
); );
$idGroup = $id_group; $idGroup = $id_group;
// If there is no agent defined, it means that it cannot search for the secondary groups // If there is no agent defined, it means that it cannot search for the secondary groups.
$all_groups = [$id_group]; $all_groups = [$id_group];
$print_agent = true; $print_agent = true;
@ -335,7 +335,9 @@ if ($free_search != '') {
} }
$alert_action = empty(alerts_get_alert_actions_filter()) === false ? alerts_get_alert_actions_filter() : ['' => __('No actions')]; $alert_action = empty(alerts_get_alert_actions_filter()) === false
? alerts_get_alert_actions_filter()
: ['' => __('No actions')];
ob_start(); ob_start();
@ -352,7 +354,7 @@ if ($free_search != '') {
'ajax_url' => 'include/ajax/alert_list.ajax', 'ajax_url' => 'include/ajax/alert_list.ajax',
'ajax_data' => [ 'ajax_data' => [
'get_agent_alerts_datatable' => 1, 'get_agent_alerts_datatable' => 1,
'id_agent' => $id_agent, 'id_agent' => $idAgent,
'url' => $url, 'url' => $url,
'agent_view_page' => true, 'agent_view_page' => true,
'all_groups' => $all_groups, 'all_groups' => $all_groups,
@ -395,7 +397,7 @@ if ($free_search != '') {
'ajax_url' => 'include/ajax/alert_list.ajax', 'ajax_url' => 'include/ajax/alert_list.ajax',
'ajax_data' => [ 'ajax_data' => [
'get_agent_alerts_datatable' => 1, 'get_agent_alerts_datatable' => 1,
'id_agent' => $id_agent, 'id_agent' => $idAgent,
'url' => $url, 'url' => $url,
], ],
'drawCallback' => 'alerts_table_controls()', 'drawCallback' => 'alerts_table_controls()',
@ -451,7 +453,7 @@ if ($free_search != '') {
echo $html_content; echo $html_content;
} }
// strict user hidden // Strict user hidden.
echo '<div id="strict_hidden" class="invisible">'; echo '<div id="strict_hidden" class="invisible">';
html_print_input_text('strict_user_hidden', $strict_user); html_print_input_text('strict_user_hidden', $strict_user);

View File

@ -97,7 +97,7 @@ if ($edit_networkmap) {
return; return;
} }
$name = io_safe_output($values['name']); $name = io_safe_output_html($values['name']);
// Id group of the map itself, not data source. // Id group of the map itself, not data source.
$id_group_map = $values['id_group_map']; $id_group_map = $values['id_group_map'];

View File

@ -302,7 +302,7 @@ if (empty($all_address_agents)) {
switch ($config['dbtype']) { switch ($config['dbtype']) {
case 'mysql': case 'mysql':
$sql = 'SELECT * $sql = 'SELECT *
FROM ttrap FROM ttrap
WHERE ( WHERE (
`source` IN ('.implode(',', $address_by_user_groups).") OR `source` IN ('.implode(',', $address_by_user_groups).") OR
`source`='' OR `source`='' OR
@ -671,8 +671,18 @@ $filter_resume['group_by'] = $group_by;
$filter_resume['hours_ago'] = $hours_ago; $filter_resume['hours_ago'] = $hours_ago;
$filter_resume['trap_type'] = $trap_types[$trap_type]; $filter_resume['trap_type'] = $trap_types[$trap_type];
$traps = db_get_all_rows_sql($sql); $traps = db_get_all_rows_sql($sql, true);
$trapcount = (int) db_get_value_sql($sql_count); $trapcount = (int) db_get_value_sql($sql_count, false, true);
// Re-sort traps by timestamp if history db is enabled.
if ($config['history_db_enabled'] == 1) {
usort(
$traps,
function ($a, $b) {
return strtotime($a['timestamp']) < strtotime($b['timestamp']);
}
);
}
// No traps. // No traps.
if (empty($traps)) { if (empty($traps)) {

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221102 %define release 221104
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221102 %define release 221104
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221102 %define release 221104
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.765-221102 Version: 7.0NG.765-221104
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.765-221102" pandora_version="7.0NG.765-221104"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -453,6 +453,9 @@ sub pandora_server_tasks ($) {
} }
} }
# Check if snmptrapd is freeze.
pandora_snmptrapd_still_working ($pa_config, $dbh);
# Event auto-expiry # Event auto-expiry
my $expiry_time = $pa_config->{"event_expiry_time"}; my $expiry_time = $pa_config->{"event_expiry_time"};
my $expiry_window = $pa_config->{"event_expiry_window"}; my $expiry_window = $pa_config->{"event_expiry_window"};

View File

@ -747,3 +747,6 @@ alertserver_queue 0
tentacle_service_watchdog 1 tentacle_service_watchdog 1
# Enable (1) or disable (0) the parameter of mysql ssl certification (mysql_ssl_verify_server_cert) (enabled by default).
verify_mysql_ssl_cert 1

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.765"; my $pandora_version = "7.0NG.765";
my $pandora_build = "221102"; my $pandora_build = "221104";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash
@ -229,6 +229,7 @@ sub pandora_load_config {
$pa_config->{"dbssl"} = 0; $pa_config->{"dbssl"} = 0;
$pa_config->{"dbsslcapath"} = ""; $pa_config->{"dbsslcapath"} = "";
$pa_config->{"dbsslcafile"} = ""; $pa_config->{"dbsslcafile"} = "";
$pa_config->{"verify_mysql_ssl_cert"} = "0";
$pa_config->{"basepath"} = $pa_config->{'pandora_path'}; # Compatibility with Pandora 1.1 $pa_config->{"basepath"} = $pa_config->{'pandora_path'}; # Compatibility with Pandora 1.1
$pa_config->{"incomingdir"} = "/var/spool/pandora/data_in"; $pa_config->{"incomingdir"} = "/var/spool/pandora/data_in";
$pa_config->{"user"} = "pandora"; # environment settings default user owner for files generated $pa_config->{"user"} = "pandora"; # environment settings default user owner for files generated
@ -724,6 +725,9 @@ sub pandora_load_config {
elsif ($parametro =~ m/^dbsslcafile\s(.*)/i) { elsif ($parametro =~ m/^dbsslcafile\s(.*)/i) {
$pa_config->{'dbsslcafile'}= clean_blank($1); $pa_config->{'dbsslcafile'}= clean_blank($1);
} }
elsif ($parametro =~ m/^verify_mysql_ssl_cert\s(.*)/i) {
$pa_config->{'verify_mysql_ssl_cert'}= clean_blank($1);
}
elsif ($parametro =~ m/^dbuser\s(.*)/i) { elsif ($parametro =~ m/^dbuser\s(.*)/i) {
$pa_config->{'dbuser'}= clean_blank($1); $pa_config->{'dbuser'}= clean_blank($1);
} }

View File

@ -114,6 +114,7 @@ use Encode;
use Encode::CN; use Encode::CN;
use XML::Simple; use XML::Simple;
use HTML::Entities; use HTML::Entities;
use Tie::File;
use Time::Local; use Time::Local;
use Time::HiRes qw(time); use Time::HiRes qw(time);
eval "use POSIX::strftime::GNU;1" if ($^O =~ /win/i); eval "use POSIX::strftime::GNU;1" if ($^O =~ /win/i);
@ -215,6 +216,7 @@ our @EXPORT = qw(
pandora_module_keep_alive_nd pandora_module_keep_alive_nd
pandora_module_unknown pandora_module_unknown
pandora_output_password pandora_output_password
pandora_snmptrapd_still_working
pandora_planned_downtime pandora_planned_downtime
pandora_planned_downtime_set_quiet_elements pandora_planned_downtime_set_quiet_elements
pandora_planned_downtime_unset_quiet_elements pandora_planned_downtime_unset_quiet_elements
@ -7229,6 +7231,43 @@ sub escalate_warning {
return MODULE_WARNING; return MODULE_WARNING;
} }
########################################################################
=head2 C<< pandora_snmptrapd_still_working (I<$pa_config>, I<$dbh>) >>
snmptrapd sometimes freezes and eventually its status needs to be checked.
=cut
########################################################################
sub pandora_snmptrapd_still_working ($$) {
my ($pa_config, $dbh) = @_;
if ($pa_config->{'snmpserver'} eq '1') {
# Variable that defines the maximum time of delay between kksks.
my $timeMaxLapse = 3600;
# Check last snmptrapd saved in DB.
my $lastTimestampSaved = get_db_value($dbh, 'SELECT UNIX_TIMESTAMP(timestamp)
FROM ttrap
ORDER BY timestamp DESC
LIMIT 1');
# Read the last log file line.
my $snmptrapdFile = $pa_config->{'snmp_logfile'};
tie my @snmptrapdFileComplete, 'Tie::File', $snmptrapdFile;
my $lastTimestampLogFile = $snmptrapdFileComplete[-1];
my ($protocol, $date, $time) = split(/\[\*\*\]/, $lastTimestampLogFile, 4);
# If time or date not filled in, probably havent caught any snmptraps yet.
if ($time ne '' && $date ne '') {
my ($hour, $min, $sec) = split(/:/, $time, 3);
my ($year, $month, $day) = split(/-/, $date, 3);
my $lastTimestampLogFile = timelocal($sec,$min,$hour,$day,$month-1,$year);
if ($lastTimestampSaved ne $lastTimestampLogFile && $lastTimestampLogFile gt ($lastTimestampSaved + $timeMaxLapse)) {
my $lapseMessage = "snmptrapd service probably is stuck.";
logger($pa_config, $lapseMessage, 1);
pandora_event ($pa_config, $lapseMessage, 0, 0, 4, 0, 0, 'system', 0, $dbh);
}
}
}
}
# End of function declaration # End of function declaration
# End of defined Code # End of defined Code

View File

@ -1665,9 +1665,12 @@ sub set_ssl_opts($) {
} }
# Enable SSL. # Enable SSL.
$SSL_OPTS = "mysql_ssl=1;mysql_ssl_optional=1;mysql_ssl_verify_server_cert=1"; $SSL_OPTS = "mysql_ssl=1;mysql_ssl_optional=1";
# Set additional SSL options. # Set additional SSL options.
if (defined($pa_config->{'verify_mysql_ssl_cert'}) && $pa_config->{'verify_mysql_ssl_cert'} ne "") {
$SSL_OPTS .= ";mysql_ssl_verify_server_cert=" . $pa_config->{'verify_mysql_ssl_cert'};
}
if (defined($pa_config->{'dbsslcapath'}) && $pa_config->{'dbsslcapath'} ne "") { if (defined($pa_config->{'dbsslcapath'}) && $pa_config->{'dbsslcapath'} ne "") {
$SSL_OPTS .= ";mysql_ssl_ca_path=" . $pa_config->{'dbsslcapath'}; $SSL_OPTS .= ";mysql_ssl_ca_path=" . $pa_config->{'dbsslcapath'};
} }

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.765"; my $pandora_version = "7.0NG.765";
my $pandora_build = "221102"; my $pandora_build = "221104";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221102 %define release 221104
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221102 %define release 221104
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.765" PI_VERSION="7.0NG.765"
PI_BUILD="221102" PI_BUILD="221104"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.765 Build 221102"; my $version = "7.0NG.765 Build 221104";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.765 Build 221102"; my $version = "7.0NG.765 Build 221104";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);