【问题标题】:Trying to monitor the internals of a rails application with nagios and nrpe but only getting "NRPE: Unable to read output"尝试使用 nagios 和 nrpe 监视 Rails 应用程序的内部,但只得到“NRPE:无法读取输出”
【发布时间】:2012-07-10 19:45:57
【问题描述】:

我正在尝试使用 nagiosnrpe 插件监视 Rails 应用程序的内部,但只得到 NRPE: Unable to read output

这是我的监控机器代码“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'

任何帮助都会非常感激。 提前致谢。

【问题讨论】:

    标签: ruby-on-rails ruby monitoring nagios nrpe


    【解决方案1】:

    我创建了一个包装器 bash 脚本,如下所示:


    #!/bin/bash

    cd /var/www/production/current/

    RAILS_ENV=production /usr/local/nagios/libexec/check_test.rb --silent

    退出$?


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

    它现在工作正常:-DD

    谢谢!

    【讨论】:

    • 另一个选项是:cd /var/www/production/current/ && script/rails runner -e [ENVIRONMENT] 'YOUR_CLASS.YOUR_METHOD'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-17
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多