2007-05-07 Sancho Lerena <slerena@artica.es>

* bin/pandora_db.pm: Fixed some problems with quotes and other aditional
	checks.

	* bin/pandora_network.pl: Fixed some problems with quotes and other
	aditional checks.  Detected a serious BUG in snmplib for Ubuntu Freeze
	(already submitted as detected BUG with veryhigh priority). This makes
	pandora network server unusable on feisty until fixed :(. Bug item is in
	https://bugs.launchpad.net/ubuntu/+source/net-snmp/+bug/65047



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@452 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2007-05-07 11:45:01 +00:00
parent ffe699680a
commit 15dc48e9ac
3 changed files with 61 additions and 25 deletions

View File

@ -1,3 +1,14 @@
2007-05-07 Sancho Lerena <slerena@artica.es>
* bin/pandora_db.pm: Fixed some problems with quotes and other aditional
checks.
* bin/pandora_network.pl: Fixed some problems with quotes and other
aditional checks. Detected a serious BUG in snmplib for Ubuntu Freeze
(already submitted as detected BUG with veryhigh priority). This makes
pandora network server unusable on feisty until fixed :(. Bug item is in
https://bugs.launchpad.net/ubuntu/+source/net-snmp/+bug/65047
2007-05-07 Sancho Lerena <slerena@artica.es> 2007-05-07 Sancho Lerena <slerena@artica.es>
* bin/pandora_db.pm: Fixed BUG #1714003 for data_inc unit division * bin/pandora_db.pm: Fixed BUG #1714003 for data_inc unit division

View File

@ -544,8 +544,13 @@ sub module_generic_data (%$$$$$) {
my $m_name = $datos->{name}->[0]; my $m_name = $datos->{name}->[0];
my $a_desc = $datos->{description}->[0]; my $a_desc = $datos->{description}->[0];
my $m_data = $datos->{data}->[0]; my $m_data = $datos->{data}->[0];
my $bUpdateDatos = 0; # added, patch submitted by Dassing my $bUpdateDatos = 0; # added, patch submitted by Dassing
if (ref($m_data) ne "HASH"){ if (ref($m_data) ne "HASH"){
if (!is_numeric($m_data)){
logger($pa_config, "(data) Invalid data (non-numeric) received from $agent_name, module $m_name", 1);
return -1;
}
if ($m_data =~ /[0-9]*/){ if ($m_data =~ /[0-9]*/){
$m_data =~ s/\,/\./g; # replace "," by "." $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
@ -628,7 +633,7 @@ sub module_generic_data_inc (%$$$$$) {
my $need_reset = 0; my $need_reset = 0;
my $need_update = 0; my $need_update = 0;
my $new_data = 0; my $new_data = 0;
my $data_anterior; my $data_anterior = 0;
my $timestamp_diferencia; my $timestamp_diferencia;
my $timestamp_anterior; my $timestamp_anterior;
my $m_utimestamp = &UnixDate ($m_timestamp, "%s"); my $m_utimestamp = &UnixDate ($m_timestamp, "%s");
@ -647,7 +652,7 @@ sub module_generic_data_inc (%$$$$$) {
$diferencia = $m_data - $data_anterior; $diferencia = $m_data - $data_anterior;
$timestamp_diferencia = $m_utimestamp - $timestamp_anterior; $timestamp_diferencia = $m_utimestamp - $timestamp_anterior;
# get seconds between last data and this data # get seconds between last data and this data
if ($diferencia > 0){ if (($timestamp_diferencia > 0) && ($diferencia > 0)) {
$diferencia = $diferencia / $timestamp_diferencia; $diferencia = $diferencia / $timestamp_diferencia;
} }
if ($diferencia < 0 ){ if ($diferencia < 0 ){
@ -804,12 +809,12 @@ sub pandora_writedata (%$$$$$$$$$$){
if ($tipo_modulo =~ /string/){ if ($tipo_modulo =~ /string/){
$datos = $datos; # No change $datos = $datos; # No change
} else { # Numeric change to real } else { # Numeric change to real
$datos =~ s/\,/\./g; # replace "," by "."
$data[2] =~ s/\,/\./g; # replace "," by "."
$datos = sprintf("%.2f", $datos); $datos = sprintf("%.2f", $datos);
$data[2] = sprintf("%.2f", $data[2]); $data[2] = sprintf("%.2f", $data[2]);
# Two decimal float. We cannot store more # Two decimal float. We cannot store more
# to change this, you need to change mysql structure # to change this, you need to change mysql structure
$datos =~ s/\,/\./g; # replace "," by "."
$data[2] =~ s/\,/\./g; # replace "," by "."
} }
# Detect changes between stored data and adquired data. # Detect changes between stored data and adquired data.
if ($data[2] ne $datos){ if ($data[2] ne $datos){
@ -842,8 +847,10 @@ sub pandora_writedata (%$$$$$$$$$$){
$$Ref_bUpdateDatos = 1; # true $$Ref_bUpdateDatos = 1; # true
} }
if ($tipo_modulo =~ /string/) { # String module types if ($tipo_modulo =~ /string/) { # String module types
$datos = $dbh->quote($datos); # Parse data entry for adecuate SQL representation. $datos = $dbh->quote($datos);
$query = "insert into tagente_datos_string (id_agente_modulo,datos,timestamp,utimestamp,id_agente) VALUES ($id_agente_modulo,$datos,'$timestamp',$utimestamp,$id_agente)"; $timestamp = $dbh->quote($timestamp);
# Parse data entry for adecuate SQL representation.
$query = "INSERT INTO tagente_datos_string (id_agente_modulo, datos, timestamp, utimestamp, id_agente) VALUES ($id_agente_modulo, $datos, $timestamp, $utimestamp, $id_agente)";
} else { } else {
if ($max != $min) { if ($max != $min) {
if ($datos > $max) { if ($datos > $max) {
@ -857,8 +864,11 @@ sub pandora_writedata (%$$$$$$$$$$){
logger($pa_config, "DEBUG: MIN Value reached ($min) for agent $nombre_agente / $nombre_modulo",6); logger($pa_config, "DEBUG: MIN Value reached ($min) for agent $nombre_agente / $nombre_modulo",6);
} }
} }
$query = "insert into tagente_datos (id_agente_modulo, datos,timestamp, utimestamp, id_agente) VALUES ($id_agente_modulo, $datos, '$timestamp', $utimestamp, $id_agente)"; $datos = $dbh->quote($datos);
} # If data is out of limits, do not insert into database (Thanks for David Villanueva for his words) $timestamp = $dbh->quote($timestamp);
# Parse data entry for adecuate SQL representation.
$query = "INSERT INTO tagente_datos (id_agente_modulo, datos, timestamp, utimestamp, id_agente) VALUES ($id_agente_modulo, $datos, $timestamp, $utimestamp, $id_agente)";
} # If data is out of limits, do not insert into database
if ($outlimit == 0){ if ($outlimit == 0){
logger($pa_config, "DEBUG: pandora_insertdata Calculado id_agente_modulo a $id_agente_modulo",6); logger($pa_config, "DEBUG: pandora_insertdata Calculado id_agente_modulo a $id_agente_modulo",6);
logger($pa_config, "DEBUG: pandora_insertdata SQL : $query",10); logger($pa_config, "DEBUG: pandora_insertdata SQL : $query",10);

View File

@ -319,12 +319,27 @@ sub pandora_network_subsystem {
# pandora_ping_icmp (destination, timeout) - Do a ICMP scan, 1 if alive, 0 if not # pandora_ping_icmp (destination, timeout) - Do a ICMP scan, 1 if alive, 0 if not
############################################################################## ##############################################################################
sub pandora_ping_icmp { sub pandora_ping_icmp {
my $p;
my $dest = $_[0]; my $dest = $_[0];
my $l_timeout = $_[1]; my $l_timeout = $_[1];
# temporal vars.
my $result = 0;
my $p;
# Check for valid destination
if (!defined($dest)) {
return 0;
}
$p = Net::Ping->new("icmp",$l_timeout); $p = Net::Ping->new("icmp",$l_timeout);
if ($p->ping($dest) == 1) { $result = $p->ping($dest);
# Check for valid result
if (!defined($result)) {
return 0;
}
# Lets see the result
if ($result == 1) {
$p->close(); $p->close();
return 1; return 1;
} else { } else {