Merge remote-tracking branch 'origin/develop' into ent-9554-nuevas-graficas-de-tarta-que-reemplazar-a-las-actuales-3

This commit is contained in:
daniel 2022-12-27 09:06:20 +01:00
commit 69e3203317
46 changed files with 46162 additions and 40061 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.767-221221
Version: 7.0NG.767-221227
Architecture: all
Priority: optional
Section: admin

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.767"
PI_BUILD="221221"
PI_BUILD="221227"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{221221}
{221227}
ViewReadme
{Yes}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.767-221221
Version: 7.0NG.767-221227
Architecture: all
Priority: optional
Section: admin

View File

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

File diff suppressed because one or more lines are too long

View File

@ -52,13 +52,13 @@ if (!isset($policy_page)) {
echo '<form id="create_module_type" method="post" action="'.$url.'">';
echo '<table width="100%" cellpadding="2" cellspacing="2" class="databox filters" >';
echo "<tr><td class='datos bolder w20p'>";
echo __('Search').' '.html_print_input_text(
echo "<tr><td class='datos bolder w12p'><span class='mrgn_right_7px'>";
echo __('Search').'</span>'.html_print_input_text(
'search_string',
$search_string,
'',
15,
255,
5,
5,
true
);
html_print_input_hidden('search', 1);
@ -73,7 +73,6 @@ echo '</td>';
echo "<td class='datos w10p'>";
html_print_submit_button(__('Filter'), 'filter', false, 'class="sub search"');
echo '</td>';
echo "<td class='datos w10p'></td>";
echo '</form>';
// Check if there is at least one server of each type available to assign that
// kind of modules. If not, do not show server type in combo.
@ -179,7 +178,7 @@ if (($policy_page) || (isset($agent))) {
// Create module/type combo.
echo '<form id="create_module_type" method="post" action="'.$url.'">';
if (!$policy_page) {
echo '<td class="datos w20p bolder">';
echo '<td class="datos w15p bolder">';
echo __('Show in hierachy mode');
if ($checked == 'true') {
$checked = true;
@ -198,8 +197,8 @@ if (($policy_page) || (isset($agent))) {
echo '</td>';
}
echo '<td class="datos w20p bolder">';
echo __('<p>Type</p>');
echo '<td class="datos w20p bolder lign_right"><span class="mrgn_right_7px">';
echo __('Type').'</span>';
html_print_select(
$modules,
'moduletype',
@ -216,7 +215,7 @@ if (($policy_page) || (isset($agent))) {
);
html_print_input_hidden('edit_module', 1);
echo '</td>';
echo '<td class="datos w10p">';
echo '<td class="datos w5p">';
echo '<input align="right" name="updbutton" type="submit" class="sub next" value="'.__('Create').'">';
echo '</td>';
echo '</tr>';

View File

@ -92,6 +92,7 @@ if (is_ajax() === true) {
if ($get_group_agents === true) {
ob_clean();
$id_group = (int) get_parameter('id_group');
$id_os = (int) get_parameter('id_os', 0);
$disabled = (int) get_parameter('disabled', 0);
$search = (string) get_parameter('search', '');
$recursion = (int) get_parameter('recursion', 0);
@ -151,6 +152,10 @@ if (is_ajax() === true) {
$filter['status'] = $status_agents;
}
if ($id_os !== 0) {
$filter['id_os'] = $id_os;
}
$_sql_post = ' 1=1 ';
if ($show_void_agents == 0) {
$_sql_post .= ' AND id_agente IN (SELECT a.id_agente FROM tagente a, tagente_modulo b WHERE a.id_agente=b.id_agente AND b.delete_pending=0) AND \'1\'';
@ -782,18 +787,18 @@ if ($tab == 'tree') {
$form = "<form method='post' action=''>";
$form .= "<table class='databox filters bolder' width='100%'>";
$form .= '<tr><td>'.__('Search').'&nbsp;';
$form .= '<tr><td>'.__('Search').'&nbsp;&nbsp;&nbsp;';
$form .= html_print_input_text(
'search',
$search,
'',
100,
100,
30,
30,
true
);
$form .= '</td><td>';
$form .= '</td><td style="text-align: right">';
$form .= "<input name='find' type='submit' class='sub search' value='".__('Search')."'>";
$form .= '<td></tr>';
$form .= '</tr>';
$form .= '</table>';
$form .= '</form>';

View File

@ -213,10 +213,16 @@ function process_user_login_local($login, $pass, $api=false)
$row = db_get_row_sql($sql);
// Check that row exists, that password is not empty and that password is the same hash
if ($row !== false && $row['password'] !== md5('')
&& $row['password'] == md5($pass)
) {
// Perform password check whether it is MD5-hashed (old hashing) or Bcrypt-hashed.
if (strlen($row['password']) === 32) {
// MD5.
$credentials_check = $row !== false && $row['password'] !== md5('') && $row['password'] == md5($pass);
} else {
// Bcrypt.
$credentials_check = password_verify($pass, $row['password']);
}
if ($credentials_check === true) {
// Login OK
// Nick could be uppercase or lowercase (select in MySQL
// is not case sensitive)
@ -231,6 +237,11 @@ function process_user_login_local($login, $pass, $api=false)
return false;
}
// Override password to use Bcrypt encryption.
if (strlen($row['password']) === 32) {
update_user_password($login, $pass);
}
return $row['id_user'];
} else {
if (!user_can_login($login)) {
@ -656,7 +667,7 @@ function create_user($id_user, $password, $user_info)
{
$values = $user_info;
$values['id_user'] = $id_user;
$values['password'] = md5($password);
$values['password'] = password_hash($password, PASSWORD_BCRYPT);
$values['last_connect'] = 0;
$values['registered'] = get_system_time();
@ -747,7 +758,7 @@ function delete_user(string $id_user)
/**
* Update the password in MD5 for user pass as id_user with
* Update the password using BCRYPT algorithm for specific id_user passing
* password in plain text.
*
* @param string $user User ID.
@ -766,7 +777,7 @@ function update_user_password(string $user, string $password_new)
if (isset($config['auth']) === true && $config['auth'] === 'pandora') {
$sql = sprintf(
"UPDATE tusuario SET password = '".md5($password_new)."', last_pass_change = '".date('Y-m-d H:i:s', get_system_time())."' WHERE id_user = '".$user."'"
"UPDATE tusuario SET password = '".password_hash($password_new, PASSWORD_BCRYPT)."', last_pass_change = '".date('Y-m-d H:i:s', get_system_time())."' WHERE id_user = '".$user."'"
);
$connection = mysql_connect_db(
@ -786,7 +797,7 @@ function update_user_password(string $user, string $password_new)
return db_process_sql_update(
'tusuario',
[
'password' => md5($password_new),
'password' => password_hash($password_new, PASSWORD_BCRYPT),
'last_pass_change' => date('Y/m/d H:i:s', get_system_time()),
],
['id_user' => $user]
@ -1050,7 +1061,7 @@ function create_user_and_permisions_ldap(
$values['id_user'] = $id_user;
if ($config['ldap_save_password'] || $config['ad_save_password']) {
$values['password'] = md5($password);
$values['password'] = password_hash($password, PASSWORD_BCRYPT);
}
$values['last_connect'] = 0;
@ -1482,9 +1493,9 @@ function change_local_user_pass_ldap($id_user, $password)
$local_user_pass = db_get_value_filter('password', 'tusuario', ['id_user' => $id_user]);
$return = false;
if (md5($password) !== $local_user_pass) {
if (password_hash($password, PASSWORD_BCRYPT) !== $local_user_pass) {
$values_update = [];
$values_update['password'] = md5($password);
$values_update['password'] = password_hash($password, PASSWORD_BCRYPT);
$return = db_process_sql_update('tusuario', $values_update, ['id_user' => $id_user]);
}

View File

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

View File

@ -2104,7 +2104,7 @@ function get_snmpwalk(
}
if (enterprise_installed()) {
if ($server_to_exec != 0) {
if (empty($server_to_exec) === false) {
$server_data = db_get_row('tserver', 'id_server', $server_to_exec);
if (empty($server_data['port'])) {

View File

@ -8545,14 +8545,17 @@ function reporting_advanced_sla(
$sla_check_value_warning = false;
if ($sla_check_value === true) {
// Warning SLA check.
$sla_check_value_warning = sla_check_value(
$current_data['datos'],
$min_value_warning,
$max_value_warning,
$inverse_interval_warning,
1
);
if ((isset($min_value_warning) === false
&& isset($max_value_warning) === false) === false
) {
// Warning SLA check.
$sla_check_value_warning = sla_check_value(
$current_data['datos'],
$min_value_warning,
$max_value_warning,
$inverse_interval_warning
);
}
}
}
@ -15269,8 +15272,6 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
$return = [];
$urlImage = ui_get_full_url(false, true, false, false);
$return['type'] = $content['type'];
$ttl = 1;
@ -15379,10 +15380,24 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
return false;
}
$uncompress_module = db_uncompress_module_data(
$module_interval = modules_get_interval(
$content['id_agent_module']
);
$slice = ($content['period'] / $module_interval);
$result_sla = reporting_advanced_sla(
$content['id_agent_module'],
($report['datetime'] - $content['period']),
$report['datetime']
$report['datetime'],
null,
null,
0,
null,
null,
null,
$slice,
1,
true
);
// Select Warning and critical values.
@ -15431,125 +15446,84 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
$inverse_warning = $agentmodule_info['warning_inverse'];
// Initialize vars.
$tstart = 0;
$tend = 0;
$tacum = 0;
$tacum_data = 0;
$data = [];
$data['time_total'] = 0;
$data['time_ok'] = 0;
$data['time_error'] = 0;
$data['time_warning'] = 0;
$data['time_unknown'] = 0;
$data['time_not_init'] = 0;
$data['time_downtime'] = 0;
$data['checks_total'] = 0;
$data['checks_ok'] = 0;
$data['checks_error'] = 0;
$data['checks_warning'] = 0;
$data['checks_unknown'] = 0;
$data['checks_not_init'] = 0;
$array_graph = [];
$i = 0;
foreach ($result_sla as $value_sla) {
$data['time_total'] += $value_sla['time_total'];
$data['time_ok'] += $value_sla['time_ok'];
$data['time_error'] += $value_sla['time_error'];
$data['time_warning'] += $value_sla['time_warning'];
$data['time_unknown'] += $value_sla['time_unknown'];
$data['time_downtime'] += $value_sla['time_downtime'];
$data['time_not_init'] += $value_sla['time_not_init'];
$data['checks_total'] += $value_sla['checks_total'];
$data['checks_ok'] += $value_sla['checks_ok'];
$data['checks_error'] += $value_sla['checks_error'];
$data['checks_warning'] += $value_sla['checks_warning'];
$data['checks_unknown'] += $value_sla['checks_unknown'];
$data['checks_not_init'] += $value_sla['checks_not_init'];
$data_not_init = 0;
$data_unknown = 0;
$data_critical = 0;
$data_warning = 0;
$data_ok = 0;
$data_total = 0;
$time_not_init = 0;
$time_unknown = 0;
$time_critical = 0;
$time_warning = 0;
$time_ok = 0;
$legend = [];
foreach ($uncompress_module as $data) {
foreach ($data['data'] as $key => $value) {
if ($tacum == 0) {
// Initialize the accumulators.
$tacum = $value['utimestamp'];
$tacum_data = $value['datos'];
// Generate raw data for graph.
if ($value_sla['time_total'] != 0) {
if ($value_sla['time_error'] > 0) {
// ERR.
$array_graph[$i]['data'] = 3;
} else if ($value_sla['time_unknown'] > 0) {
// UNKNOWN.
$array_graph[$i]['data'] = 4;
} else if ($value_sla['time_warning'] > 0) {
// Warning.
$array_graph[$i]['data'] = 2;
} else if ($value_sla['time_not_init'] == $value_sla['time_total']) {
// NOT INIT.
$array_graph[$i]['data'] = 6;
} else {
// Utimestand end and final.
$tstart = $tacum;
$tend = $value['utimestamp'];
// Module type isn't string.
$sla_check_value_critical = sla_check_value(
$tacum_data,
$min_value_critical,
$max_value_critical,
$inverse_critical
);
$sla_check_value_warning = sla_check_value(
$tacum_data,
$min_value_warning,
$max_value_warning,
$inverse_warning
);
// Module type is string.
$string_check_value_critical = preg_match('/'.$max_value_critical.'/', $tacum_data);
$string_check_value_warning = preg_match('/'.$max_value_warning.'/', $tacum_data);
if ($inverse_critical) {
$string_check_value_critical = !preg_match('/'.$max_value_critical.'/', $tacum_data);
}
if ($string_check_value_warning) {
$string_check_value_warning = !preg_match('/'.$max_value_warning.'/', $tacum_data);
}
// Contruct array period and data.
if ($tacum_data === false) {
$array_graph[$data_total]['data'] = AGENT_MODULE_STATUS_NOT_INIT;
// NOT INIT.
$time_not_init = ($time_not_init + ($tend - $tstart));
$data_not_init++;
} else if ($tacum_data === null) {
$array_graph[$data_total]['data'] = AGENT_MODULE_STATUS_UNKNOWN;
// UNKNOWN.
$time_unknown = ($time_unknown + ($tend - $tstart));
$data_unknown++;
} else if (( (isset($min_value_critical) || isset($max_value_critical)) && ($modules_is_string === false) && ($sla_check_value_critical == true) )
|| ( isset($max_value_critical) && ($modules_is_string === true) && $string_check_value_critical )
) {
$array_graph[$data_total]['data'] = AGENT_MODULE_STATUS_CRITICAL_BAD;
// CRITICAL.
$time_critical = ($time_critical + ($tend - $tstart));
$data_critical++;
} else if (( (isset($min_value_warning) || isset($max_value_warning)) && ($modules_is_string === false) && ($sla_check_value_warning == true) )
|| ( isset($max_value_warning) && ($modules_is_string === true) && $sla_check_value_warning )
) {
$array_graph[$data_total]['data'] = AGENT_MODULE_STATUS_WARNING;
// WARNING.
$time_warning = ($time_warning + ($tend - $tstart));
$data_warning++;
} else {
$array_graph[$data_total]['data'] = AGENT_MODULE_STATUS_NORMAL;
// OK.
$time_ok = ($time_ok + ($tend - $tstart));
$data_ok++;
}
$array_graph[$data_total]['utimestamp'] = ($tend - $tstart);
$array_graph[$data_total]['real_data'] = $tacum_data;
// Reassign accumulators.
$tacum = $value['utimestamp'];
$tacum_data = $value['datos'];
$data_total++;
$array_graph[$i]['data'] = 1;
}
} else {
$array_graph[$i]['data'] = 7;
}
$array_graph[$i]['utimestamp'] = ($value_sla['date_to'] - $value_sla['date_from']);
$i++;
}
$data['sla_value'] = reporting_sla_get_compliance_from_array(
$data
);
$data['sla_fixed'] = sla_truncate(
$data['sla_value'],
$config['graph_precision']
);
$data_init = -1;
$acum = 0;
$sum = 0;
$array_result = [];
$i = 0;
foreach ($array_graph as $key => $value) {
foreach ($array_graph as $value) {
if ($data_init == -1) {
$data_init = $value['data'];
$acum = $value['utimestamp'];
} else {
if ($data_init == $value['data']) {
$acum = ($acum + $value['utimestamp']);
if ($modules_is_string === false) {
$sum = ($sum + $value['real_data']);
} else {
$sum = $value['real_data'];
}
} else {
$array_result[$i]['data'] = $data_init;
$array_result[$i]['utimestamp'] = $acum;
@ -15557,7 +15531,6 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
$i++;
$data_init = $value['data'];
$acum = $value['utimestamp'];
$sum = $value['real_data'];
}
}
}
@ -15570,39 +15543,42 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
$array_result[$i]['real_data'] = $sum;
}
$time_total = ($time_not_init + $time_unknown + $time_critical + $time_warning + $time_ok);
$time_total = $data['time_total'];
// Slice graphs calculation.
$return['agent'] = modules_get_agentmodule_agent_alias(
$return['agent'] = modules_get_agentmodule_agent_alias(
$content['id_agent_module']
);
$return['module'] = modules_get_agentmodule_name(
$return['module'] = modules_get_agentmodule_name(
$content['id_agent_module']
);
$return['max_critical'] = $max_value_critical;
$return['min_critical'] = $min_value_critical;
$return['max_critical'] = $max_value_critical;
$return['min_critical'] = $min_value_critical;
$return['critical_inverse'] = $inverse_critical;
$return['max_warning'] = $max_value_warning;
$return['min_warning'] = $min_value_warning;
$return['warning_inverse'] = $inverse_warning;
$return['data_not_init'] = $data_not_init;
$return['data_unknown'] = $data_unknown;
$return['data_critical'] = $data_critical;
$return['data_warning'] = $data_warning;
$return['data_ok'] = $data_ok;
$return['data_total'] = $data_total;
$return['time_not_init'] = $time_not_init;
$return['time_unknown'] = $time_unknown;
$return['time_critical'] = $time_critical;
$return['time_warning'] = $time_warning;
$return['time_ok'] = $time_ok;
$return['percent_ok'] = (($data_ok * 100) / $data_total);
$return['max_warning'] = $max_value_warning;
$return['min_warning'] = $min_value_warning;
$return['warning_inverse'] = $inverse_warning;
$return['data_not_init'] = $data['checks_not_init'];
$return['data_unknown'] = $data['checks_unknown'];
$return['data_critical'] = $data['checks_error'];
$return['data_warning'] = $data['checks_warning'];
$return['data_ok'] = $data['checks_ok'];
$return['data_total'] = $data['checks_total'];
$return['time_not_init'] = $data['time_not_init'];
$return['time_unknown'] = $data['time_unknown'];
$return['time_critical'] = $data['time_error'];
$return['time_warning'] = $data['time_warning'];
$return['time_ok'] = $data['time_ok'];
$return['percent_ok'] = (($data['checks_ok'] * 100) / $data['checks_total']);
$colors = [
AGENT_MODULE_STATUS_NORMAL => COL_NORMAL,
AGENT_MODULE_STATUS_WARNING => COL_WARNING,
AGENT_MODULE_STATUS_CRITICAL_BAD => COL_CRITICAL,
AGENT_MODULE_STATUS_UNKNOWN => COL_UNKNOWN,
AGENT_MODULE_STATUS_NOT_INIT => COL_NOTINIT,
1 => COL_NORMAL,
2 => COL_WARNING,
3 => COL_CRITICAL,
4 => COL_UNKNOWN,
5 => COL_DOWNTIME,
6 => COL_NOTINIT,
7 => COL_IGNORED,
];
$width_graph = 100;
@ -15612,7 +15588,7 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
$time_total,
$width_graph,
$height_graph,
$legend,
[],
$colors,
$config['fontpath'],
$config['round_corner'],

View File

@ -460,7 +460,7 @@ function snmp_browser_get_oid(
$snmptranslate_bin = $config['snmptranslate'];
}
if ($server_to_exec != 0 && enterprise_installed()) {
if (empty($server_to_exec) === false && enterprise_installed()) {
$server_data = db_get_row('tserver', 'id_server', $server_to_exec);
$command_output = $snmptranslate_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -Td '.escapeshellarg($oid);

View File

@ -380,6 +380,7 @@ function configure_modules_form() {
$("#text-snmp_oid").val(js_html_entity_decode(data["snmp_oid"]));
$("#oid, img#edit_oid").hide();
$("#id_module_group").val(data["id_module_group"]);
$("#id_module_group").trigger("change");
$("#max_timeout").attr("value", data["max_timeout"]);
$("#max_retries").attr("value", data["max_retries"]);
if (data["id_plugin"] != undefined) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -252,9 +252,7 @@ function snmp_show_result_message(data) {
// Stop waiting modal.
waiting_modal(stop);
var dato = data.replace(/[^]+(?=\[)/, "");
dato = JSON.parse(dato);
var dato = JSON.parse(data);
if (dato.length !== 0) {
$("#error_text").text("");
@ -678,13 +676,16 @@ function show_add_module() {
//Submit form to agent module url.
$("#snmp_create_module").attr(
"action",
"index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente="+id_agent+"&tab=module&edit_module=1");
"index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente="
+id_agent+
"&tab=module&edit_module=1"
);
$('#snmp_create_module').submit();
//Close dialog.
$('#dialog_create_module').dialog("close");
},
onDeny: function () {
$("#dialog_create_module").dialog("close");
return false;
}
});
}

View File

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

View File

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

View File

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

View File

@ -1275,7 +1275,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` (
`firstname` VARCHAR(255) NOT NULL,
`lastname` VARCHAR(255) NOT NULL,
`middlename` VARCHAR(255) NOT NULL,
`password` VARCHAR(45) DEFAULT NULL,
`password` VARCHAR(60) DEFAULT NULL,
`comments` VARCHAR(200) DEFAULT NULL,
`last_connect` BIGINT NOT NULL DEFAULT 0,
`registered` BIGINT NOT NULL DEFAULT 0,

View File

@ -345,7 +345,7 @@ INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `descri
-- Dumping data for table `tusuario`
--
INSERT INTO `tusuario` (`id_user`, `fullname`, `firstname`, `lastname`, `middlename`, `password`, `comments`, `last_connect`, `registered`, `email`, `phone`, `is_admin`, `language`, `block_size`, `section`, `data_section`, `metaconsole_access`, `local_user`) VALUES
('admin', 'Pandora', 'Pandora', 'Admin', '', '1da7ee7d45b96d0e1f45ee4ee23da560', 'Admin Pandora', 1232642121, 0, 'admin@example.com', '555-555-5555', 1, 'default', 0, 'Default', '', 'advanced', 1);
('admin', 'Pandora', 'Pandora', 'Admin', '', '$2y$10$Wv/xoxjI2VAkthJhk/PzeeGIhBKYU/K.TMgUdmW7fEP2NQkdWlB9K', 'Admin Pandora', 1232642121, 0, 'admin@example.com', '555-555-5555', 1, 'default', 0, 'Default', '', 'advanced', 1);
--
-- Dumping data for table `tusuario_perfil`

View File

@ -0,0 +1,47 @@
import gspread
import argparse
from oauth2client.service_account import ServiceAccountCredentials
from pprint import pprint
__author__ = "Alejandro Sánchez Carrion"
__copyright__ = "Copyright 2022, PandoraFMS"
__maintainer__ = "Operations department"
__status__ = "Production"
__version__= '1.0'
info = f"""
Pandora FMS Google Sheets
Version = {__version__}
Manual execution
python3 pandora_googlesheets.py --cred <file credentials> --row <number-row> --column <number-column>
"""
parser = argparse.ArgumentParser(description= info, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('--cred', help='')
parser.add_argument('--name', help='')
parser.add_argument('--row', help='',type=int)
parser.add_argument('--column', help='',type=int)
args = parser.parse_args()
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name(args.cred, scope)
client = gspread.authorize(creds)
sheet = client.open(args.name).sheet1 # Open the spreadhseet
data = sheet.get_all_records() # Get a list of all records
if args.row is not None and args.column==None:
row = sheet.row_values(args.row) # Get a specific row
print(row)
elif args.row ==None and args.column is not None:
col = sheet.col_values(args.column) # Get a specific column
print(col)
elif args.row is not None and args.column is not None:
cell = sheet.cell(args.row,args.column).value # Get the value of a specific cell
print(cell)

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.767-221221
Version: 7.0NG.767-221227
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -855,6 +855,7 @@ sub main() {
# Main loop
my $time_ref = time ();
my $thr_time_ref = 0;
my $test_remote_interval = ($Config{'keepalive'}/$Config{'server_threshold'});
my $test_remote = 0;
while ($RUN == 1) {
@ -870,6 +871,15 @@ sub main() {
# Make sure all server threads are running.
die("Server thread crashed.") unless (check_server_threads() == 1);
# Monitor server threads.
if (defined($Config{"self_monitoring"})
&& $Config{"self_monitoring"} == 1
&& !is_metaconsole(\%Config)
&& time() - $thr_time_ref > $Config{'self_monitoring_interval'}) {
$thr_time_ref = time();
pandora_thread_monitoring (\%Config, $DBH, \@Servers);
}
db_do ($DBH,
"UPDATE tserver SET status = -1
WHERE UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(keepalive) > 2*server_keepalive

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.767";
my $pandora_build = "221221";
my $pandora_build = "221227";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -98,6 +98,8 @@ Exported Functions:
=item * C<pandora_self_monitoring>
=item * C<pandora_thread_monitoring>
=item * C<pandora_sample_agent>
=back
@ -258,6 +260,7 @@ our @EXPORT = qw(
pandora_group_statistics
pandora_server_statistics
pandora_self_monitoring
pandora_thread_monitoring
pandora_sample_agent
pandora_process_policy_queue
pandora_sync_agents_integria
@ -6067,6 +6070,71 @@ sub pandora_self_monitoring ($$) {
print XMLFILE $xml_output;
close (XMLFILE);
}
##########################################################################
=head2 C<< pandora_thread_monitoring (I<$pa_config>, I<$dbh>, I<$servers>) >>
Generate stats for Pandora FMS threads.
=cut
##########################################################################
sub pandora_thread_monitoring ($$$) {
my ($pa_config, $dbh, $servers) = @_;
my $utimestamp = time ();
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
my $xml_output = "";
$xml_output = "<agent_data os_name='$OS' os_version='$OS_VERSION' version='" . $pa_config->{'version'} . "' description='" . $pa_config->{'rb_product_name'} . " Server version " . $pa_config->{'version'} . "' agent_name='".$pa_config->{'servername'} . "' agent_alias='".$pa_config->{'servername'} . "' interval='".$pa_config->{"self_monitoring_interval"}."' timestamp='".$timestamp."' >";
foreach my $server (@{$servers}) {
while (my ($tid, $stats) = each(%{$server->getProducerStats()})) {
$xml_output .=" <module>";
$xml_output .=" <name>" . uc($ServerTypes[$server->{'_server_type'}]) . " Producer Status</name>";
$xml_output .=" <type>generic_proc</type>";
$xml_output .=" <module_group>System</module_group>";
$xml_output .=" <data>" . (time() - $stats->{'tstamp'} < 2 * $pa_config->{"self_monitoring_interval"} ? 1 : 0) . "</data>";
$xml_output .=" </module>";
$xml_output .=" <module>";
$xml_output .=" <name>" . uc($ServerTypes[$server->{'_server_type'}]) . " Producer Processing Rate</name>";
$xml_output .=" <type>generic_data</type>";
$xml_output .=" <module_group>Performance</module_group>";
$xml_output .=" <data>" . $stats->{'rate'} . "</data>";
$xml_output .=" <unit>tasks/second</unit>";
$xml_output .=" </module>";
}
my $idx = 0;
my $consumer_stats = $server->getConsumerStats();
foreach my $tid (sort(keys(%{$consumer_stats}))) {
my $stats = $consumer_stats->{$tid};
$idx += 1;
$xml_output .=" <module>";
$xml_output .=" <name>" . uc($ServerTypes[$server->{'_server_type'}]) . " Consumer #$idx Status</name>";
$xml_output .=" <type>generic_proc</type>";
$xml_output .=" <module_group>System</module_group>";
$xml_output .=" <data>" . (time() - $stats->{'tstamp'} < 2 * $pa_config->{"self_monitoring_interval"} ? 1 : 0) . "</data>";
$xml_output .=" </module>";
$xml_output .=" <module>";
$xml_output .=" <name>" . uc($ServerTypes[$server->{'_server_type'}]) . " Consumer #$idx Processing Rate</name>";
$xml_output .=" <type>generic_data</type>";
$xml_output .=" <module_group>Performance</module_group>";
$xml_output .=" <data>" . $stats->{'rate'} . "</data>";
$xml_output .=" <unit>tasks/second</unit>";
$xml_output .=" </module>";
}
}
$xml_output .= "</agent_data>";
my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{'servername'}.".threads.".$utimestamp.".data";
open (XMLFILE, ">", $filename) or die "[FATAL] Could not write to the thread monitoring XML file '$filename'";
print XMLFILE $xml_output;
close (XMLFILE);
}
##########################################################################
=head2 C<< xml_module_template (I<$module_name>, I<$module_type>, I<$module_data>) >>

View File

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

View File

@ -89,6 +89,15 @@ sub run ($$$$$) {
# Launch consumer threads
for (1..$self->getNumThreads ()) {
# Enable consumer stats
my $consumer_stats = shared_clone({
'tstamp' => time(),
'rate' => 0,
'rate_count' => 0,
'rate_tstamp' => time()
});
my $thr = threads->create ({'exit' => 'thread_only'},
sub {
my ($self, $task_queue, $pending_tasks, $sem, $task_sem) = @_;
@ -98,13 +107,29 @@ sub run ($$$$$) {
$sem->up();
exit 0;
};
# Make consumer stats reachable from the thread
$self->{'_consumer_stats'}->{threads->tid()} = $consumer_stats;
PandoraFMS::ProducerConsumerServer::data_consumer->(@_);
}, $self, $task_queue, $pending_tasks, $sem, $task_sem
);
return unless defined ($thr);
$self->addThread ($thr->tid ());
# Make consumer stats reachable from the main program
$self->{'_consumer_stats'}->{$thr->tid()} = $consumer_stats;
}
# Enable producer stats
my $producer_stats = shared_clone({
'tstamp' => time(),
'rate' => 0,
'rate_count' => 0,
'rate_tstamp' => time()
});
# Launch producer thread
my $thr = threads->create ({'exit' => 'thread_only'},
sub {
@ -115,11 +140,18 @@ sub run ($$$$$) {
$sem->up();
exit 0;
};
# Make producer stats reachable from the thread
$self->{'_producer_stats'}->{threads->tid()} = $producer_stats;
PandoraFMS::ProducerConsumerServer::data_producer->(@_);
}, $self, $task_queue, $pending_tasks, $sem, $task_sem
);
return unless defined ($thr);
$self->addThread ($thr->tid ());
# Make producer stats reachable from the main program
$self->{'_producer_stats'}->{$thr->tid()} = $producer_stats;
}
###############################################################################
@ -130,46 +162,50 @@ sub data_producer ($$$$$) {
my $pa_config = $self->getConfig ();
my $dbh;
eval {
# Connect to the DB
$dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'}, $pa_config->{'dbport'},
$pa_config->{'dbuser'}, $pa_config->{'dbpass'});
$self->setDBH ($dbh);
while ($RUN == 1) {
eval {
# Connect to the DB
$dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'}, $pa_config->{'dbport'},
$pa_config->{'dbuser'}, $pa_config->{'dbpass'});
$self->setDBH ($dbh);
while ($RUN == 1) {
while ($RUN == 1) {
# Get pending tasks
$self->logThread('[PRODUCER] Queuing tasks.');
my @tasks = &{$self->{'_producer'}}($self);
foreach my $task (@tasks) {
$sem->down;
# Get pending tasks
$self->logThread('[PRODUCER] Queuing tasks.');
my @tasks = &{$self->{'_producer'}}($self);
last if ($RUN == 0);
if (defined $pending_tasks->{$task}) {
$sem->up;
next;
}
foreach my $task (@tasks) {
$sem->down;
# Queue task and signal consumers
$pending_tasks->{$task} = 0;
push (@{$task_queue}, $task);
$task_sem->up;
$sem->up;
last if ($RUN == 0);
if (defined $pending_tasks->{$task}) {
$sem->up;
next;
}
# Queue task and signal consumers
$pending_tasks->{$task} = 0;
push (@{$task_queue}, $task);
$task_sem->up;
$sem->up;
}
last if ($RUN == 0);
# Update queue size and thread stats
$self->setQueueSize (scalar @{$task_queue});
$self->updateProducerStats(scalar(@tasks));
threads->yield;
usleep (int(1e6 * $self->getPeriod()));
}
last if ($RUN == 0);
# Update queue size for statistics
$self->setQueueSize (scalar @{$task_queue});
threads->yield;
usleep (int(1e6 * $self->getPeriod()));
};
if ($@) {
print STDERR $@;
}
};
if ($@) {
$self->setErrStr ($@);
}
$task_sem->up($self->getNumThreads ());
@ -185,40 +221,51 @@ sub data_consumer ($$$$$) {
my $pa_config = $self->getConfig ();
my $dbh;
eval {
# Connect to the DB
$dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'}, $pa_config->{'dbport'},
$pa_config->{'dbuser'}, $pa_config->{'dbpass'});
$self->setDBH ($dbh);
my $sem_timeout = $pa_config->{'self_monitoring_interval'} > 0 ?
$pa_config->{'self_monitoring_interval'} :
300;
while ($RUN == 1) {
eval {
# Connect to the DB
$dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'}, $pa_config->{'dbport'},
$pa_config->{'dbuser'}, $pa_config->{'dbpass'});
$self->setDBH ($dbh);
while ($RUN == 1) {
# Wait for data
$self->logThread('[CONSUMER] Waiting for data.');
$task_sem->down;
while ($RUN == 1) {
# Wait for data
$self->logThread('[CONSUMER] Waiting for data.');
while (!$task_sem->down_timed($sem_timeout)) {
$self->updateConsumerStats(0);
}
$sem->down;
last if ($RUN == 0);
my $task = shift (@{$task_queue});
$sem->up;
last if ($RUN == 0);
# The consumer was waiting for data when the producer exited
last if ($RUN == 0);
# Execute task
$self->logThread("[CONSUMER] Executing task: $task");
&{$self->{'_consumer'}}($self, $task);
$sem->down;
my $task = shift (@{$task_queue});
$sem->up;
# Update task status
$sem->down;
delete ($pending_tasks->{$task});
$sem->up;
# The consumer was waiting for data when the producer exited
last if ($RUN == 0);
# Execute task
$self->logThread("[CONSUMER] Executing task: $task");
&{$self->{'_consumer'}}($self, $task);
threads->yield;
# Update thread stats
$self->updateConsumerStats(1);
# Update task status
$sem->down;
delete ($pending_tasks->{$task});
$sem->up;
threads->yield;
}
};
if ($@) {
print STDERR $@;
}
};
if ($@) {
$self->setErrStr ($@);
}
db_disconnect ($dbh);

View File

@ -47,7 +47,9 @@ sub new ($$$;$) {
_threads => [],
_queue_size => 0,
_errstr => '',
_period => 0
_period => 0,
_producer_stats => {},
_consumer_stats => {},
};
# Share variables that may be set from different threads
@ -176,6 +178,24 @@ sub getServerType ($) {
return $self->{'_server_type'};
}
########################################################################################
# Return consumer stats.
########################################################################################
sub getConsumerStats ($) {
my $self = shift;
return $self->{'_consumer_stats'};
}
########################################################################################
# Return producer stats.
########################################################################################
sub getProducerStats ($) {
my $self = shift;
return $self->{'_producer_stats'};
}
########################################################################################
# Set error string.
########################################################################################
@ -337,6 +357,52 @@ sub stop ($) {
}
}
########################################################################################
# Update stats for the current thread.
########################################################################################
sub updateStats ($$$) {
my ($self, $dest, $inc) = @_;
my $tid = threads->tid();
my $curr_time = time();
# Stats disabled for this thread.
if (!defined($dest->{$tid})) {
return;
}
# Update the timestamp and count.
$dest->{$tid}->{'tstamp'} = time();
$dest->{$tid}->{'rate_count'} += $inc;
# Compute the processing rate.
my $elapsed = $curr_time - $dest->{$tid}->{'rate_tstamp'};
if ($elapsed >= $self->{'_pa_config'}->{'self_monitoring_interval'}) {
$dest->{$tid}->{'rate'} = $dest->{$tid}->{'rate_count'} / $elapsed;
$dest->{$tid}->{'rate_count'} = 0;
$dest->{$tid}->{'rate_tstamp'} = $curr_time;
return;
}
}
########################################################################################
# Update producer stats.
########################################################################################
sub updateProducerStats ($$) {
my ($self, $queued_tasks) = @_;
$self->updateStats($self->{'_producer_stats'}, $queued_tasks);
}
########################################################################################
# Update consumer stats.
########################################################################################
sub updateConsumerStats ($$) {
my ($self, $processed_tasks) = @_;
$self->updateStats($self->{'_consumer_stats'}, $processed_tasks);
}
# End of function declaration
# End of defined Code

View File

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

View File

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

View File

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

View File

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

View File

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