2012-07-10 35 views
0

我试图监控Rails应用程序与nagiosnrpe插件的内部,但只获得NRPE: Unable to read output要监控Rails应用程序的使用Nagios和NRPE,但只获得了内部“NRPE:无法读取输出”

这是我的监控机代码 “check_test.rb” 脚本:

#!/usr/bin/env ruby 

# load rails 

RAILS_ENV = 'production' 
require '/var/www/production/current/config/environment' 

error = 0 

print "OK" 

exit error # exit with the error code that is then interpreted by nagios 

这里是我的监视主机呼叫:

$ sudo /usr/local/nagios/libexec/check_nrpe -H remote.machine.com -c check_test -t 240 

如果我删除下面的线,它工作正常:

# load rails 

RAILS_ENV = 'production' 
require '/var/www/production/current/config/environment' 

任何帮助将非常appretiated。 在此先感谢。

回答

1

我创建了一个包装bash脚本如下:


#/斌/庆典

CD /无功/网络/生产/电流/

RAILS_ENV =生产的/ usr/local/nagios/libexec/check_test.rb --silent

exit $?


从check_test.rb中删除了RAILS_ENV语句,因为它已经被声明为包装脚本。

它现在工作正常:-DD

谢谢!

+0

另一种选择是:'cd/var/www/production/current/&& script/rails runner -e [ENVIRONMENT]'YOUR_CLASS.YOUR_METHOD'' – pisaruk 2012-07-11 23:05:01