Skip to content

Commit

Permalink
Merge pull request #34 from redBorder/bugfix/17238_logstash_not_runni…
Browse files Browse the repository at this point in the history
…ng_when_no_pipelines

Bugfix/17238 logstash not running when no pipelines
  • Loading branch information
jsotofernandez authored Jun 21, 2024
2 parents 5e2004d + e1272bb commit ad927c6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
default['redborder']['services']['redborder-scanner'] = true
default['redborder']['services']['snmp'] = true
default['redborder']['services']['f2k'] = true
default['redborder']['services']['logstash'] = true
default['redborder']['services']['logstash'] = false
default['redborder']['services']['pmacct'] = true
default['redborder']['services']['rsyslog'] = true
default['redborder']['services']['redborder-nmsp'] = true
Expand Down
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 RbProxy
module Helpers
def get_monitor_configuration
proxy_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'
proxy_config << monitor['name']
end
end
end
proxy_config
end
end
end
17 changes: 17 additions & 0 deletions resources/libraries/get_pipelines.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module RbProxy
module Helpers
def get_pipelines
logstash_pipelines = []
sensors = get_sensors_info()
proxy_config = get_monitor_configuration()
has_device_sensors = !sensors['device-sensor'].nil? && !sensors['device-sensor'].empty?
contains_thermal = proxy_config.include?('thermal')
contains_bulkstats = proxy_config.include?('bulkstats_schema')

logstash_pipelines.push('redfish-pipeline') if has_device_sensors && contains_thermal
logstash_pipelines.push('bulkstats-pipeline') if has_device_sensors && contains_bulkstats

logstash_pipelines
end
end
end
3 changes: 2 additions & 1 deletion resources/recipes/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
namespaces node.run_state['namespaces']
vault_nodes node.run_state['sensors_info_all']['vault-sensor']
device_nodes node.run_state['sensors_info_all']['device-sensor']
if proxy_services['logstash']
logstash_pipelines node.default['pipelines']
if !logstash_pipelines.nil? && !logstash_pipelines.empty?
action [:add]
else
action [:remove]
Expand Down
3 changes: 3 additions & 0 deletions resources/recipes/prepare_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
# get namespaces
node.run_state['namespaces'] = get_namespaces

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

# get string with all zookeeper hosts and port separated by commas, its needed for multiples services
# zk_port = node['redborder']['zookeeper']['port']
# zk_hosts = ['localhost'].map {|z| '#{z}.node:#{zk_port}'}.join(',')
Expand Down

0 comments on commit ad927c6

Please sign in to comment.