From fbd46d100bfc5ea9b94606c101d07c5ead167d89 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich <sebastian.gumprich@t-systems.com> Date: Thu, 4 Mar 2021 09:23:41 +0100 Subject: [PATCH 1/3] use service name for process check instead of hardcoding it Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com> --- controls/mysql_conf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controls/mysql_conf.rb b/controls/mysql_conf.rb index a8648fb..ef75188 100644 --- a/controls/mysql_conf.rb +++ b/controls/mysql_conf.rb @@ -67,7 +67,7 @@ control 'mysql-conf-02' do impact 0.5 title 'only one instance of mysql should run on a server' - describe command('ps aux | grep mysqld | egrep -v "grep|mysqld_safe|logger" | wc -l') do + describe command("ps aux | grep #{service_name} | egrep -v \"grep|mysqld_safe|logger\" | wc -l") do its(:stdout) { should match(/^1$/) } end end From deb13c3be823841b3884c7aacd5d41ab68cb4c52 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich <sebastian.gumprich@t-systems.com> Date: Thu, 4 Mar 2021 10:54:28 +0100 Subject: [PATCH 2/3] use pgrep isntead of grep Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com> --- controls/mysql_conf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controls/mysql_conf.rb b/controls/mysql_conf.rb index ef75188..8864c2a 100644 --- a/controls/mysql_conf.rb +++ b/controls/mysql_conf.rb @@ -67,7 +67,7 @@ control 'mysql-conf-02' do impact 0.5 title 'only one instance of mysql should run on a server' - describe command("ps aux | grep #{service_name} | egrep -v \"grep|mysqld_safe|logger\" | wc -l") do + describe command("pgrep -c #{service_name}") do its(:stdout) { should match(/^1$/) } end end From 491098afd085510267f4860342ad5eb242ba8ead Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich <sebastian.gumprich@t-systems.com> Date: Thu, 4 Mar 2021 11:01:33 +0100 Subject: [PATCH 3/3] search for exact strings with pgrep Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com> --- controls/mysql_conf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controls/mysql_conf.rb b/controls/mysql_conf.rb index 8864c2a..9f7bea7 100644 --- a/controls/mysql_conf.rb +++ b/controls/mysql_conf.rb @@ -67,7 +67,7 @@ control 'mysql-conf-02' do impact 0.5 title 'only one instance of mysql should run on a server' - describe command("pgrep -c #{service_name}") do + describe command("pgrep -x -c #{service_name}") do its(:stdout) { should match(/^1$/) } end end