LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   BHOD - Nagios Plugin returns null (https://www.linuxquestions.org/questions/linux-server-73/bhod-nagios-plugin-returns-null-4175434634/)

slokie 10-29-2012 11:01 AM

BHOD - Nagios Plugin returns null
 
Hello, I'm lost and need some help, I stumbled upon the site, hope you can help

Running a check command for our my account app
Code:

define service{
use generic-service
host_name myaccount
service_description MyAccount Login Time - Medium Account
check_command check_myaccount! ccc@yyy.none password 10 13
}

Code:

define command{
command_name check_myaccount
command_line /usr/lib64/nagios/plugins/check_myaccount $ARG1$
}

Code:

#!/usr/bin/env ruby

require 'rubygems'
require 'mechanize'
require 'pp'
require 'benchmark'

agent = Mechanize.new
agent.read_timeout = 600

username = ARGV[0]
password = ARGV[1]
warning = ARGV[2].to_i
critical = ARGV[3].to_i

if ARGV.length < 4
  puts "Please add needed arguments:"
  puts "  ./check_myaccount <login> <password> <warning seconds> <critical seconds>"
  exit(3)
end

time = Benchmark.realtime do
  start_page = agent.get('https://myaccount.xyz.com/online/')
  login_form = start_page.form('loginForm')
  login_form['loginForm:username'] = ARGV[0]
  login_form['loginForm:password'] = ARGV[1]
  myaccount_page = agent.submit(login_form, login_form.buttons.first)
end

time = time.round(2)

if time < warning
  puts "TIME OK - #{time} | time=#{time}"
  exit(0)
elsif time >= warning && time < critical
  puts "TIME WARNING - #{time} | time=#{time}"
  exit(1)
elsif time >= critical
  puts "TIME CRITICAL - #{time} | time=#{time}"
  exit(2)
else
  puts "TIME UNKNOWN - #{time} | time=#{time}"
  exit(3)
end

[root@monitoring01 plugins]# su nagios
sh-3.2$ /usr/lib64/nagios/plugins/check_myaccount ccc@yyy.none password 15 20
TIME OK - 2.43 | time=2.43

but nagios returns
(null)

Please help

Habitual 10-31-2012 07:44 AM

What OS is nagios installed on?
How did nagios get installed?
Package Manager, or source code using
Code:

./configure && make && make install
How did nagios plugins get installed and what version is it?

You provided a ruby script that seems to wrap up the nagios check_ command but you aren't telling us where, or how you use it.

Please let us know...

slokie 10-31-2012 12:45 PM

This was installed on a CentOS 5.8 we had an original build of 3.0 but was upgraded via yum when this started.

As for the nagios versions installed:
Code:

nagios-plugins-1.4.16-1.el5.rf
nagios-plugins-nrpe-2.12-16.el5
nagios-devel-3.2.3-3.el5.rf
nagios-nrpe-2.12-1.el5.rf
nagios-plugins-setuid-1.4.16-1.el5.rf
nagios-3.2.3-3.el5.rf

to run:

Code:

/usr/lib64/nagios/plugins/check_myaccount <user> <password> <time warning> <time critcal>

slokie 11-12-2012 05:29 PM

Checking other local plugins - appears to not be parsing local arguments - I've had debug on checking on another similar issue and noticed the following

these are both Ruby derived nagios plugins.

Code:

[1352762845.038683] [2320.2] [pid=31182] Expanded Command Output: /usr/lib64/nagios/plugins/check_imem_temp -area $ARG1$ -warn $ARG2$ -critical $ARG3$
[1352762845.049649] [2320.2] [pid=31182] Raw Command Input: /usr/lib64/nagios/plugins/check_imem_temp -area $ARG1$ -warn $ARG2$ -critical $ARG3$

am I missing something simple here?


All times are GMT -5. The time now is 08:18 AM.