Skip to content

Commit 46d9216

Browse files
committed
sap_facts.sh - ps print only executable with path
The output of "ps -ef" not also includes the command but also the process age and process arguments. Both can have digits in its string which may interfere when grepping for an instance number like 00 or 01. To fix this, let ps print only the executable with its path. Example: ps with default output - 2 lines match where only 1st line should match /usr/sap/A22/D01/exe/sapstartsrv pf=/usr/sap/A22/SYS/profile/A22_D01_sapa22u01 -D -u a22adm /usr/sap/A22/ASCS02/exe/sapstartsrv pf=/usr/sap/A22/SYS/profile/A22_ASCS02_sapa22u01 -D -u a22adm Example: ps with custom layout, only one line matches as expected /usr/sap/A22/D01/exe/sapstartsrv
1 parent e247f47 commit 46d9216

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

plugins/modules/sap_facts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ function check_sapstartsrv(){
286286
# $3 - NR
287287

288288
## Count the number of sapstartsrv processes
289-
SAPSTARTSRV=$(ps -ef | grep $2 | grep $3 | grep sapstartsrv | wc -l)
289+
SAPSTARTSRV=$(ps -eo command | grep $2 | grep $3 | grep sapstartsrv | wc -l)
290290

291291
if [[ $SAPSTARTSRV = 0 ]]; then
292292
## No sapstartsrv process running - attempt to start

0 commit comments

Comments
 (0)