AnsweredAssumed Answered

Incorrect results running CLI script in parallel in VSX

Question asked by Hawkeye Parker on Dec 26, 2018
Latest reply on Dec 29, 2018 by Jozko Mrkvicka

We have some SSH expert mode bash scripts that run against large VSX deployments, and, for various reasons, we've been trying to speed up the runtime of these scripts. One thing we've tried is executing a script in parallel. E.g.,

 

vsx stat -l | awk '/^VSID:/{ print $NF }' |
xargs -n 1 -P 4 -I{} bash -c 'id={}; result=`source /etc/profile.d/vsenv.sh; vsenv $id && ifconfig`; echo "$result"'

 

xargs options:
-n max args
-P max procs
-i --> -i{} -- in the following command to xargs, for each line of input from stdin, replace {} with that input.

 

I.e., we use vsx stat -l to extract the VSID, then for each VS, we execute ifconfig and dump the result.

 

It's really fast, but we see some incorrect results: ifconfig reports the same IP for each interface in each VS; if we run it serially, we get correct output.

 

We're suspecting that this 'initialization' of the bash environment, bash -c 'id={}; result=`source /etc/profile.d/vsenv.sh...' isn't creating a "complete" Check Point shell environment (like the one you'd get if you SSH'd in). Just a guess.

 

Anyone have suggestions on how to properly initialize the shell? Any other ideas?

Outcomes