From 474f44a9d81baf3be5345fac30907bf1444d0b45 Mon Sep 17 00:00:00 2001 From: samdesmondking Date: Tue, 9 Jul 2024 17:10:29 +0530 Subject: [PATCH] Updated the update_results function to append any custom fields rather than overwriting them --- unix/src/machine_stats/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/unix/src/machine_stats/__init__.py b/unix/src/machine_stats/__init__.py index eb08012..650cc44 100644 --- a/unix/src/machine_stats/__init__.py +++ b/unix/src/machine_stats/__init__.py @@ -199,8 +199,16 @@ def update_results(self, host, data: dict): if host not in self._total_results: self._total_results[host] = data - else: + return + + # Ensure we append any custom fields, rather than overwriting them + if 'custom_fields' in data and 'custom_fields' in self._total_results[host]: + combined_custom_fields = {**self._total_results[host]['custom_fields'], **data['custom_fields']} + data['custom_fields'].update(combined_custom_fields) self._total_results[host].update(data) + return + + self._total_results[host].update(data) def v2_runner_on_ok(self, result): self._plugins.ok_callback(self, result)