mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
2008-07-23 Sancho Lerena <slerena@gmail.com>
* Makefile.PL: Removed reference to export_server. * DB.pm: Fixed bug that causes to do not store string data. Added checks for aviod null text and skip max/min checks for string types. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@972 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
aa70fc0287
commit
574f8dd2e9
@ -1,3 +1,10 @@
|
|||||||
|
2008-07-23 Sancho Lerena <slerena@gmail.com>
|
||||||
|
|
||||||
|
* Makefile.PL: Removed reference to export_server.
|
||||||
|
|
||||||
|
* DB.pm: Fixed bug that causes to do not store string data. Added checks
|
||||||
|
for aviod null text and skip max/min checks for string types.
|
||||||
|
|
||||||
2008-07-22 Sancho Lerena <slerena@gmail.com>
|
2008-07-22 Sancho Lerena <slerena@gmail.com>
|
||||||
|
|
||||||
* pandora_network: Minimal style changes. Added status change in
|
* pandora_network: Minimal style changes. Added status change in
|
||||||
|
@ -22,7 +22,7 @@ WriteMakefile(
|
|||||||
SNMP => 0
|
SNMP => 0
|
||||||
},
|
},
|
||||||
EXE_FILES =>
|
EXE_FILES =>
|
||||||
[ 'bin/pandora_server', 'bin/pandora_network', 'bin/pandora_recon', 'bin/pandora_snmpconsole' , 'bin/pandora_plugin', 'bin/pandora_export', 'bin/pandora_prediction'],
|
[ 'bin/pandora_server', 'bin/pandora_network', 'bin/pandora_recon', 'bin/pandora_snmpconsole' , 'bin/pandora_plugin', 'bin/pandora_prediction'],
|
||||||
PMLIBDIRS => [ 'lib' ],
|
PMLIBDIRS => [ 'lib' ],
|
||||||
'dist' => { 'TAR' => 'tar', 'TARFLAGS' => 'cvfz', 'SUFFIX'
|
'dist' => { 'TAR' => 'tar', 'TARFLAGS' => 'cvfz', 'SUFFIX'
|
||||||
=> '.gz', 'COMPRESS' => 'gzip'}
|
=> '.gz', 'COMPRESS' => 'gzip'}
|
||||||
|
@ -596,10 +596,21 @@ sub pandora_writestate (%$$$$$$$) {
|
|||||||
my $id_agente = dame_agente_id ($pa_config, $nombre_agente, $dbh);
|
my $id_agente = dame_agente_id ($pa_config, $nombre_agente, $dbh);
|
||||||
my $id_modulo = dame_modulo_id ($pa_config, $tipo_modulo, $dbh);
|
my $id_modulo = dame_modulo_id ($pa_config, $tipo_modulo, $dbh);
|
||||||
my $id_agente_modulo = dame_agente_modulo_id($pa_config, $id_agente, $id_modulo, $nombre_modulo, $dbh);
|
my $id_agente_modulo = dame_agente_modulo_id($pa_config, $id_agente, $id_modulo, $nombre_modulo, $dbh);
|
||||||
|
|
||||||
|
# Valid agent ?
|
||||||
if (($id_agente == -1) || ($id_agente_modulo == -1)) {
|
if (($id_agente == -1) || ($id_agente_modulo == -1)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Valid string data ? (not null)
|
||||||
|
if (($id_modulo == 3) || ($id_modulo == 17) || ($id_modulo == 10) || ($id_modulo == 23)){
|
||||||
|
if ($datos eq "") {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
my $id_grupo = dame_grupo_agente($pa_config, $id_agente,$dbh);
|
my $id_grupo = dame_grupo_agente($pa_config, $id_agente,$dbh);
|
||||||
|
|
||||||
# Seek for agent_interval or module_interval
|
# Seek for agent_interval or module_interval
|
||||||
@ -1068,13 +1079,23 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||||||
if (!defined($min)){
|
if (!defined($min)){
|
||||||
$min = "0";
|
$min = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Obtenemos los identificadores
|
# Obtenemos los identificadores
|
||||||
my $id_agente = dame_agente_id ($pa_config, $nombre_agente,$dbh);
|
my $id_agente = dame_agente_id ($pa_config, $nombre_agente,$dbh);
|
||||||
# Check if exists module and agent_module reference in DB, if not, and learn mode activated, insert module in DB
|
|
||||||
|
# Check if exists module and agent_module reference in DB,
|
||||||
|
# if not, and learn mode activated, insert module in DB
|
||||||
if ($id_agente eq "-1"){
|
if ($id_agente eq "-1"){
|
||||||
goto fin_DB_insert_datos;
|
goto fin_DB_insert_datos;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $id_modulo = dame_modulo_id($pa_config, $tipo_modulo,$dbh);
|
my $id_modulo = dame_modulo_id($pa_config, $tipo_modulo,$dbh);
|
||||||
|
if (($id_modulo == 3) || ($id_modulo == 17) || ($id_modulo == 10) || ($id_modulo == 23)){
|
||||||
|
if ($datos eq "") {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $id_agente_modulo = dame_agente_modulo_id($pa_config, $id_agente, $id_modulo, $nombre_modulo,$dbh);
|
my $id_agente_modulo = dame_agente_modulo_id($pa_config, $id_agente, $id_modulo, $nombre_modulo,$dbh);
|
||||||
# Pandora 1.3. Now uses integer to store timestamp in datatables
|
# Pandora 1.3. Now uses integer to store timestamp in datatables
|
||||||
# much more faster to do comparations...
|
# much more faster to do comparations...
|
||||||
@ -1087,6 +1108,10 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||||||
|
|
||||||
# take max and min values for this id_agente_module
|
# take max and min values for this id_agente_module
|
||||||
if ($id_agente_modulo != -1){ # ID AgenteModulo does exists
|
if ($id_agente_modulo != -1){ # ID AgenteModulo does exists
|
||||||
|
|
||||||
|
# Postprocess and get MAX/MIN only for numeric moduletypes
|
||||||
|
|
||||||
|
if (($id_modulo != 3) && ($id_modulo != 17) && ($id_modulo != 10) && ($id_modulo != 23)){
|
||||||
my $query_idag = "SELECT * FROM tagente_modulo WHERE id_agente = $id_agente AND id_agente_modulo = ".$id_agente_modulo;
|
my $query_idag = "SELECT * FROM tagente_modulo WHERE id_agente = $id_agente AND id_agente_modulo = ".$id_agente_modulo;
|
||||||
my $s_idag = $dbh->prepare($query_idag);
|
my $s_idag = $dbh->prepare($query_idag);
|
||||||
$s_idag ->execute;
|
$s_idag ->execute;
|
||||||
@ -1101,12 +1126,13 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||||||
|
|
||||||
# Postprocess
|
# Postprocess
|
||||||
if (($data[23] != 0) && (is_numeric($data[23]))){
|
if (($data[23] != 0) && (is_numeric($data[23]))){
|
||||||
if (($id_modulo == 1) || ($id_modulo == 7) || ($id_modulo == 15) || ($id_modulo == 22) || ($id_modulo == 4) || ($id_modulo == 8) || ($id_modulo == 16) ){
|
|
||||||
$datos = $datos * $data[23];
|
$datos = $datos * $data[23];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$s_idag->finish();
|
$s_idag->finish();
|
||||||
|
} else {
|
||||||
|
$max = "";
|
||||||
|
$min = "";
|
||||||
|
}
|
||||||
} else { # Id AgenteModulo DOESNT exist, it could need to be created...
|
} else { # Id AgenteModulo DOESNT exist, it could need to be created...
|
||||||
if (dame_learnagente($pa_config, $id_agente, $dbh) eq "1" ){
|
if (dame_learnagente($pa_config, $id_agente, $dbh) eq "1" ){
|
||||||
# Try to write a module and agent_module definition for that datablock
|
# Try to write a module and agent_module definition for that datablock
|
||||||
@ -1114,7 +1140,7 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||||||
$id_agente_modulo = crea_agente_modulo ($pa_config, $nombre_agente, $tipo_modulo, $nombre_modulo, $max, $min, $descripcion, $dbh);
|
$id_agente_modulo = crea_agente_modulo ($pa_config, $nombre_agente, $tipo_modulo, $nombre_modulo, $max, $min, $descripcion, $dbh);
|
||||||
$needscreate = 1; # Really needs to be created
|
$needscreate = 1; # Really needs to be created
|
||||||
} else {
|
} else {
|
||||||
logger( $pa_config, "VERBOSE: pandora_insertdata cannot find module definition ($nombre_modulo / $tipo_modulo )for agent $nombre_agente - Use LEARN MODE for autocreate.",2);
|
logger( $pa_config, "VERBOSE: pandora_insertdata cannot find module definition ($nombre_modulo / $tipo_modulo )for agent $nombre_agente - Use LEARN MODE for autocreate.", 3);
|
||||||
goto fin_DB_insert_datos;
|
goto fin_DB_insert_datos;
|
||||||
}
|
}
|
||||||
} # Module exists or has been created
|
} # Module exists or has been created
|
||||||
@ -1146,6 +1172,7 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||||||
# 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
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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){
|
||||||
$needsupdate = 1;
|
$needsupdate = 1;
|
||||||
@ -1199,7 +1226,7 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||||||
$timestamp = $dbh->quote($timestamp);
|
$timestamp = $dbh->quote($timestamp);
|
||||||
# Parse data entry for adecuate SQL representation.
|
# 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)";
|
$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 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);
|
||||||
@ -1207,7 +1234,6 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||||||
$dbh->do($query); # Makes insertion in database
|
$dbh->do($query); # Makes insertion in database
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fin_DB_insert_datos:
|
fin_DB_insert_datos:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user