Merge branch 'develop' into feature/ticket#2179-recontask-view-acl-Pandora6.0
This commit is contained in:
commit
0c161cf7e9
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 6.0dev-150722
|
||||
Version: 6.0dev-150723
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="6.0dev-150722"
|
||||
pandora_version="6.0dev-150723"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -41,7 +41,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '6.0dev';
|
||||
use constant AGENT_BUILD => '150722';
|
||||
use constant AGENT_BUILD => '150723';
|
||||
|
||||
# Commands to retrieve total memory information in kB
|
||||
use constant TOTALMEMORY_CMDS => {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 6.0dev
|
||||
%define release 150722
|
||||
%define release 150723
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 6.0dev
|
||||
%define release 150722
|
||||
%define release 150723
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{150722}
|
||||
{150723}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("6.0dev(Build 150722)")
|
||||
#define PANDORA_VERSION ("6.0dev(Build 150723)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(6.0dev(Build 150722))"
|
||||
VALUE "ProductVersion", "(6.0dev(Build 150723))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 6.0dev-150722
|
||||
Version: 6.0dev-150723
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="6.0dev-150722"
|
||||
pandora_version="6.0dev-150723"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -81,7 +81,7 @@ $table_behaviour->data[$row][1] = html_print_checkbox('paginate_module', 1,
|
|||
$config['paginate_module'], true);
|
||||
$row++;
|
||||
|
||||
$table_behaviour->data[$row][0] = __('Display proc modules in binary format (OK/FAIL).');
|
||||
$table_behaviour->data[$row][0] = __('Display data of proc modules in other format');
|
||||
$table_behaviour->data[$row][1] = __('Yes') . ' ' .
|
||||
html_print_radio_button ('render_proc', 1, '',
|
||||
$config["render_proc"], true) .
|
||||
|
@ -90,6 +90,15 @@ $table_behaviour->data[$row][1] .= __('No') . ' ' .
|
|||
html_print_radio_button ('render_proc', 0, '',
|
||||
$config["render_proc"], true);
|
||||
$row++;
|
||||
|
||||
$table_behaviour->data[$row][0] = __('Display text proc modules have state is ok');
|
||||
$table_behaviour->data[$row][1] = html_print_input_text ('render_proc_ok', $config["render_proc_ok"], '', 25, 25, true);
|
||||
$row++;
|
||||
|
||||
$table_behaviour->data[$row][0] = __('Display text when proc modules have state critical');
|
||||
$table_behaviour->data[$row][1] = html_print_input_text ('render_proc_fail', $config["render_proc_fail"], '', 25, 25, true);
|
||||
$row++;
|
||||
|
||||
echo "<fieldset>";
|
||||
echo "<legend>" . __('Behaviour configuration') . "</legend>";
|
||||
html_print_table ($table_behaviour);
|
||||
|
|
|
@ -903,9 +903,9 @@ if ($list_modules) {
|
|||
case 21:
|
||||
case 31:
|
||||
if ($module["datos"]>=1)
|
||||
$salida ='OK';
|
||||
$salida = $config["render_proc_ok"];
|
||||
else
|
||||
$salida = 'FAIL';
|
||||
$salida = $config["render_proc_fail"];
|
||||
break;
|
||||
default:
|
||||
$salida = format_numeric($module["datos"]);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC150722';
|
||||
$build_version = 'PC150723';
|
||||
$pandora_version = 'v6.0dev';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -468,7 +468,11 @@ function config_update_config () {
|
|||
if (!config_update_value ('type_module_charts', (string) get_parameter('type_module_charts', 'area')))
|
||||
$error_update[] = __('Default type of module charts.');
|
||||
if (!config_update_value ('render_proc', (bool) get_parameter('render_proc', false)))
|
||||
$error_update[] = __('Display proc modules in binary format (OK/FAIL)');
|
||||
$error_update[] = __('Display dara of proc modules in other format');
|
||||
if (!config_update_value ('render_proc_ok', (string) get_parameter('render_proc_ok', __('Ok') )))
|
||||
$error_update[] = __('Display text proc modules have state is ok');
|
||||
if (!config_update_value ('render_proc_fail', (string) get_parameter('render_proc_fail', __('Fail') )))
|
||||
$error_update[] = __('Display text when proc modules have state critical');
|
||||
|
||||
|
||||
|
||||
|
@ -1296,6 +1300,13 @@ function config_process_config () {
|
|||
config_update_value ('render_proc', 0);
|
||||
}
|
||||
|
||||
if (!isset($config["render_proc_ok"])) {
|
||||
config_update_value ('render_proc_ok', __('Ok') );
|
||||
}
|
||||
if (!isset($config["render_proc_fail"])) {
|
||||
config_update_value ('render_proc_fail', __('Fail') );
|
||||
}
|
||||
|
||||
if (!isset($config['command_snapshot'])) {
|
||||
config_update_value ('command_snapshot', 1);
|
||||
}
|
||||
|
|
|
@ -571,7 +571,11 @@ function reporting_SLA($report, $content, $type = 'dinamic',
|
|||
$id_agent_modules[] = $sla['id_agent_module'];
|
||||
}
|
||||
|
||||
$planned_downtimes = reporting_get_planned_downtimes(($report['datetime']-$content['period']), $report['datetime'], $id_agent_modules);
|
||||
$planned_downtimes =
|
||||
reporting_get_planned_downtimes(
|
||||
($report['datetime'] - $content['period']),
|
||||
$report['datetime'],
|
||||
$id_agent_modules);
|
||||
$malformed_planned_downtimes = planned_downtimes_get_malformed();
|
||||
|
||||
if (!empty($planned_downtimes))
|
||||
|
@ -586,7 +590,8 @@ function reporting_SLA($report, $content, $type = 'dinamic',
|
|||
$data['name'] = $planned_downtime['name'];
|
||||
$data['description'] = $planned_downtime['description'];
|
||||
$data['execution'] = ucfirst($planned_downtime['type_execution']);
|
||||
$data['dates'] = reporting_format_planned_downtime_dates($planned_downtime);
|
||||
$data['dates'] =
|
||||
reporting_format_planned_downtime_dates($planned_downtime);
|
||||
|
||||
$data['malformed'] = 0;
|
||||
if (!$malformed_planned_downtimes_empty && isset($malformed_planned_downtimes[$planned_downtime['id']])) {
|
||||
|
@ -636,6 +641,8 @@ function reporting_SLA($report, $content, $type = 'dinamic',
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Get the sla_value in % and store it on $sla_value
|
||||
$sla_value = reporting_get_agentmodule_sla(
|
||||
$sla['id_agent_module'],
|
||||
|
@ -6367,6 +6374,8 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
|
||||
global $config;
|
||||
|
||||
|
||||
|
||||
if (empty($id_agent_module))
|
||||
return false;
|
||||
|
||||
|
@ -6385,8 +6394,11 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Calculate the SLA for large time without hours
|
||||
if ($timeFrom == $timeTo) {
|
||||
|
||||
// Get interval data
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tagente_datos
|
||||
|
@ -6438,7 +6450,8 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
}
|
||||
|
||||
// Calculate planned downtime dates
|
||||
$downtime_dates = reporting_get_planned_downtimes_intervals($id_agent_module, $datelimit, $date);
|
||||
$downtime_dates = reporting_get_planned_downtimes_intervals(
|
||||
$id_agent_module, $datelimit, $date);
|
||||
|
||||
// Get previous data
|
||||
$previous_data = modules_get_previous_data ($id_agent_module, $datelimit);
|
||||
|
@ -6476,12 +6489,27 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
}
|
||||
|
||||
$previous_utimestamp = $first_data['utimestamp'];
|
||||
if ((($max_value > $min_value AND ($first_data['datos'] > $max_value OR $first_data['datos'] < $min_value))) OR
|
||||
($max_value <= $min_value AND $first_data['datos'] < $min_value)) {
|
||||
if (
|
||||
(
|
||||
(
|
||||
$max_value > $min_value AND (
|
||||
$first_data['datos'] > $max_value OR
|
||||
$first_data['datos'] < $min_value
|
||||
)
|
||||
)
|
||||
) OR
|
||||
(
|
||||
$max_value <= $min_value AND
|
||||
$first_data['datos'] < $min_value
|
||||
)
|
||||
) {
|
||||
|
||||
$previous_status = 1;
|
||||
foreach ($downtime_dates as $date_dt) {
|
||||
if (($date_dt['date_from'] <= $previous_utimestamp) AND ($date_dt['date_to'] >= $previous_utimestamp)) {
|
||||
|
||||
if (($date_dt['date_from'] <= $previous_utimestamp) AND
|
||||
($date_dt['date_to'] >= $previous_utimestamp)) {
|
||||
|
||||
$previous_status = 0;
|
||||
}
|
||||
}
|
||||
|
@ -6537,13 +6565,14 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
$timeTo);
|
||||
}
|
||||
else {
|
||||
|
||||
// Extract the data each day
|
||||
|
||||
$sla = 0;
|
||||
|
||||
$i = 0;
|
||||
for ($interval = 0; $interval <= $period; $interval = $interval + SECONDS_1DAY) {
|
||||
$datelimit = $date - $interval;
|
||||
for ($interval = SECONDS_1DAY; $interval <= $period; $interval = $interval + SECONDS_1DAY) {
|
||||
|
||||
|
||||
$sla_day = reporting_get_agentmodule_sla(
|
||||
$id_agent_module,
|
||||
|
@ -6555,8 +6584,12 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
$timeFrom, $timeTo);
|
||||
|
||||
|
||||
$sla += $sla_day;
|
||||
$i++;
|
||||
|
||||
// Avoid to add the period of module not init
|
||||
if ($sla_day !== false) {
|
||||
$sla += $sla_day;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$sla = $sla / $i;
|
||||
|
@ -7400,13 +7433,16 @@ function reporting_get_agentmodule_sla_day ($id_agent_module, $period = 0, $min_
|
|||
// Limit date to start searching data
|
||||
$datelimit = $date - $period;
|
||||
|
||||
|
||||
|
||||
$search_in_history_db = db_search_in_history_db($datelimit);
|
||||
|
||||
// Get interval data
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tagente_datos
|
||||
WHERE id_agente_modulo = %d
|
||||
AND utimestamp > %d AND utimestamp <= %d',
|
||||
AND utimestamp > %d
|
||||
AND utimestamp <= %d',
|
||||
$id_agent_module, $datelimit, $date);
|
||||
|
||||
//Add the working times (mon - tue - wed ...) and from time to time
|
||||
|
@ -7467,10 +7503,11 @@ function reporting_get_agentmodule_sla_day ($id_agent_module, $period = 0, $min_
|
|||
}
|
||||
|
||||
// Calculate planned downtime dates
|
||||
$downtime_dates = reporting_get_planned_downtimes_intervals($id_agent_module, $datelimit, $date);
|
||||
$downtime_dates =
|
||||
reporting_get_planned_downtimes_intervals($id_agent_module, $datelimit, $date);
|
||||
|
||||
// Get previous data
|
||||
$previous_data = modules_get_previous_data ($id_agent_module, $datelimit);
|
||||
$previous_data = modules_get_previous_data($id_agent_module, $datelimit);
|
||||
|
||||
if ($previous_data !== false) {
|
||||
$previous_data['utimestamp'] = $datelimit;
|
||||
|
@ -7548,6 +7585,7 @@ function reporting_get_agentmodule_sla_day ($id_agent_module, $period = 0, $min_
|
|||
$previous_utimestamp = $data['utimestamp'];
|
||||
}
|
||||
|
||||
|
||||
// Return the percentage of SLA compliance
|
||||
return (float) (100 - ($bad_period / $period) * 100);
|
||||
}
|
||||
|
|
|
@ -13,21 +13,22 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
if (! isset($_SESSION['id_usuario'])) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
require_once('functions.php');
|
||||
require_once('functions_filemanager.php');
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("config.php");
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
$auth_method = db_get_value('value', 'tconfig', 'token', 'auth');
|
||||
|
||||
require_once("auth/" . $auth_method . ".php");
|
||||
|
||||
session_write_close ();
|
||||
|
||||
check_login ();
|
||||
|
||||
$styleError = "background:url(\"../images/err.png\") no-repeat scroll 0 0 transparent; padding:4px 1px 6px 30px; color:#CC0000;";
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '6.0dev';
|
||||
$build = '150722';
|
||||
$build = '150723';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -268,7 +268,7 @@ if (!$update_networkmap && !$save_networkmap) {
|
|||
$group = $networkmap_data['id_group'];
|
||||
$module_group = $networkmap_data['id_module_group'];
|
||||
$center = $networkmap_data['center'];
|
||||
$name = $networkmap_data['name'];
|
||||
$name = io_safe_output($networkmap_data['name']);
|
||||
$activeTab = $networkmap_data['type'];
|
||||
$l2_network = $networkmap_data['l2_network'];
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ $form_elems = array();
|
|||
|
||||
// Name
|
||||
$element = __('Name') . ' ' .
|
||||
html_print_input_text ('name', $name, '', 25, 50, true);
|
||||
html_print_input_text ('name', io_safe_output($name), '', 25, 50, true);
|
||||
if ($activeTab == 'groups')
|
||||
$element .= clippy_context_help("topology_group");
|
||||
$form_elems[] = $element;
|
||||
|
|
|
@ -217,7 +217,7 @@ else {
|
|||
|
||||
$data = array();
|
||||
$data[0] = '<b><a href="index.php?sec=network&sec2=operation/agentes/networkmap&tab=' . $network_map['type']
|
||||
. '&id_networkmap=' . $network_map['id_networkmap'] . '">' . $network_map['name'] . '</a></b>';
|
||||
. '&id_networkmap=' . $network_map['id_networkmap'] . '">' . io_safe_output($network_map['name']) . '</a></b>';
|
||||
$data[1] = $network_map['type'];
|
||||
$data[2] = ui_print_group_icon ($network_map['store_group'], true);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 6.0dev
|
||||
%define release 150722
|
||||
%define release 150723
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 6.0dev
|
||||
%define release 150722
|
||||
%define release 150723
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -39,7 +39,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
|||
('step_compact','1'),
|
||||
('db_scheme_first_version', '6.0dev'),
|
||||
('db_scheme_version','6.0dev'),
|
||||
('db_scheme_build','PD150722'),
|
||||
('db_scheme_build','PD150723'),
|
||||
('show_unknown','0'),
|
||||
('show_lastalerts','1'),
|
||||
('style','pandora'),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 6.0dev-150722
|
||||
Version: 6.0dev-150723
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="6.0dev-150722"
|
||||
pandora_version="6.0dev-150723"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -43,7 +43,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "6.0dev";
|
||||
my $pandora_build = "150722";
|
||||
my $pandora_build = "150723";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
|
|
@ -34,6 +34,7 @@ our @EXPORT = qw(
|
|||
add_new_address_agent
|
||||
db_concat
|
||||
db_connect
|
||||
db_delete_limit
|
||||
db_disconnect
|
||||
db_do
|
||||
db_get_lock
|
||||
|
@ -638,9 +639,9 @@ sub get_db_value_limit ($$$;@) {
|
|||
# Cache statements
|
||||
my $sth;
|
||||
if ($RDBMS ne 'oracle') {
|
||||
$sth = $dbh->prepare_cached($query . ' LIMIT ' . $limit);
|
||||
$sth = $dbh->prepare_cached($query . ' LIMIT ' . int($limit));
|
||||
} else {
|
||||
$sth = $dbh->prepare_cached('SELECT * FROM (' . $query . ') WHERE ROWNUM <= ' . $limit);
|
||||
$sth = $dbh->prepare_cached('SELECT * FROM (' . $query . ') WHERE ROWNUM <= ' . int($limit));
|
||||
}
|
||||
|
||||
$sth->execute(@values);
|
||||
|
@ -739,6 +740,29 @@ sub get_db_rows_limit ($$$;@) {
|
|||
return @rows;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
## SQL delete with a LIMIT clause.
|
||||
##########################################################################
|
||||
sub db_delete_limit ($$$$;@) {
|
||||
my ($dbh, $from, $where, $limit, @values) = @_;
|
||||
my $sth;
|
||||
|
||||
# MySQL
|
||||
if ($RDBMS eq 'mysql') {
|
||||
$sth = $dbh->prepare_cached("DELETE FROM $from WHERE $where LIMIT " . int($limit));
|
||||
}
|
||||
# PostgreSQL
|
||||
elsif ($RDBMS eq 'postgresql') {
|
||||
$sth = $dbh->prepare_cached("DELETE FROM $from WHERE $where LIMIT " . int($limit));
|
||||
}
|
||||
# Oracle
|
||||
elsif ($RDBMS eq 'oracle') {
|
||||
$sth = $dbh->prepare_cached("DELETE FROM (SELECT * FROM $from WHERE $where) WHERE ROWNUM <= " . int($limit));
|
||||
}
|
||||
|
||||
$sth->execute(@values);
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
## SQL insert. Returns the ID of the inserted row.
|
||||
##########################################################################
|
||||
|
@ -1109,7 +1133,10 @@ sub db_insert_get_values ($) {
|
|||
########################################################################
|
||||
sub db_get_lock($$;$) {
|
||||
my ($dbh, $lock_name, $lock_timeout) = @_;
|
||||
|
||||
|
||||
# Only supported in MySQL.
|
||||
return 1 unless ($RDBMS eq 'mysql');
|
||||
|
||||
# Set a default lock timeout of 1 second
|
||||
$lock_timeout = 1 if (! defined ($lock_timeout));
|
||||
|
||||
|
@ -1130,6 +1157,9 @@ sub db_get_lock($$;$) {
|
|||
sub db_release_lock($$) {
|
||||
my ($dbh, $lock_name) = @_;
|
||||
|
||||
# Only supported in MySQL.
|
||||
return unless ($RDBMS eq 'mysql');
|
||||
|
||||
my $sth = $dbh->prepare('SELECT RELEASE_LOCK(?)');
|
||||
$sth->execute($lock_name);
|
||||
my ($lock) = $sth->fetchrow;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 6.0dev
|
||||
%define release 150722
|
||||
%define release 150723
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 6.0dev
|
||||
%define release 150722
|
||||
%define release 150723
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -53,7 +53,7 @@ pandora_init(\%conf);
|
|||
pandora_load_config (\%conf);
|
||||
|
||||
# Connect to the DB
|
||||
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
|
||||
my $dbh = db_connect ($conf{'dbengine'}, $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
|
||||
my $history_dbh = ($conf{'_history_db_enabled'} eq '1') ? db_connect ('mysql', $conf{'_history_db_name'},
|
||||
$conf{'_history_db_host'}, '3306', $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ use PandoraFMS::Tools;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "6.0dev PS150722";
|
||||
my $version = "6.0dev PS150723";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
@ -87,7 +87,7 @@ sub pandora_purgedb ($$) {
|
|||
# Delete extended session data
|
||||
if (enterprise_load (\%conf) != 0) {
|
||||
db_do ($dbh, "DELETE FROM tsesion_extended
|
||||
WHERE id_sesion NOT IN ( SELECT id_sesion FROM tsesion );");
|
||||
WHERE id_sesion NOT IN ( SELECT id_sesion FROM tsesion )");
|
||||
log_message ('PURGE', 'Deleting old extended session data.');
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ sub pandora_purgedb ($$) {
|
|||
# steps (100 fixed by default)
|
||||
# Starting from the oldest record on the table
|
||||
|
||||
$first_mark = get_db_value ($dbh, 'SELECT utimestamp FROM tagente_datos_inventory ORDER BY utimestamp ASC LIMIT 1');
|
||||
$first_mark = get_db_value_limit ($dbh, 'SELECT utimestamp FROM tagente_datos_inventory ORDER BY utimestamp ASC', 1);
|
||||
if (defined ($first_mark)) {
|
||||
$total_time = $ulimit_timestamp - $first_mark;
|
||||
$purge_steps = int($total_time / $BIG_OPERATION_STEP);
|
||||
|
@ -137,7 +137,7 @@ sub pandora_purgedb ($$) {
|
|||
#
|
||||
# Now the log4x data
|
||||
#
|
||||
$first_mark = get_db_value ($dbh, 'SELECT utimestamp FROM tagente_datos_log4x ORDER BY utimestamp ASC LIMIT 1');
|
||||
$first_mark = get_db_value_limit ($dbh, 'SELECT utimestamp FROM tagente_datos_log4x ORDER BY utimestamp ASC', 1);
|
||||
if (defined ($first_mark)) {
|
||||
$total_time = $ulimit_timestamp - $first_mark;
|
||||
$purge_steps = int($total_time / $BIG_OPERATION_STEP);
|
||||
|
@ -206,7 +206,7 @@ sub pandora_purgedb ($$) {
|
|||
# Delete with buffer to avoid problems with performance
|
||||
my $events_to_delete = get_db_value ($dbh, "SELECT COUNT(*) FROM $events_table WHERE utimestamp < ?", $event_limit);
|
||||
while($events_to_delete > 0) {
|
||||
db_do($dbh, "DELETE FROM $events_table WHERE utimestamp < ? LIMIT ?", $event_limit, $BIG_OPERATION_STEP);
|
||||
db_delete_limit($dbh, $events_table, "utimestamp < ?", $BIG_OPERATION_STEP, $event_limit);
|
||||
$events_to_delete = $events_to_delete - $BIG_OPERATION_STEP;
|
||||
|
||||
# Mark the progress
|
||||
|
@ -222,7 +222,7 @@ sub pandora_purgedb ($$) {
|
|||
log_message ('PURGE', "Deleting validated events from tmetaconsole_event_history.", '');
|
||||
$events_to_delete = get_db_value ($dbh, "SELECT COUNT(*) FROM tmetaconsole_event_history WHERE estado = 1");
|
||||
while($events_to_delete > 0) {
|
||||
db_do($dbh, "DELETE FROM tmetaconsole_event_history WHERE estado = 1 LIMIT ?", $BIG_OPERATION_STEP);
|
||||
db_delete_limit($dbh, 'tmetaconsole_event_history', 'estado = 1', $BIG_OPERATION_STEP);
|
||||
$events_to_delete = $events_to_delete - $BIG_OPERATION_STEP;
|
||||
|
||||
# Mark the progress
|
||||
|
@ -292,7 +292,7 @@ sub pandora_purgedb ($$) {
|
|||
my $nstate = get_db_value ($dbh, 'SELECT count(id_agente_modulo) FROM tagente_estado WHERE id_agente_modulo=?', $id_module);
|
||||
last if($nstate == 0);
|
||||
|
||||
db_do ($dbh, 'DELETE FROM tagente_estado WHERE id_agente_modulo=? LIMIT ?', $id_module, $buffer);
|
||||
db_delete_limit ($dbh, 'tagente_estado', 'id_agente_modulo=?', $buffer, $id_module);
|
||||
}
|
||||
}
|
||||
log_message ('', "\n");
|
||||
|
@ -303,7 +303,7 @@ sub pandora_purgedb ($$) {
|
|||
|
||||
log_message ('PURGE', "Deleting old access data (More than 24hr)");
|
||||
|
||||
$first_mark = get_db_value ($dbh, 'SELECT utimestamp FROM tagent_access ORDER BY utimestamp ASC LIMIT 1');
|
||||
$first_mark = get_db_value_limit ($dbh, 'SELECT utimestamp FROM tagent_access ORDER BY utimestamp ASC', 1);
|
||||
if (defined ($first_mark)) {
|
||||
$total_time = $ulimit_access_timestamp - $first_mark;
|
||||
$purge_steps = int( $total_time / $BIG_OPERATION_STEP);
|
||||
|
@ -339,31 +339,31 @@ sub pandora_purgedb ($$) {
|
|||
db_do ($dbh, "DELETE FROM treport_content
|
||||
WHERE id_agent_module != 0
|
||||
AND id_agent_module NOT IN (SELECT id_agente_modulo FROM tagente_modulo)
|
||||
AND type NOT IN ($blacklist_types_str);");
|
||||
AND ${RDBMS_QUOTE}type${RDBMS_QUOTE} NOT IN ($blacklist_types_str)");
|
||||
db_do ($dbh, "DELETE FROM treport_content_item
|
||||
WHERE id_agent_module != 0
|
||||
AND id_agent_module NOT IN (SELECT id_agente_modulo FROM tagente_modulo)
|
||||
AND id_report_content NOT IN (SELECT id_rc FROM treport_content WHERE type IN ($blacklist_types_str));");
|
||||
AND id_report_content NOT IN (SELECT id_rc FROM treport_content WHERE ${RDBMS_QUOTE}type${RDBMS_QUOTE} IN ($blacklist_types_str))");
|
||||
db_do ($dbh, "DELETE FROM treport_content_sla_combined
|
||||
WHERE id_agent_module != 0
|
||||
AND id_agent_module NOT IN (SELECT id_agente_modulo FROM tagente_modulo)
|
||||
AND id_report_content NOT IN (SELECT id_rc FROM treport_content WHERE type = 'SLA_services');");
|
||||
AND id_report_content NOT IN (SELECT id_rc FROM treport_content WHERE ${RDBMS_QUOTE}type${RDBMS_QUOTE} = 'SLA_services')");
|
||||
|
||||
# Deleted agents
|
||||
log_message ('PURGE', "Delete contents in report that have some deleted agents.");
|
||||
db_do ($dbh, "DELETE FROM treport_content
|
||||
WHERE id_agent != 0
|
||||
AND id_agent NOT IN (SELECT id_agente FROM tagente)
|
||||
AND type NOT IN ($blacklist_types_str);");
|
||||
AND ${RDBMS_QUOTE}type${RDBMS_QUOTE} NOT IN ($blacklist_types_str)");
|
||||
|
||||
# Empty contents
|
||||
log_message ('PURGE', "Delete empty contents in report (like SLA or Exception).");
|
||||
db_do ($dbh, "DELETE FROM treport_content
|
||||
WHERE type LIKE 'exception'
|
||||
AND id_rc NOT IN (SELECT id_report_content FROM treport_content_item);");
|
||||
WHERE ${RDBMS_QUOTE}type${RDBMS_QUOTE} LIKE 'exception'
|
||||
AND id_rc NOT IN (SELECT id_report_content FROM treport_content_item)");
|
||||
db_do ($dbh, "DELETE FROM treport_content
|
||||
WHERE type IN ('SLA', 'SLA_monthly', 'SLA_services')
|
||||
AND id_rc NOT IN (SELECT id_report_content FROM treport_content_sla_combined);");
|
||||
WHERE ${RDBMS_QUOTE}type${RDBMS_QUOTE} IN ('SLA', 'SLA_monthly', 'SLA_services')
|
||||
AND id_rc NOT IN (SELECT id_report_content FROM treport_content_sla_combined)");
|
||||
}
|
||||
|
||||
|
||||
|
@ -913,7 +913,7 @@ sub pandora_delete_old_module_data {
|
|||
# you alter code and you don't know exactly what are you doing. Please take in mind this code executes each hour
|
||||
# and has been patches MANY times. Before altering anything, think twice !
|
||||
|
||||
$first_mark = get_db_value ($dbh, "SELECT utimestamp FROM $table ORDER BY utimestamp ASC LIMIT 1");
|
||||
$first_mark = get_db_value_limit ($dbh, "SELECT utimestamp FROM $table ORDER BY utimestamp ASC", 1);
|
||||
if (defined ($first_mark)) {
|
||||
$total_time = $ulimit_timestamp - $first_mark;
|
||||
$purge_steps = int($total_time / $BIG_OPERATION_STEP);
|
||||
|
@ -926,7 +926,7 @@ sub pandora_delete_old_module_data {
|
|||
# Let's split the intervals in $SMALL_OPERATION_STEP deletes each
|
||||
$purge_count = get_db_value ($dbh, "SELECT COUNT(id_agente_modulo) FROM $table WHERE utimestamp < $mark1 AND utimestamp >= $mark2");
|
||||
while ($purge_count > 0){
|
||||
db_do ($dbh, "DELETE FROM $table WHERE utimestamp < $mark1 AND utimestamp >= $mark2 LIMIT $SMALL_OPERATION_STEP");
|
||||
db_delete_limit ($dbh, $table, 'utimestamp < ? AND utimestamp >= ?', $SMALL_OPERATION_STEP, $mark1, $mark2);
|
||||
# Do a nanosleep here for 0,001 sec
|
||||
usleep (10000);
|
||||
$purge_count = $purge_count - $SMALL_OPERATION_STEP;
|
||||
|
@ -950,7 +950,8 @@ sub pandora_delete_old_export_data {
|
|||
my ($dbh, $ulimit_timestamp) = @_;
|
||||
|
||||
log_message ('PURGE', "Deleting old export data from tserver_export_data\n");
|
||||
while(db_do ($dbh, "DELETE FROM tserver_export_data WHERE UNIX_TIMESTAMP(timestamp) < ? LIMIT $SMALL_OPERATION_STEP", $ulimit_timestamp) ne '0E0') {
|
||||
while((my $rc = db_delete_limit ($dbh, 'tserver_export_data', 'UNIX_TIMESTAMP(timestamp) < ?', $SMALL_OPERATION_STEP, $ulimit_timestamp)) ne '0E0') {
|
||||
print "RC:$rc\n";
|
||||
usleep (10000);
|
||||
};
|
||||
}
|
||||
|
@ -962,7 +963,7 @@ sub pandora_delete_old_session_data {
|
|||
my ($dbh, $ulimit_timestamp) = @_;
|
||||
|
||||
log_message ('PURGE', "Deleting old session data from tsessions_php\n");
|
||||
while(db_do ($dbh, "DELETE FROM tsessions_php WHERE last_active < ? LIMIT $SMALL_OPERATION_STEP", $ulimit_timestamp) ne '0E0') {
|
||||
while(db_delete_limit ($dbh, 'tsessions_php', 'last_active < ?', $SMALL_OPERATION_STEP, $ulimit_timestamp) ne '0E0') {
|
||||
usleep (10000);
|
||||
};
|
||||
}
|
||||
|
@ -1019,7 +1020,7 @@ else {
|
|||
}
|
||||
|
||||
# Connect to the DB
|
||||
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
|
||||
my $dbh = db_connect ($conf{'dbengine'}, $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
|
||||
my $history_dbh = ($conf{'_history_db_enabled'} eq '1') ? db_connect ('mysql', $conf{'_history_db_name'},
|
||||
$conf{'_history_db_host'}, '3306', $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "6.0dev PS150722";
|
||||
my $version = "6.0dev PS150723";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
|
Loading…
Reference in New Issue