Display workflow engine which are not running

Hi ,
We have 6 informatica workflow engine running on our server , so if we do a
ubnf0010% ps -ef |grep workflow |grep "TCPP01 TCPP01"
atlmsts 12721 1 0 06:52:18 ? 14:58 workflow TCPP01 TCPP01 1
atlmsts 14415 1 0 06:52:44 ? 14:56 workflow TCPP01 TCPP01 2
atlmsts 21876 1 0 06:54:07 ? 14:50 workflow TCPP01 TCPP01 5
atlmsts 19720 1 0 06:53:40 ? 15:02 workflow TCPP01 TCPP01 4
atlmsts 23736 1 0 06:54:25 ? 14:39 workflow TCPP01 TCPP01 6
atlmsts 17785 1 0 06:53:17 ? 14:53 workflow TCPP01 TCPP01 3

all 6 are shown running .
At times there is 1 or multiple engine failure, in that suppose 2 and 5 fails, when we do a
ubnf0010% ps -ef |grep workflow |grep "TCPP01 TCPP01"

atlmsts 12721 1 0 06:52:18 ? 14:58 workflow TCPP01 TCPP01 1
atlmsts 19720 1 0 06:53:40 ? 15:02 workflow TCPP01 TCPP01 4
atlmsts 23736 1 0 06:54:25 ? 14:39 workflow TCPP01 TCPP01 6
atlmsts 17785 1 0 06:53:17 ? 14:53 workflow TCPP01 TCPP01 3

I want a script which displays which engines(engine numbers are not running , if there are engine failure)

You can do something like that :

ps -ef | \
awk -v count=6 '
$(NF-3)=="workflow" && $(NF-2)=="TCPP01" && $(NF-1)=="TCPP01" {
    ++p[$NF]
}
END {
   for (i=1; i<=count; i++) {
      if (! p)
         print "engine not running:",i
   }
}
'

Output:

engine not running: 2
engine not running: 5

Jean-Pierre.

please explain this
ps -ef | \
awk -v count=6 '
$(NF-3)=="workflow" && $(NF-2)=="TCPP01" && $(NF-1)=="TCPP01" {
++p[$NF]
}

 -v count=6

initialyze variable count which contains the numbers of engines.

$(NF-3)=="workflow" && $(NF-2)=="TCPP01" && $(NF-1)=="TCPP01" { ... }

Select records containing "workflow TCPP01 TCPP01" before last fiels (which is engine number).
NF is the totaal number of fields in the input record processed.

++p[$NF]

Increment the element for the engine ($NF is last fied) in the p array

END { ... }

When all input record have been processed

   for (i=1; i<=count; i++) { ... } 

I is the engine, number

      if (! p)
         print "engine not running:",i

If the element for the engine in the p array is 0 (not different of zero) the print message.

Jean-Pierre.

it gives me a syntax error

awk: syntax error near line 1
awk: bailing out near line 1

Use gawk instead of awk (on my system it's the same thing).
This solutions works only with gawk because the time functions aren't defined with other versions of awk.

Jean-Pierre.

gawk is not installed on the server

---------- Post updated at 07:07 PM ---------- Previous update was at 06:55 PM ----------

is there any other solution without gawk

Sorry, I confused two post them.
You don't need gawk, try nawk instead of awk.

Jean-Pierre.

At least there's another approach :wink:

LIST=$( ps -ef | grep 'workflow' - )

for NO in {1..6}
do
  TEST=$( echo "$LIST" | grep "TCPP01 TCPP01 $NO" - )
  if [ "$TEST" = "" ]
  then
    echo "Engine no. $NO down (?)."
  fi
done