From a8a528965267d59458738d79f99d000f4c14eaf0 Mon Sep 17 00:00:00 2001 From: marcos Date: Tue, 28 Sep 2021 09:31:06 +0200 Subject: [PATCH] update agent custom fields --- pandora_server/lib/PandoraFMS/Core.pm | 12 ++++++++++++ pandora_server/util/pandora_manage.pl | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index e1ee218876..c494682f08 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -242,6 +242,7 @@ our @EXPORT = qw( pandora_update_agent_module_count pandora_update_config_token pandora_update_agent_custom_field + pandora_select_id_custom_field pandora_update_gis_data pandora_update_module_on_error pandora_update_module_from_hash @@ -3407,6 +3408,17 @@ sub pandora_update_config_token ($$$) { return $result; } +########################################################################## +## Select custom field id by name tagent_custom_field +########################################################################## +sub pandora_select_id_custom_field ($$) { + my ($dbh, $field) = @_; + my $result = undef; + + $result = get_db_single_row ($dbh, 'SELECT id_field FROM tagent_custom_fields WHERE name = ? ', safe_input($field)); + + return $result; +} ########################################################################## ## Update a custom field from agent of tagent_custom_data diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 97058e741d..f58316efdd 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -3063,7 +3063,7 @@ sub cli_agent_update_custom_fields() { } # Department, Serial number ... - my $custom_field = get_db_single_row ($dbh, 'SELECT id_field FROM tagent_custom_fields WHERE name = ? ', safe_input($field)); + my $custom_field = pandora_select_id_custom_field ($dbh, $field); if($custom_field eq '') { print_log "[ERROR] Field '$field' doesnt exist\n\n";