Skip to content

Commit

Permalink
add pipeline per monitor configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsver committed Jun 20, 2024
1 parent 040aeda commit 0186ecc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
17 changes: 17 additions & 0 deletions resources/libraries/get_monitor_configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module RbManager
module Helpers
def get_monitor_configuration
monitor_config = []
sensor = search(:node, "redborder_monitors:[* TO *] AND name:*device*").sort
sensor.each do |node|
monitors = node.normal['redborder']['monitors']
monitors.each do |monitor|
if monitor['name'] == 'bulkstats_schema' || monitor['name'] == 'thermal'
monitor_config << monitor['name']
end
end
end
monitor_config
end
end
end
35 changes: 20 additions & 15 deletions resources/libraries/get_pipelines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,28 @@ def get_pipelines
namespaces = get_namespaces()
main_logstash = determine_main_logstash_node()
monitor_sensor_in_proxy_nodes = find_monitor_sensor_in_proxy_nodes()
monitor_config = get_monitor_configuration()
has_device_sensors = !sensors['device-sensor'].nil? && !sensors['device-sensor'].empty?

if manager_services['logstash']
logstash_pipelines.push('rbwindow-pipeline') if main_logstash == node.name
logstash_pipelines.push('apstate-pipeline')
logstash_pipelines.push('scanner-pipeline') unless sensors['scanner-sensor'].empty?
logstash_pipelines.push('nmsp-pipeline') if main_logstash == node.name && !sensors['flow-sensor'].empty?
logstash_pipelines.push('radius-pipeline') if main_logstash == node.name
logstash_pipelines.push('vault-pipeline') unless sensors['vault-sensor'].empty?
logstash_pipelines.push('netflow-pipeline') unless sensors['flow-sensor'].empty?
logstash_pipelines.push('sflow-pipeline') unless sensors['flow-sensor'].empty?
logstash_pipelines.push('meraki-pipeline') unless sensors['meraki-sensor'].empty?
logstash_pipelines.push('monitor-pipeline') unless namespaces.empty?
logstash_pipelines.push('location-pipeline') unless sensors['ale-sensor'].empty? || sensors['mse-sensor'].empty? || sensors['flow-sensor'].empty? || sensors['arubacentral-sensor'].empty?
logstash_pipelines.push('mobility-pipeline')
logstash_pipelines.push('redfish-pipeline') unless sensors['device-sensor'].empty? && monitor_sensor_in_proxy_nodes.empty?
logstash_pipelines.push('bulkstats-pipeline') unless sensors['device-sensor'].empty? && monitor_sensor_in_proxy_nodes.empty?
logstash_pipelines.push('rbwindow-pipeline') if main_logstash == node.name
logstash_pipelines.push('apstate-pipeline')
logstash_pipelines.push('scanner-pipeline') unless sensors['scanner-sensor'].empty?
logstash_pipelines.push('nmsp-pipeline') if main_logstash == node.name && !sensors['flow-sensor'].empty?
logstash_pipelines.push('radius-pipeline') if main_logstash == node.name
logstash_pipelines.push('vault-pipeline') unless sensors['vault-sensor'].empty?
logstash_pipelines.push('netflow-pipeline') unless sensors['flow-sensor'].empty?
logstash_pipelines.push('sflow-pipeline') unless sensors['flow-sensor'].empty?
logstash_pipelines.push('meraki-pipeline') unless sensors['meraki-sensor'].empty?
logstash_pipelines.push('monitor-pipeline') unless namespaces.empty?
logstash_pipelines.push('location-pipeline') unless sensors['ale-sensor'].empty? || sensors['mse-sensor'].empty? || sensors['flow-sensor'].empty? || sensors['arubacentral-sensor'].empty?
logstash_pipelines.push('mobility-pipeline')
if (has_device_sensors && monitor_config.include?('thermal')) || !monitor_sensor_in_proxy_nodes.empty?
logstash_pipelines.push('redfish-pipeline')
end
if (has_device_sensors && monitor_config.include?('bulkstats_schema')) || !monitor_sensor_in_proxy_nodes.empty?
logstash_pipelines.push('bulkstats-pipeline')
end

logstash_pipelines
end

Expand Down
4 changes: 2 additions & 2 deletions resources/recipes/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@
vault_nodes node.run_state['sensors_info_all']['vault-sensor']
scanner_nodes node.run_state['sensors_info_all']['scanner-sensor']
device_nodes node.run_state['sensors_info_all']['device-sensor']
logstash_pipelines node.run_state['pipelines']
if manager_services['logstash'] && node.run_state['pipelines'] && !node.run_state['pipelines'].empty?
logstash_pipelines node.default['pipelines']
if !logstash_pipelines.nil? && !logstash_pipelines.empty?
action [:add, :register]
else
action [:remove, :deregister]
Expand Down
2 changes: 1 addition & 1 deletion resources/recipes/prepare_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
node.run_state['all_flow_sensors_info'] = get_all_flow_sensors_info()

# get logstash pipelines
node.run_state['pipelines'] = get_pipelines()
node.default['pipelines'] = get_pipelines()

# get namespaces
node.run_state['namespaces'] = get_namespaces
Expand Down

0 comments on commit 0186ecc

Please sign in to comment.