Variables in an external monitor BASH script
Greetings,
I have written a shell script to use as an external monitor. It works as expected when I execute it from the bash shell, but fails as a monitor. I believe the reason for the failure is the way I am using VARIABLEs.
Is the code below legal?
TMSH='/usr/bin/tmsh'
VCS1='10.12.1.11'
VCS2='10.12.1.12'
DEBUG=1
PRI=$TMSH list ltm snat snat_ids_primary | $GREP -E "$VCS1|$VCS2"
if [ "$DEBUG" -eq 1 ]; then
echo "IDS_SNAT: Result of Primary SNAT check -> $PRI" | $LOGGER -p local0.debug;
fi
When run from the CLI interactively the log will have data to in the $PRI variable.
Mar 26 17:24:46 local/bip-bxb-lab-01 debug logger: IDS_SNAT: Result of Primary SNAT check -> 10.12.1.11/32 Mar 26 17:24:46 local/bip-bxb-lab-01 debug logger: 10.12.1.12/32
When run as an external monitor the $PRI variable is empty.
Mar 26 17:21:24 local/bip-bxb-lab-01 debug logger: IDS_SNAT: Result of Primary SNAT check ->
I am clearly doing something wrong I just don't know what.
Any help would be appreciated.
Thank you.