Skip to content

Commit

Permalink
sap_facts.sh - print only command column with ps
Browse files Browse the repository at this point in the history
The output of "ps -ef" not also includes the command but also the
process age. When grepping for instance number '00', it can also match
for a displayed process age like 00:00:01. So only print the columns
that are really needed which is the command.

Example:
desadm    2640     1  0 15:16 ?        00:00:00 /usr/sap/DES/ASCS01/exe/sapstartsrv pf=/usr/sap/DES/SYS/profile/DES_ASCS01_sapdes -D -u desadm
                                       ^^ ^^ ^^
desadm    2879     1  0 15:16 ?        00:00:01 /usr/sap/DES/D00/exe/sapstartsrv pf=/usr/sap/DES/SYS/profile/DES_D00_sapdes -D -u desadm

Only line 2 should match but because of the time value, the first
line matches also when grepping for instance 00.
  • Loading branch information
jhohwieler committed Aug 20, 2024
1 parent e247f47 commit 9140fd1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/modules/sap_facts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function check_sapstartsrv(){
# $3 - NR

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

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

0 comments on commit 9140fd1

Please sign in to comment.