2008-10-20 Esteban Sanchez <estebans@artica.es>

* lib/PandoraFMS/DB.pm: Fixed a strange bug that was causing to
	generate events of servers going down, the solution was to update
	own keepalive before checking others server status. Tab style
	correction, replacing blankspaces with tab.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1173 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
esanchezm 2008-10-20 10:43:21 +00:00
parent 38df3554bc
commit b46fab2e7f
2 changed files with 507 additions and 498 deletions

View File

@ -1,3 +1,10 @@
2008-10-20 Esteban Sanchez <estebans@artica.es>
* lib/PandoraFMS/DB.pm: Fixed a strange bug that was causing to
generate events of servers going down, the solution was to update
own keepalive before checking others server status. Tab style
correction, replacing blankspaces with tab.
2008-10-20 Manuel Arostegui <marostegui@artica.es>
* pandora_server_installer: Added dependency

View File

@ -22,7 +22,7 @@ use warnings;
use Time::Local;
use Time::Format qw(%time %strftime %manip); # For data mangling
use DBI;
use Date::Manip; # Needed to manipulate DateTime formats of input, output and compare
use Date::Manip;# Needed to manipulate DateTime formats of input, output and compare
use XML::Simple;
use HTML::Entities;
@ -834,9 +834,9 @@ sub module_generic_proc (%$$$$$) {
my $a_datos = $datos->{data}->[0];
if ((ref($a_datos) eq "HASH")){
$a_datos = 0; # If get bad data, then this is bad value, not "unknown" (> 1.3 version)
$a_datos = 0;# If get bad data, then this is bad value, not "unknown" (> 1.3 version)
} else {
$a_datos = sprintf("%.2f", $a_datos); # Two decimal float. We cannot store more
$a_datos = sprintf("%.2f", $a_datos);# Two decimal float. We cannot store more
} # to change this, you need to change mysql structure
$a_datos =~ s/\,/\./g; # replace "," by "." avoiding locale problems
my $a_name = $datos->{name}->[0];
@ -902,7 +902,7 @@ sub module_generic_data (%$$$$$) {
}
if ($m_data =~ /[0-9]*/){
$m_data =~ s/\,/\./g; # replace "," by "."
$m_data = sprintf("%.2f", $m_data); # Two decimal float. We cannot store more
$m_data = sprintf("%.2f", $m_data);# Two decimal float. We cannot store more
} else {
$m_data =0;
}
@ -949,7 +949,7 @@ sub module_generic_data_inc (%$$$$$) {
my $a_min = $datos->{min}->[0];
if (is_numeric($m_data)){
$m_data =~ s/\,/\./g; # replace "," by "."
$m_data = sprintf("%.2f", $m_data); # Two decimal float. We cannot store more
$m_data = sprintf("%.2f", $m_data);# Two decimal float. We cannot store more
# to change this, you need to change mysql structure
$m_data =~ s/\,/\./g; # replace "," by "."
@ -1292,6 +1292,9 @@ sub pandora_serverkeepaliver (%$$) {
my @data;
my $err;
# First of all, update our keepalive
pandora_updateserver ($pa_config, $pa_config->{'servername'}, 1, $opmode, $dbh);
my $temp = $pa_config->{"keepalive"} - $pa_config->{"server_threshold"};
if ($temp <= 0){
@ -1299,8 +1302,7 @@ sub pandora_serverkeepaliver (%$$) {
$temp = $pa_config->{"keepalive_orig"} * 2; # Down if keepalive x 2 seconds unknown
my $fecha_limite = DateCalc($timestamp,"- $temp seconds",\$err);
$fecha_limite = &UnixDate($fecha_limite,"%Y-%m-%d %H:%M:%S");
# Look updated servers and take down non updated servers
my $query_idag = "select * from tserver where keepalive < '$fecha_limite'";
my $query_idag = "SELECT * FROM tserver WHERE keepalive < '$fecha_limite'";
my $s_idag = $dbh->prepare($query_idag);
$s_idag ->execute;
if ($s_idag->rows != 0) {
@ -1321,7 +1323,6 @@ sub pandora_serverkeepaliver (%$$) {
}
$s_idag->finish();
# Update my server
pandora_updateserver ($pa_config, $pa_config->{'servername'}, 1, $opmode, $dbh);
$pa_config->{"keepalive"} = $pa_config->{"keepalive_orig"};
}
$pa_config->{"keepalive"} = $pa_config->{"keepalive"} - $pa_config->{"server_threshold"};
@ -2269,3 +2270,4 @@ sub export_module_data {
1;
__END__
# Look updated servers and take down non updated servers