当前位置: 技术问答>linux和unix
部署在nagios中的语句不能执行
来源: 互联网 发布时间:2017-02-05
本文导语: 在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" exi...
在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
请问各位这个问题出在什么地方?
--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用户没有权限执行这个“lsnrctl status”
看看lsnrctl命令的所属主和所属组, 将nagios公共组加入到lsnrctl的所属组中,然后赋予x权限
或者使用你喜欢的其他方式,让nagios能执行“lsnrctl status”就行了呗..