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