From aabc528c01696c1bdff1ed73c89230d7e74f6c61 Mon Sep 17 00:00:00 2001 From: jsatoh Date: Tue, 12 Aug 2014 01:07:29 +0000 Subject: [PATCH] 2014-08-12 Junichi Satoh * lib/PandoraFMS/Core.pm, lib/PandoraFMS/DataServer.pm: Fixed sql error with MySQL 5.6 and its default sql_mode. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10400 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/lib/PandoraFMS/Core.pm | 10 +++++----- pandora_server/lib/PandoraFMS/DataServer.pm | 7 +++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 3780992851..d226834d0f 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2014-08-12 Junichi Satoh + + * lib/PandoraFMS/Core.pm, lib/PandoraFMS/DataServer.pm: Fixed sql + error with MySQL 5.6 and its default sql_mode. + 2014-08-11 Hirofumi Kosaka * lib/PandoraFMS/Core.pm: Fixed modules would have ignored diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index d11c14e440..2eb80a0935 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -2341,11 +2341,11 @@ sub pandora_create_module ($$$$$$$$$$) { } my $module_id = db_insert($dbh, 'id_agente_modulo', - 'INSERT INTO tagente_modulo (id_agente, id_tipo_modulo, nombre, max, min, post_process, descripcion, module_interval, id_modulo) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1)', + 'INSERT INTO tagente_modulo (id_agente, id_tipo_modulo, nombre, max, min, post_process, descripcion, module_interval, id_modulo, critical_instructions, warning_instructions, unknown_instructions, disabled_types_event, module_macros) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, \'\', \'\', \'\', \'\', \'\')', $agent_id, $module_type_id, safe_input($module_name), $max, $min, $post_process, $description, $interval); - db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try) - VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\')', + db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try, datos) + VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\', \'\')', $module_id, $agent_id, $status, $status, $status); # Update the module status count. When the module is created disabled dont do it @@ -2466,7 +2466,7 @@ sub pandora_create_module_from_hash ($$$) { $status = 0; } - db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try) VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\')', $module_id, $parameters->{'id_agente'}, $status, $status, $status); + db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try, datos) VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\', \'\')', $module_id, $parameters->{'id_agente'}, $status, $status, $status); # Update the module status count. When the module is created disabled dont do it pandora_mark_agent_for_module_update ($dbh, $parameters->{'id_agente'}); diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index f88437d0b6..320084eafc 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -556,6 +556,13 @@ sub process_module_data ($$$$$$$$$) { # Allow , as a decimal separator $module_conf->{'post_process'} =~ s/,/./ if (defined ($module_conf->{'post_process'})); + + # avoid NULL columns + $module_conf->{'critical_instructions'} = '' unless defined ($module_conf->{'critical_instructions'}); + $module_conf->{'warning_instructions'} = '' unless defined ($module_conf->{'warning_instructions'}); + $module_conf->{'unknown_instructions'} = '' unless defined ($module_conf->{'unknown_instructions'}); + $module_conf->{'disabled_types_event'} = '' unless defined ($module_conf->{'disabled_types_event'}); + $module_conf->{'module_macros'} = '' unless defined ($module_conf->{'module_macros'}); # Get module data or create it if it does not exist $ModuleSem->down ();