0

I'm trying to monitor the internals of a rails application with nagios and nrpe plugin but only getting NRPE: Unable to read output

Here is my Monitoring Machine Code "check_test.rb" script:

#!/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

Here is my Monitoring Host call:

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

If I remove the lines below, it works fine:

# load rails

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

Any help will be very much appretiated. Thanks in advance.

1 Answers1

1

I created a wrapper bash script as follows:


#!/bin/bash

cd /var/www/production/current/

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

exit $?


And removed the RAILS_ENV statement from check_test.rb since It was already declared into the wrapper script.

It is now working fine :-DD

Thanks!

  • Another option would be: `cd /var/www/production/current/ && script/rails runner -e [ENVIRONMENT] 'YOUR_CLASS.YOUR_METHOD'` – Pikachu Jul 11 '12 at 23:05