From 6763ebe3a1c969436b99e827a29a177f914c57fb Mon Sep 17 00:00:00 2001 From: David Vanhoucke Date: Thu, 14 Mar 2024 14:37:30 +0000 Subject: [PATCH] pass all flow sensors to sflow pipeline --- .../libraries/get_all_flow_sensors_info.rb | 19 +++++++++++++++++++ resources/recipes/configure.rb | 2 +- resources/recipes/prepare_system.rb | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 resources/libraries/get_all_flow_sensors_info.rb diff --git a/resources/libraries/get_all_flow_sensors_info.rb b/resources/libraries/get_all_flow_sensors_info.rb new file mode 100644 index 00000000..01bfe615 --- /dev/null +++ b/resources/libraries/get_all_flow_sensors_info.rb @@ -0,0 +1,19 @@ +module Rb_manager + module Helpers + def get_all_flow_sensors_info() + sensors_info = {} + sensor_types = ["flow-sensor"] + + sensor_types.each do |s_type| + sensors = search(:node, "role:#{s_type}").sort + + sensors_info[s_type] = [] + sensors.each do |s| + sensors_info[s_type] << s + end + end + sensors_info + end + end +end + \ No newline at end of file diff --git a/resources/recipes/configure.rb b/resources/recipes/configure.rb index 8935c5d7..9aa6f431 100644 --- a/resources/recipes/configure.rb +++ b/resources/recipes/configure.rb @@ -276,7 +276,7 @@ logstash_config "Configure logstash" do cdomain node["redborder"]["cdomain"] - flow_nodes node["redborder"]["sensors_info_all"]["flow-sensor"] + flow_nodes node["redborder"]["all_flow_sensors_info"]["flow-sensor"] namespaces node["redborder"]["namespaces"] vault_nodes node["redborder"]["sensors_info_all"]["vault-sensor"] scanner_nodes node["redborder"]["sensors_info_all"]["scanner-sensor"] diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index e3b0cbb8..a9b9d2d7 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -91,6 +91,9 @@ #get sensors info full info node.default["redborder"]["sensors_info_all"] = get_sensors_all_info() +#get sensors info of all flow sensors +node.default["redborder"]["all_flow_sensors_info"] = get_all_flow_sensors_info() + #get namespaces node.default["redborder"]["namespaces"] = get_namespaces