What is wrong with the following if-then-else? I never can hit the else.
if [ $result > $value ]; then
echo HEALTH: OK. Result is $result Value is $value
exit 0
else
echo HEALTH: CRITICAL. Result is $result which is over $value
exit 2
fi
# ./check_cw_auto <AWS variables> 5.0
HEALTH: OK. Result is 275593.8 Value is 5.0
# ./check_cw_auto <AWS variables> 10000000.0
HEALTH: OK. Result is 275593.8 Value is 10000000.0
I'm trying to create a nagios bash script. I did try -gt instead of >, but that give an error. Example:
./check_cw_auto <AWS variables> 5.0
./check_cw_auto: line 30: [: 256497.2: integer expression expected
HEALTH: CRITICAL. Result is 256497.2 which is over 5.0