Search code examples
bashpluginsnagios

pb nagios bash script null result in if


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

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

Thanks


Solution

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