Skip to content

Commit

Permalink
excluded mem services is a new attribute of data structure set
Browse files Browse the repository at this point in the history
  • Loading branch information
ljblancoredborder committed May 7, 2024
1 parent 6c843fb commit 907c278
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion resources/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'set'
#Default attributes

#general
Expand Down Expand Up @@ -55,6 +56,8 @@
default["redborder"]["memory_services"]["redborder-monitor"] = {"count" => 5, "memory" => 0, "max_limit" => 20000 }
default["redborder"]["memory_services"]["snortd"] = {"count" => 10, "memory" => 0}
default["redborder"]["memory_services"]["barnyard2"] = {"count" => 10, "memory" => 0}
# excluded mem services
default['redborder']['excluded_memservices'] = Set.new(['chef-client']) # Don't assign memory to chef because the service will get handled

default["redborder"]["services"] = {}
default["redborder"]["services"]["chef-client"] = true
Expand All @@ -70,4 +73,3 @@
default["redborder"]["systemdservices"]["rsyslog"] = ["rsyslog"]
default["redborder"]["systemdservices"]["snortd"] = ["snortd"]
default["redborder"]["systemdservices"]["barnyard2"] = ["barnyard2"]

3 changes: 2 additions & 1 deletion resources/libraries/memory_services.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'set'
module Rb_ips
module Helpers
def memory_services(sysmem_total, excluded_services=[])
def memory_services(sysmem_total, excluded_services)
memory_serv = {}
memory_services_size = 0
memory_services_size_total = 0
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 @@ -64,4 +64,4 @@
#getting total system memory less 10% reserved by system
sysmem_total = (node["memory"]["total"].to_i * 0.90).to_i
#node attributes related with memory are changed inside the function to have simplicity using recursivity
memory_services(sysmem_total, ['chef-client'])
memory_services(sysmem_total, node['redborder']['excluded_memservices'])

0 comments on commit 907c278

Please sign in to comment.