Monitoring: trim device name

This commit is contained in:
ViacheslavKlimov 2025-04-15 15:16:55 +03:00
parent 82d4cb5381
commit a8a0083bb2

View File

@ -97,7 +97,7 @@ public abstract class TransportHealthChecker<C extends TransportMonitoringConfig
private Device getOrCreateDevice(TbClient tbClient) { private Device getOrCreateDevice(TbClient tbClient) {
TransportType transportType = config.getTransportType(); TransportType transportType = config.getTransportType();
String deviceName = String.format("%s %s (%s) - %s", target.getNamePrefix(), transportType.getName(), target.getQueue(), target.getBaseUrl()); String deviceName = String.format("%s %s (%s) - %s", target.getNamePrefix(), transportType.getName(), target.getQueue(), target.getBaseUrl()).trim();
Device device = tbClient.getTenantDevice(deviceName).orElse(null); Device device = tbClient.getTenantDevice(deviceName).orElse(null);
if (device != null) { if (device != null) {
if (checkCalculatedFields) { if (checkCalculatedFields) {
@ -145,7 +145,7 @@ public abstract class TransportHealthChecker<C extends TransportMonitoringConfig
private DeviceProfile getOrCreateDeviceProfile(TbClient tbClient) { private DeviceProfile getOrCreateDeviceProfile(TbClient tbClient) {
TransportType transportType = config.getTransportType(); TransportType transportType = config.getTransportType();
String profileName = String.format("%s %s (%s)", target.getNamePrefix(), transportType.getName(), target.getQueue()); String profileName = String.format("%s %s (%s)", target.getNamePrefix(), transportType.getName(), target.getQueue()).trim();
DeviceProfile deviceProfile = tbClient.getDeviceProfiles(new PageLink(1, 0, profileName)).getData() DeviceProfile deviceProfile = tbClient.getDeviceProfiles(new PageLink(1, 0, profileName)).getData()
.stream().findFirst().orElse(null); .stream().findFirst().orElse(null);
if (deviceProfile != null) { if (deviceProfile != null) {