原因分析,nginx不支持post。
解决方法,重新编译nagios
1、vi /nagios-4.0.8/cgi/cmd.c
找到printf("<form method='post' action='%s'>\n", COMMAND_CGI);
post修改为get
2、重新make,不需要make install
复制新的cmd.cgi替换旧的的
cp nagios-4.0.8/cgi/cmd.cgi /usr/local/nagios/sbin/cmd.cgi
3、Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update!,有这个错误信息后,搜索下,得到答案:http://blog.sina.com.cn/s/blog_6eee530801010ade.html
修改nagios的启动脚本/etc/init.d/nagios
start)
echo -n "Starting nagios:"
$NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
if [ $? -eq 0 ]; then
su - $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile"
rm -f $NagiosCommandFile
touch $NagiosRunFile
chown $NagiosUser:$NagiosGroup $NagiosRunFile
$NagiosBin -d $NagiosCfgFile
if [ -d $NagiosLockDir ]; then touch $NagiosLockDir/$NagiosLockFile; fi
echo " done."
chmod -R 777 $NagiosVarDir/rw ----增加这句话
exit 0