日期:2014-05-16  浏览次数:20887 次

部署在nagios中的语句不能执行
在nagios中部署了一段语句

--lsnrctl)
lsnrctl=` lsnrctl status`
#lsnrctl=` echo "successfully"`
lsnrctl2=` echo $lsnrctl | grep -c successfully`
echo $lsnrctl
echo $lsnrctl2
  if [ `echo $lsnrctl2 | bc` -eq 1 ] ; then
  echo "lsnrctl is OK"
  exit $STATE_OK
  else
  echo "lsnrctl is NG"
  exit $STATE_CRITICAL
  fi
  ;;

监控中输出:
(No output returned from plugin)
0
lsnrctl is NG




而用下面这段就正常
--lsnrctl)
#lsnrctl=` lsnrctl status`
lsnrctl=` echo "successfully"`
lsnrctl2=` echo $lsnrctl | grep -c successfully`
#echo $lsnrctl
#echo $lsnrctl2
  if [ `echo $lsnrctl2 | bc` -eq 1 ] ; then
  echo "lsnrctl is OK"
  exit $STATE_OK
  else
  echo "lsnrctl is NG"
  exit $STATE_CRITICAL
  fi
  ;;

这样就正常输出:
successfully
1
lsnrctl is OK




请问各位这个问题出在什么地方?

------解决方案--------------------
探讨

应该是权限问题吧~文件是nagios用户生成的

-rw-r--r-- 1 nagios nagios 0 Feb 21 18:18 tmpjiankong.txt