sentrysoftware / metricshub

Universal Metrics Collection for OpenTelemetry
https://metricshub.com
GNU Affero General Public License v3.0
15 stars 4 forks source link

Protocol definition is applied to only one host in multiple hosts configuration setup #410

Closed NassimBtk closed 2 months ago

NassimBtk commented 2 months ago

Problem

When configuring multiple hosts with the same protocol configuration as shown below:

resources:
  devlinux:
    attributes:
      host.names: [ host1, host2, host3 ]
      host.type: linux
    protocols:
      ssh:
        timeout: 120
        useSudo: true
        username: *******
        password: *******

The engine creates three resource configurations, but they all share a shallow copy of the same ssh protocol reference. Since it’s a shallow copy, changes like setting the hostname in one configuration will affect all other configurations. This leads to all hosts incorrectly sharing the same hostname.

Proposal

To resolve this issue, a deep copy of the protocol configuration should be created for each host. This will ensure that each host has an independent IConfiguration (ssh, wbem, wmi, http, snmp, snmpv3, winrm, oscommand, ping configurations), avoiding unintended overwriting of shared attributes like hostname.