Merge branch 'develop' into feature/ticket#2179-recontask-view-acl-Pandora6.0

This commit is contained in:
Arturo Gonzalez Diaz 2015-07-23 16:07:19 +02:00
commit 0c161cf7e9
31 changed files with 161 additions and 71 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 6.0dev-150722 Version: 6.0dev-150723
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="6.0dev-150722" pandora_version="6.0dev-150723"
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

@ -41,7 +41,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '6.0dev'; use constant AGENT_VERSION => '6.0dev';
use constant AGENT_BUILD => '150722'; use constant AGENT_BUILD => '150723';
# Commands to retrieve total memory information in kB # Commands to retrieve total memory information in kB
use constant TOTALMEMORY_CMDS => { use constant TOTALMEMORY_CMDS => {

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 6.0dev %define version 6.0dev
%define release 150722 %define release 150723
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 6.0dev %define version 6.0dev
%define release 150722 %define release 150723
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{150722} {150723}
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 ("6.0dev(Build 150722)") #define PANDORA_VERSION ("6.0dev(Build 150723)")
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", "(6.0dev(Build 150722))" VALUE "ProductVersion", "(6.0dev(Build 150723))"
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: 6.0dev-150722 Version: 6.0dev-150723
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="6.0dev-150722" pandora_version="6.0dev-150723"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -81,7 +81,7 @@ $table_behaviour->data[$row][1] = html_print_checkbox('paginate_module', 1,
$config['paginate_module'], true); $config['paginate_module'], true);
$row++; $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') . ' ' . $table_behaviour->data[$row][1] = __('Yes') . ' ' .
html_print_radio_button ('render_proc', 1, '', html_print_radio_button ('render_proc', 1, '',
$config["render_proc"], true) . $config["render_proc"], true) .
@ -90,6 +90,15 @@ $table_behaviour->data[$row][1] .= __('No') . ' ' .
html_print_radio_button ('render_proc', 0, '', html_print_radio_button ('render_proc', 0, '',
$config["render_proc"], true); $config["render_proc"], true);
$row++; $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 "<fieldset>";
echo "<legend>" . __('Behaviour configuration') . "</legend>"; echo "<legend>" . __('Behaviour configuration') . "</legend>";
html_print_table ($table_behaviour); html_print_table ($table_behaviour);

View File

@ -903,9 +903,9 @@ if ($list_modules) {
case 21: case 21:
case 31: case 31:
if ($module["datos"]>=1) if ($module["datos"]>=1)
$salida ='OK'; $salida = $config["render_proc_ok"];
else else
$salida = 'FAIL'; $salida = $config["render_proc_fail"];
break; break;
default: default:
$salida = format_numeric($module["datos"]); $salida = format_numeric($module["datos"]);

View File

@ -22,7 +22,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC150722'; $build_version = 'PC150723';
$pandora_version = 'v6.0dev'; $pandora_version = 'v6.0dev';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -468,7 +468,11 @@ function config_update_config () {
if (!config_update_value ('type_module_charts', (string) get_parameter('type_module_charts', 'area'))) if (!config_update_value ('type_module_charts', (string) get_parameter('type_module_charts', 'area')))
$error_update[] = __('Default type of module charts.'); $error_update[] = __('Default type of module charts.');
if (!config_update_value ('render_proc', (bool) get_parameter('render_proc', false))) 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); 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'])) { if (!isset($config['command_snapshot'])) {
config_update_value ('command_snapshot', 1); config_update_value ('command_snapshot', 1);
} }

View File

@ -571,7 +571,11 @@ function reporting_SLA($report, $content, $type = 'dinamic',
$id_agent_modules[] = $sla['id_agent_module']; $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(); $malformed_planned_downtimes = planned_downtimes_get_malformed();
if (!empty($planned_downtimes)) if (!empty($planned_downtimes))
@ -586,7 +590,8 @@ function reporting_SLA($report, $content, $type = 'dinamic',
$data['name'] = $planned_downtime['name']; $data['name'] = $planned_downtime['name'];
$data['description'] = $planned_downtime['description']; $data['description'] = $planned_downtime['description'];
$data['execution'] = ucfirst($planned_downtime['type_execution']); $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; $data['malformed'] = 0;
if (!$malformed_planned_downtimes_empty && isset($malformed_planned_downtimes[$planned_downtime['id']])) { if (!$malformed_planned_downtimes_empty && isset($malformed_planned_downtimes[$planned_downtime['id']])) {
@ -636,6 +641,8 @@ function reporting_SLA($report, $content, $type = 'dinamic',
continue; continue;
} }
//Get the sla_value in % and store it on $sla_value //Get the sla_value in % and store it on $sla_value
$sla_value = reporting_get_agentmodule_sla( $sla_value = reporting_get_agentmodule_sla(
$sla['id_agent_module'], $sla['id_agent_module'],
@ -6367,6 +6374,8 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
global $config; global $config;
if (empty($id_agent_module)) if (empty($id_agent_module))
return false; return false;
@ -6385,8 +6394,11 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
} }
// Calculate the SLA for large time without hours // Calculate the SLA for large time without hours
if ($timeFrom == $timeTo) { if ($timeFrom == $timeTo) {
// Get interval data // Get interval data
$sql = sprintf ('SELECT * $sql = sprintf ('SELECT *
FROM tagente_datos FROM tagente_datos
@ -6438,7 +6450,8 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
} }
// Calculate planned downtime dates // 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 // Get previous data
$previous_data = modules_get_previous_data ($id_agent_module, $datelimit); $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']; $previous_utimestamp = $first_data['utimestamp'];
if ((($max_value > $min_value AND ($first_data['datos'] > $max_value OR $first_data['datos'] < $min_value))) OR if (
($max_value <= $min_value AND $first_data['datos'] < $min_value)) { (
(
$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; $previous_status = 1;
foreach ($downtime_dates as $date_dt) { 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; $previous_status = 0;
} }
} }
@ -6537,13 +6565,14 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
$timeTo); $timeTo);
} }
else { else {
// Extract the data each day // Extract the data each day
$sla = 0; $sla = 0;
$i = 0; $i = 0;
for ($interval = 0; $interval <= $period; $interval = $interval + SECONDS_1DAY) { for ($interval = SECONDS_1DAY; $interval <= $period; $interval = $interval + SECONDS_1DAY) {
$datelimit = $date - $interval;
$sla_day = reporting_get_agentmodule_sla( $sla_day = reporting_get_agentmodule_sla(
$id_agent_module, $id_agent_module,
@ -6555,8 +6584,12 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
$timeFrom, $timeTo); $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; $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 // Limit date to start searching data
$datelimit = $date - $period; $datelimit = $date - $period;
$search_in_history_db = db_search_in_history_db($datelimit); $search_in_history_db = db_search_in_history_db($datelimit);
// Get interval data // Get interval data
$sql = sprintf ('SELECT * $sql = sprintf ('SELECT *
FROM tagente_datos FROM tagente_datos
WHERE id_agente_modulo = %d WHERE id_agente_modulo = %d
AND utimestamp > %d AND utimestamp <= %d', AND utimestamp > %d
AND utimestamp <= %d',
$id_agent_module, $datelimit, $date); $id_agent_module, $datelimit, $date);
//Add the working times (mon - tue - wed ...) and from time to time //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 // 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 // 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) { if ($previous_data !== false) {
$previous_data['utimestamp'] = $datelimit; $previous_data['utimestamp'] = $datelimit;
@ -7548,6 +7585,7 @@ function reporting_get_agentmodule_sla_day ($id_agent_module, $period = 0, $min_
$previous_utimestamp = $data['utimestamp']; $previous_utimestamp = $data['utimestamp'];
} }
// Return the percentage of SLA compliance // Return the percentage of SLA compliance
return (float) (100 - ($bad_period / $period) * 100); return (float) (100 - ($bad_period / $period) * 100);
} }

View File

@ -13,21 +13,22 @@
// 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.
if (! isset($_SESSION['id_usuario'])) {
session_start();
}
require_once('functions.php'); require_once('functions.php');
require_once('functions_filemanager.php'); require_once('functions_filemanager.php');
session_start();
require_once ("config.php"); require_once ("config.php");
global $config; global $config;
check_login ();
$auth_method = db_get_value('value', 'tconfig', 'token', 'auth'); $auth_method = db_get_value('value', 'tconfig', 'token', 'auth');
require_once("auth/" . $auth_method . ".php"); 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;"; $styleError = "background:url(\"../images/err.png\") no-repeat scroll 0 0 transparent; padding:4px 1px 6px 30px; color:#CC0000;";

View File

@ -63,7 +63,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '6.0dev'; $version = '6.0dev';
$build = '150722'; $build = '150723';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -268,7 +268,7 @@ if (!$update_networkmap && !$save_networkmap) {
$group = $networkmap_data['id_group']; $group = $networkmap_data['id_group'];
$module_group = $networkmap_data['id_module_group']; $module_group = $networkmap_data['id_module_group'];
$center = $networkmap_data['center']; $center = $networkmap_data['center'];
$name = $networkmap_data['name']; $name = io_safe_output($networkmap_data['name']);
$activeTab = $networkmap_data['type']; $activeTab = $networkmap_data['type'];
$l2_network = $networkmap_data['l2_network']; $l2_network = $networkmap_data['l2_network'];
} }
@ -435,7 +435,7 @@ $form_elems = array();
// Name // Name
$element = __('Name') . '&nbsp;' . $element = __('Name') . '&nbsp;' .
html_print_input_text ('name', $name, '', 25, 50, true); html_print_input_text ('name', io_safe_output($name), '', 25, 50, true);
if ($activeTab == 'groups') if ($activeTab == 'groups')
$element .= clippy_context_help("topology_group"); $element .= clippy_context_help("topology_group");
$form_elems[] = $element; $form_elems[] = $element;

View File

@ -217,7 +217,7 @@ else {
$data = array(); $data = array();
$data[0] = '<b><a href="index.php?sec=network&sec2=operation/agentes/networkmap&tab=' . $network_map['type'] $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[1] = $network_map['type'];
$data[2] = ui_print_group_icon ($network_map['store_group'], true); $data[2] = ui_print_group_icon ($network_map['store_group'], true);

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 6.0dev %define version 6.0dev
%define release 150722 %define release 150723
# 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 6.0dev %define version 6.0dev
%define release 150722 %define release 150723
%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

@ -39,7 +39,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('step_compact','1'), ('step_compact','1'),
('db_scheme_first_version', '6.0dev'), ('db_scheme_first_version', '6.0dev'),
('db_scheme_version','6.0dev'), ('db_scheme_version','6.0dev'),
('db_scheme_build','PD150722'), ('db_scheme_build','PD150723'),
('show_unknown','0'), ('show_unknown','0'),
('show_lastalerts','1'), ('show_lastalerts','1'),
('style','pandora'), ('style','pandora'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 6.0dev-150722 Version: 6.0dev-150723
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="6.0dev-150722" pandora_version="6.0dev-150723"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -43,7 +43,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 = "6.0dev"; my $pandora_version = "6.0dev";
my $pandora_build = "150722"; my $pandora_build = "150723";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -34,6 +34,7 @@ our @EXPORT = qw(
add_new_address_agent add_new_address_agent
db_concat db_concat
db_connect db_connect
db_delete_limit
db_disconnect db_disconnect
db_do db_do
db_get_lock db_get_lock
@ -638,9 +639,9 @@ sub get_db_value_limit ($$$;@) {
# Cache statements # Cache statements
my $sth; my $sth;
if ($RDBMS ne 'oracle') { if ($RDBMS ne 'oracle') {
$sth = $dbh->prepare_cached($query . ' LIMIT ' . $limit); $sth = $dbh->prepare_cached($query . ' LIMIT ' . int($limit));
} else { } 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); $sth->execute(@values);
@ -739,6 +740,29 @@ sub get_db_rows_limit ($$$;@) {
return @rows; 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. ## SQL insert. Returns the ID of the inserted row.
########################################################################## ##########################################################################
@ -1109,7 +1133,10 @@ sub db_insert_get_values ($) {
######################################################################## ########################################################################
sub db_get_lock($$;$) { sub db_get_lock($$;$) {
my ($dbh, $lock_name, $lock_timeout) = @_; my ($dbh, $lock_name, $lock_timeout) = @_;
# Only supported in MySQL.
return 1 unless ($RDBMS eq 'mysql');
# Set a default lock timeout of 1 second # Set a default lock timeout of 1 second
$lock_timeout = 1 if (! defined ($lock_timeout)); $lock_timeout = 1 if (! defined ($lock_timeout));
@ -1130,6 +1157,9 @@ sub db_get_lock($$;$) {
sub db_release_lock($$) { sub db_release_lock($$) {
my ($dbh, $lock_name) = @_; my ($dbh, $lock_name) = @_;
# Only supported in MySQL.
return unless ($RDBMS eq 'mysql');
my $sth = $dbh->prepare('SELECT RELEASE_LOCK(?)'); my $sth = $dbh->prepare('SELECT RELEASE_LOCK(?)');
$sth->execute($lock_name); $sth->execute($lock_name);
my ($lock) = $sth->fetchrow; my ($lock) = $sth->fetchrow;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 6.0dev %define version 6.0dev
%define release 150722 %define release 150723
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 6.0dev %define version 6.0dev
%define release 150722 %define release 150723
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -53,7 +53,7 @@ pandora_init(\%conf);
pandora_load_config (\%conf); pandora_load_config (\%conf);
# Connect to the DB # 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'}, 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; $conf{'_history_db_host'}, '3306', $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "6.0dev PS150722"; my $version = "6.0dev PS150723";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;
@ -87,7 +87,7 @@ sub pandora_purgedb ($$) {
# Delete extended session data # Delete extended session data
if (enterprise_load (\%conf) != 0) { if (enterprise_load (\%conf) != 0) {
db_do ($dbh, "DELETE FROM tsesion_extended 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.'); log_message ('PURGE', 'Deleting old extended session data.');
} }
@ -113,7 +113,7 @@ sub pandora_purgedb ($$) {
# steps (100 fixed by default) # steps (100 fixed by default)
# Starting from the oldest record on the table # 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)) { if (defined ($first_mark)) {
$total_time = $ulimit_timestamp - $first_mark; $total_time = $ulimit_timestamp - $first_mark;
$purge_steps = int($total_time / $BIG_OPERATION_STEP); $purge_steps = int($total_time / $BIG_OPERATION_STEP);
@ -137,7 +137,7 @@ sub pandora_purgedb ($$) {
# #
# Now the log4x data # 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)) { if (defined ($first_mark)) {
$total_time = $ulimit_timestamp - $first_mark; $total_time = $ulimit_timestamp - $first_mark;
$purge_steps = int($total_time / $BIG_OPERATION_STEP); $purge_steps = int($total_time / $BIG_OPERATION_STEP);
@ -206,7 +206,7 @@ sub pandora_purgedb ($$) {
# Delete with buffer to avoid problems with performance # 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); my $events_to_delete = get_db_value ($dbh, "SELECT COUNT(*) FROM $events_table WHERE utimestamp < ?", $event_limit);
while($events_to_delete > 0) { 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; $events_to_delete = $events_to_delete - $BIG_OPERATION_STEP;
# Mark the progress # Mark the progress
@ -222,7 +222,7 @@ sub pandora_purgedb ($$) {
log_message ('PURGE', "Deleting validated events from tmetaconsole_event_history.", ''); 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"); $events_to_delete = get_db_value ($dbh, "SELECT COUNT(*) FROM tmetaconsole_event_history WHERE estado = 1");
while($events_to_delete > 0) { 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; $events_to_delete = $events_to_delete - $BIG_OPERATION_STEP;
# Mark the progress # 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); my $nstate = get_db_value ($dbh, 'SELECT count(id_agente_modulo) FROM tagente_estado WHERE id_agente_modulo=?', $id_module);
last if($nstate == 0); 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"); log_message ('', "\n");
@ -303,7 +303,7 @@ sub pandora_purgedb ($$) {
log_message ('PURGE', "Deleting old access data (More than 24hr)"); 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)) { if (defined ($first_mark)) {
$total_time = $ulimit_access_timestamp - $first_mark; $total_time = $ulimit_access_timestamp - $first_mark;
$purge_steps = int( $total_time / $BIG_OPERATION_STEP); $purge_steps = int( $total_time / $BIG_OPERATION_STEP);
@ -339,31 +339,31 @@ sub pandora_purgedb ($$) {
db_do ($dbh, "DELETE FROM treport_content db_do ($dbh, "DELETE FROM treport_content
WHERE id_agent_module != 0 WHERE id_agent_module != 0
AND id_agent_module NOT IN (SELECT id_agente_modulo FROM tagente_modulo) 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 db_do ($dbh, "DELETE FROM treport_content_item
WHERE id_agent_module != 0 WHERE id_agent_module != 0
AND id_agent_module NOT IN (SELECT id_agente_modulo FROM tagente_modulo) 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 db_do ($dbh, "DELETE FROM treport_content_sla_combined
WHERE id_agent_module != 0 WHERE id_agent_module != 0
AND id_agent_module NOT IN (SELECT id_agente_modulo FROM tagente_modulo) 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 # Deleted agents
log_message ('PURGE', "Delete contents in report that have some deleted agents."); log_message ('PURGE', "Delete contents in report that have some deleted agents.");
db_do ($dbh, "DELETE FROM treport_content db_do ($dbh, "DELETE FROM treport_content
WHERE id_agent != 0 WHERE id_agent != 0
AND id_agent NOT IN (SELECT id_agente FROM tagente) 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 # Empty contents
log_message ('PURGE', "Delete empty contents in report (like SLA or Exception)."); log_message ('PURGE', "Delete empty contents in report (like SLA or Exception).");
db_do ($dbh, "DELETE FROM treport_content db_do ($dbh, "DELETE FROM treport_content
WHERE type LIKE 'exception' WHERE ${RDBMS_QUOTE}type${RDBMS_QUOTE} LIKE 'exception'
AND id_rc NOT IN (SELECT id_report_content FROM treport_content_item);"); AND id_rc NOT IN (SELECT id_report_content FROM treport_content_item)");
db_do ($dbh, "DELETE FROM treport_content db_do ($dbh, "DELETE FROM treport_content
WHERE type IN ('SLA', 'SLA_monthly', 'SLA_services') 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);"); 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 # 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 ! # 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)) { if (defined ($first_mark)) {
$total_time = $ulimit_timestamp - $first_mark; $total_time = $ulimit_timestamp - $first_mark;
$purge_steps = int($total_time / $BIG_OPERATION_STEP); $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 # 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"); $purge_count = get_db_value ($dbh, "SELECT COUNT(id_agente_modulo) FROM $table WHERE utimestamp < $mark1 AND utimestamp >= $mark2");
while ($purge_count > 0){ 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 # Do a nanosleep here for 0,001 sec
usleep (10000); usleep (10000);
$purge_count = $purge_count - $SMALL_OPERATION_STEP; $purge_count = $purge_count - $SMALL_OPERATION_STEP;
@ -950,7 +950,8 @@ sub pandora_delete_old_export_data {
my ($dbh, $ulimit_timestamp) = @_; my ($dbh, $ulimit_timestamp) = @_;
log_message ('PURGE', "Deleting old export data from tserver_export_data\n"); 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); usleep (10000);
}; };
} }
@ -962,7 +963,7 @@ sub pandora_delete_old_session_data {
my ($dbh, $ulimit_timestamp) = @_; my ($dbh, $ulimit_timestamp) = @_;
log_message ('PURGE', "Deleting old session data from tsessions_php\n"); 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); usleep (10000);
}; };
} }
@ -1019,7 +1020,7 @@ else {
} }
# Connect to the DB # 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'}, 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; $conf{'_history_db_host'}, '3306', $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;

View File

@ -35,7 +35,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "6.0dev PS150722"; my $version = "6.0dev PS150723";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);