From f0cab8a3d2da1c64bc9a1e3d90d5560cc4fe4901 Mon Sep 17 00:00:00 2001 From: ramonn Date: Thu, 23 Apr 2009 09:20:46 +0000 Subject: [PATCH] 2009-04-23 Ramon Novoa * lib/PandoraFMS/Core.pm: Fixed *inc data processing. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1650 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 4 ++++ pandora_server/lib/PandoraFMS/Core.pm | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 60de8dbc93..3a9d10bc09 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,7 @@ +2009-04-23 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Fixed *inc data processing. + 2009-04-22 Ramon Novoa * lib/PandoraFMS/SNMPServer.pm: Fixed SNMP alerts. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index d23aca112d..04b1e26a30 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1024,9 +1024,21 @@ sub process_inc_data ($$$$) { return undef; } + # Negative increment, reset inc data + if ($data < $data_inc->{'datos'}) { + db_do ($dbh, 'DELETE FROM tagente_datos_inc WHERE id_agente_modulo = ?', $module->{'id_agente_modulo'}); + db_insert ($dbh, 'INSERT INTO tagente_datos_inc + (`id_agente_modulo`, `datos`, `utimestamp`) + VALUES (?, ?, ?)', $module->{'id_agente_modulo'}, $data, $utimestamp); + return undef; + } + # Should not happen return 0 if ($utimestamp == $data_inc->{'utimestamp'}); + # Update inc data + db_do ($dbh, 'UPDATE tagente_datos_inc SET datos = ?, utimestamp = ? WHERE id_agente_modulo = ?', $data, $utimestamp, $module->{'id_agente_modulo'}); + return ($data - $data_inc->{'datos'}) / ($utimestamp - $data_inc->{'utimestamp'}); }