From 9287c340087c0910abb535e32012d24a4e677ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Sun, 30 Jul 2023 10:39:13 -0600 Subject: [PATCH 1/3] Add _dataunit_ macro --- pandora_server/lib/PandoraFMS/Core.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index d287f880c8..5262ec0676 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1389,6 +1389,7 @@ sub pandora_execute_action ($$$$$$$$$;$$) { _timestamp_ => (defined($timestamp)) ? $timestamp : strftime ("%Y-%m-%d %H:%M:%S", localtime()), _timezone_ => strftime ("%Z", localtime()), _data_ => $data, + _dataunit_ => (defined ($module)) ? $module->{'unit'} : '', _prevdata_ => undef, _homeurl_ => $pa_config->{'public_url'}, _alert_name_ => $alert->{'name'}, @@ -4890,6 +4891,9 @@ sub on_demand_macro($$$$$$;$) { my $field_number = $1; my $field_value = get_db_value($dbh, 'SELECT description FROM tagent_custom_data WHERE id_field=? AND id_agent=?', $field_number, $agent_id); return (defined($field_value)) ? $field_value : ''; + } elsif ($macro eq '_dataunit_'){ + return '' unless defined ($module); + my $field_value = get_db_value($dbh, 'SELECT unit FROM tagente_datos where id_agente_modulo = ? order by utimestamp desc limit 1 offset 1', $module->{'id_agente_modulo'}); } elsif ($macro eq '_prevdata_') { return '' unless defined ($module); if ($module->{'id_tipo_modulo'} eq 3){ From f9e1480c5640d7ad0d501ea34dba184ab23771a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Sun, 30 Jul 2023 10:44:38 -0600 Subject: [PATCH 2/3] Fix on table selection --- pandora_server/lib/PandoraFMS/Core.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 5262ec0676..1807d48575 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4893,7 +4893,7 @@ sub on_demand_macro($$$$$$;$) { return (defined($field_value)) ? $field_value : ''; } elsif ($macro eq '_dataunit_'){ return '' unless defined ($module); - my $field_value = get_db_value($dbh, 'SELECT unit FROM tagente_datos where id_agente_modulo = ? order by utimestamp desc limit 1 offset 1', $module->{'id_agente_modulo'}); + my $field_value = get_db_value($dbh, 'SELECT unit FROM tagente_modulo where id_agente_modulo = ? order by utimestamp desc limit 1 offset 1', $module->{'id_agente_modulo'}); } elsif ($macro eq '_prevdata_') { return '' unless defined ($module); if ($module->{'id_tipo_modulo'} eq 3){ From 3434b2e6212f4fd5ebaa0de4bbc9f7f373394f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Sun, 30 Jul 2023 10:48:57 -0600 Subject: [PATCH 3/3] Fix on where clause --- pandora_server/lib/PandoraFMS/Core.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 1807d48575..194525653e 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4893,7 +4893,7 @@ sub on_demand_macro($$$$$$;$) { return (defined($field_value)) ? $field_value : ''; } elsif ($macro eq '_dataunit_'){ return '' unless defined ($module); - my $field_value = get_db_value($dbh, 'SELECT unit FROM tagente_modulo where id_agente_modulo = ? order by utimestamp desc limit 1 offset 1', $module->{'id_agente_modulo'}); + my $field_value = get_db_value($dbh, 'SELECT unit FROM tagente_modulo where id_agente_modulo = ? limit 1', $module->{'id_agente_modulo'}); } elsif ($macro eq '_prevdata_') { return '' unless defined ($module); if ($module->{'id_tipo_modulo'} eq 3){