linux 使用 os-check 巡检时报错check_linux.sh: line 41: -: -: syntax error: operand expected (error token is "-")
当我运行os-check 巡检后,生成的html文件报错
如图所示

具体报错: check_linux.sh: line 41: -: -: syntax error: operand expected (error token is "-") check_linux.sh: line 43: -: -: syntax error: operand expected (error token is "-")
操作系统 CentOS Linux release 7.9.2009 (Core)
我查看了一下,发现是在检测inode时,被传入了一个非数值参数 “-”,导致-ge对比时由于不为数值报错的,可能需要在进行ge对比时校验下是否为数字

感谢提醒,我加了个数字判断。你可以试试。
https://github.com/lework/Ansible-roles/blob/c1ef43cbb1e643d3aeca0d51bdcbacad2c12d748/os-check/files/check_linux.sh#L41
加了判断没有生效,我加了个判断,你可以参考下
# value=${2:-0}
if [[ $2 =~ '\^[1-9]+\$' ]]; then
value=${2}
else
value=0
fi
value=${2:-0}
if [[ $2 =~ '^[1-9]+$' ]]; then value=${2} else value=0 fi
试了下 这个 可以解决那个问题
后面又重新看了下,这个还要考虑下有小数的情况,我这里又改了一版,你们试试。
https://github.com/lework/Ansible-roles/blob/24a53f6da7039f8183395cfc4d5985ce360a8d90/os-check/files/check_linux.sh#L41-L42