From 1af63376521083249a9a535f3667787890fea969 Mon Sep 17 00:00:00 2001 From: Daniel Castro Date: Wed, 11 Sep 2024 15:05:09 +0100 Subject: [PATCH] fix add flow sensors to manager --- resources/libraries/update_sensor_config.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/libraries/update_sensor_config.rb b/resources/libraries/update_sensor_config.rb index f4eb7e4..33e2412 100644 --- a/resources/libraries/update_sensor_config.rb +++ b/resources/libraries/update_sensor_config.rb @@ -9,17 +9,20 @@ def update_sensor_config(resource) # FLOW SENSORS flow_nodes = resource['flow_nodes'] manager_list = resource['managers'] + begin if flow_nodes && !manager_list.empty? # Title of section node.default['redborder']['monitor']['config']['sensors'].push('/* REMOTE SENSORS, MONITORED ON ANY MANAGER */') manager_index = manager_list.find_index(resource['hostname']) + flow_nodes.each_with_index do |fnode, findex| next unless !fnode['redborder']['monitors'].empty? && fnode['ipaddress'] && fnode['redborder']['parent_id'].nil? fnode_name = fnode['rbname'].nil? ? fnode.name : fnode['rbname'] fnode_count = fnode['redborder']['monitors'].size - if findex % manager_list.length == manager_index && fnode['redborder'] && !fnode['redborder']['monitors'].size.empty? + + if findex % manager_list.length == manager_index && fnode['redborder'] && !fnode['redborder']['monitors'].empty? # Title of sensor node.default['redborder']['monitor']['config']['sensors'].push("/* Node: #{fnode_name} Monitors: #{fnode_count} */") sensor = { @@ -46,16 +49,19 @@ def update_sensor_config(resource) # DEVICES SENSORS device_nodes = resource['device_nodes'] manager_list = node['redborder']['managers_list'] + begin if device_nodes && !manager_list.empty? # Title of section node.default['redborder']['monitor']['config']['sensors'].push('/* DEVICE SENSORS */') manager_index = manager_list.find_index(resource['hostname']) + device_nodes.each_with_index do |dnode, dindex| next unless !dnode['redborder']['monitors'].empty? && dnode['ipaddress'] && dnode['redborder']['parent_id'].nil? dnode_name = dnode['rbname'].nil? ? dnode.name : dnode['rbname'] dnode_count = dnode['redborder']['monitors'].size + if dindex % manager_list.length == manager_index && dnode['redborder'] && !dnode['redborder']['monitors'].empty? # Title of sensor node.default['redborder']['monitor']['config']['sensors'].push("/* Node: #{dnode_name} Monitors: #{dnode_count} */")