-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* check cgroups function * removing comments * parametrized node name * Script to check and update if necessary * moving checker to configure script * renaming because this script will not be executable * making it executable * removing copied code * i was supposing cgroup empty means inactive * chomping consule return * comment * run script as ruby by default, getting better hostname * dinamic version and realease normalization * refactoring needed * readme update because user functionality * rubywrapper added * unmangle shebangs to avoid no env ruby * Removing comments, ruby lint function call * lint frozen literal * lint identation size * Lint doc module * lint more def less lines in one * lint, call as a function, not as a class * refactor literal string * lint fixes * versioning
- Loading branch information
1 parent
c9722b5
commit 9435cf6
Showing
4 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
####################################################################### | ||
# Copyright (c) 2024 ENEO Tecnología S.L. | ||
# This file is part of redBorder. | ||
# redBorder is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# redBorder is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License License for more details. | ||
# You should have received a copy of the GNU Affero General Public License License | ||
# along with redBorder. If not, see <http://www.gnu.org/licenses/>. | ||
####################################################################### | ||
|
||
source /etc/profile.d/rvm.sh | ||
|
||
/usr/lib/redborder/scripts/rb_check_cgroups.rb $* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require 'socket' | ||
require 'chef' | ||
|
||
# Module to interact with Cgroup v2 in an easy way | ||
module RedBorder | ||
# Module to check if cgroups need to be reassigned | ||
module Checker | ||
def self.check_memservices_cgroups | ||
Chef::Log.info('Memservices Check') | ||
active_memory_services.all? do |s| | ||
cgroup = `systemctl show -p ControlGroup #{s}`.gsub('ControlGroup=', '').chomp | ||
s = s.delete('\",-').chomp | ||
# every assigned cgroup should cointain redborder-....slice any else false | ||
cgroup.include?("redborder-#{s}.slice") | ||
end | ||
end | ||
|
||
def self.hostname | ||
`hostname -s`.strip | ||
end | ||
|
||
def self.memory_services | ||
`knife node show #{hostname} -l -F json | jq '.default.redborder.memory_services | keys[]'`.chomp.lines | ||
end | ||
|
||
def self.active_memory_services | ||
memory_services.select do |s| | ||
`systemctl is-active #{s}`.chomp == 'active' | ||
end | ||
end | ||
end | ||
end | ||
|
||
RedBorder::Checker.check_memservices_cgroups |