这最近停止工作。知道我是否需要更改代码中的任何内容吗?
TIME=`grep real < /tmp/EV_Check.time | cut -d ' ' -f2`
time=$TIME
test $time -ge $ct
result=$?
if [ "$result" -eq "1" ]
then
crit=1
msg="Report execution takes $time!"
fi
test $time -ge $wt
result=$?
if [ "$result" -eq "1" ]
then
warn=1
msg="Report execution takes $time!"
fi
if [ $crit -eq 1 -a $warn -eq 0 ]
then
echo "Critical value must be greater than warning value !"
help_usage
exit 3
fi
我收到以下错误:-
./check_ev_report.sh: line 158: test: 0.45: integer expression expected
./check_ev_report.sh: line 166: test: 0.45: integer expression expected
OK - 0.45
答案1
bash 只能进行整数运算。
如果您想比较浮点值,则必须调用外部工具,例如bc
if [[ $(bc <<<"$time >= $ct") == "1" ]]; then
do_something
fi