pb nagios bash脚本null导致if [英] pb nagios bash script null result in if

查看:88
本文介绍了pb nagios bash脚本null导致if的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Nagios中使用bash脚本时遇到问题.这是获取空间磁盘的脚本.当我使用IF部分时,它会返回(空),而当我未在IF部分中设置变量时,nagios会正确显示该变量.我试图与nagios用户一起运行脚本,结果很好.例如:

I have a problem with a bash script in Nagios. this is a script to get the space disk. When I used an IF section it returns (null) and when I don't set the variable in IF section, nagios display the variable correctly. I tried to run the script with nagios user and the result is good. Ex:

TOTAL=`/srv/eyesofnetwork/nagios/plugins/check_nt -H $2 -p 12489 -s "" -v USEDDISKSPACE -l $4 |awk -F"-" '{print $2}' |awk '{print $2}'`
if [ $TOTAL -gt 2 ] && [ $TOTAL -le 99 ];then
RUN=`/srv/eyesofnetwork/nagios/plugins/check_nrpe -H $2 -c ``check_drivesize -a drive=$4 'warning=free<2G' 'critical=free<1G' show-all 'perf-config=*(unit:G)' top-syntax='${status} : ${problem_list}'`
VAR=$(echo $RUN |grep -i ok |wc -l)
if [ $VAR -eq 1 ];then
echo "$RUN"
exit 0
fi

我尝试了所有可能(对我来说),使用",",什么都没有.变量$ RUN不显示.

I tried all possibilities (for me..), with "", with '', with nothing. The variable $RUN is not displayed.

谢谢

推荐答案

最后,我用python编写了一个脚本,现在它可以正常工作了

Finally, I wrote a script in python and now it works correctly

这篇关于pb nagios bash脚本null导致if的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆