FAQ

On Friday, July 5, 2013 2:22:25 PM UTC+1, R.I.Pienaar wrote:

----- Original Message -----
From: "Daniel Siechniewicz" <dan...@siechniewicz.com <javascript:>>
To: mcollect...@googlegroups.com <javascript:>
Sent: Friday, July 5, 2013 2:17:35 PM
Subject: Re: [mcollective-users] nrpe plugin returning wrong number of
arguments (2 for 0)

On Friday, July 5, 2013 9:17:35 AM UTC+1, R.I.Pienaar wrote:


----- Original Message -----
From: "Daniel Siechniewicz" <dan...@siechniewicz.com <javascript:>>
To: mcollect...@googlegroups.com <javascript:>
Sent: Friday, July 5, 2013 8:04:57 AM
Subject: Re: [mcollective-users] nrpe plugin returning wrong number
of
arguments (2 for 0)
On Thursday, July 4, 2013 10:00:19 PM UTC+1, R.I.Pienaar wrote:


----- Original Message -----
From: "Daniel Siechniewicz" <dan...@siechniewicz.com<javascript:>>
To: mcollect...@googlegroups.com <javascript:>
Sent: Thursday, July 4, 2013 2:54:10 PM
Subject: [mcollective-users] nrpe plugin returning wrong number
of
arguments (2 for 0)
Hi,

I've got Centos 5 with ruby 1.8.7, mcollective 2.2.4 and nrpe
plugin
3.0.2
installed from a fresh mirror of puppetlabs repo.

When I try to run nrpe command as:

mco nrpe some_command

or:

mco rpc nrpe runcommand command=some_command
I get:

status=wrong number of arguments (2 for 0)

for every command that is actually defined. I get an, expected,
"status=UNKNOWN No such command:" for ones that aren't.

I've added some poor man's debug to
/usr/libexec/mcollective/mcollective/agent/nrpe.rb, and here's
what
I
get:
debug 2013/07/04 14:29:37: agents.rb:119:in `dispatch'
Dispatching a
message to agent nrpe
debug 2013/07/04 14:29:37: pluginmanager.rb:88:in `[]' Returning
new
plugin
nrpe_agent with class MCollective::Agent::Nrpe
debug 2013/07/04 14:29:37: cache.rb:105:in `read' Cache hit on
'ddl'
key
'agent/nrpe'
debug 2013/07/04 14:29:37: activemq.rb:233:in `receive' Waiting
for
a
message from ActiveMQ
debug 2013/07/04 14:29:37: nrpe.rb:41:in `run' HERE!!! in run
debug 2013/07/04 14:29:37: nrpe.rb:46:in `run' HERE!!! past
plugin_for_command
debug 2013/07/04 14:29:37: nrpe.rb:49:in `run' HERE!!! output
empty:
debug 2013/07/04 14:29:37: nrpe.rb:50:in `run' HERE!!! trying to
run
Shell.new with /usr/lib64/nagios/plugins/some_command
debug 2013/07/04 14:29:37: pluginmanager.rb:83:in `[]' Returning
cached
plugin security_plugin with class MCollective::Security::Psk
debug 2013/07/04 14:29:37: pluginmanager.rb:83:in `[]' Returning
cached
plugin security_plugin with class MCollective::Security::Psk
debug 2013/07/04 14:29:37: base.rb:168:in `create_reply' Encoded
a
message
for request 2e9521e4d6aa5b019791284dfa9cc22f
debug 2013/07/04 14:29:37: pluginmanager.rb:83:in `[]' Returning
cached
plugin connector_plugin with class
MCollective::Connector::Activemq
My "code" is as follows:
def self.run(command)
Log.debug("HERE!!! in run")
nrpe_command = Nrpe.plugin_for_command(command)
return 3, "No such command: #{command}" unless
nrpe_command
Log.debug("HERE!!! past plugin_for_command")
output = ""
Log.debug("HERE!!! output empty: #{output}")
Log.debug("HERE!!! trying to run Shell.new with
#{nrpe_command[:cmd]}")
shell = Shell.new(nrpe_command[:cmd], {:stdout =>
output,
:chomp
=>
true})
Log.debug("HERE!!! past shell")
shell.runcommand
Log.debug("HERE!!! past shell.runcommand")
exitcode = shell.status.exitstatus

Log.debug("HERE!!! output: #{output}")
return exitcode, output
end

So it never goes to "past shell", let alone runcommand. The
/usr/lib64/nagios/plugins/some_command is there, is executable,
works
with
nagios currently without any issues.

If I take out ":chomp => true", which doesn't seem to be listed
in
/usr/lib/ruby/site_ruby/1.8/mcollective/shell.rb, nothing
changes,
but
if I
take the entire option hash out I get "wrong number of arguments
(1
for
0)"
- so 1, not 2.

That's where I'm stuck. All the other plugins work fine (I
mostly
use
the
puppet plugin, but others, like service, also work).
can you paste more of the agent in question? in an agent you
shouldnt
need
to use Shell.new(....) but I guess its depends what you do.

can you also say what versions of mco etc you have?
Hi,

This is all standard stuff from puppetlabs repo.

On the client:
rpm -qa|grep -i mco
mcollective-common-2.2.4-1.el5
mcollective-client-2.2.4-1.el5
mcollective-service-common-3.1.2-1
mcollective-filemgr-common-1.0.1-1
mcollective-sysctl-data-2.0.0-1
mcollective-facter-facts-1.0.0-1
mcollective-nrpe-agent-3.0.2-1
mcollective-filemgr-client-1.0.1-1
mcollective-nrpe-client-3.0.2-1
mcollective-2.2.4-1.el5
mcollective-nrpe-common-3.0.2-1
mcollective-puppet-common-1.6.0-1
mcollective-puppet-agent-1.6.0-1
mcollective-service-agent-3.1.2-1
mcollective-filemgr-agent-1.0.1-1
mcollective-service-client-3.1.2-1
mcollective-puppet-client-1.6.0-1

and on the server it's the same - installed at the same time, from
the
same
repo.

Same for the agent, it's nrpe agent from the package that doesn't
work,
I've added a few lines of debug and that's it. Here's the entire,
unmodified, agent:
cat /usr/libexec/mcollective/mcollective/agent/nrpe.rb
module MCollective
module Agent
class Nrpe<RPC::Agent

action "runcommand" do
reply[:exitcode], reply[:output] =
Nrpe.run(request[:command])
reply[:command] = request[:command]

case reply[:exitcode]
when 0
reply.statusmsg = "OK"

when 1
reply.fail "WARNING"

when 2
reply.fail "CRITICAL"

else
reply.fail "UNKNOWN"
end

if reply[:output] =~ /^(.+)\|(.+)$/
reply[:output] = $1
reply[:perfdata] = $2
else
reply[:perfdata] = ""
end
end

# Runs an Nrpe command and returns the command output and
exitcode
# If the command does not exist run will return exitcode 3.
#
# The Nrpe configuration directory and file containing checks
# must be specified in server.cfg
#
# Example :
# plugin.nrpe.conf_dir = /etc/nagios/nrpe
# plugin.nrpe.conf_file = checks.nrpe
def self.run(command)
nrpe_command = Nrpe.plugin_for_command(command)

return 3, "No such command: #{command}" unless nrpe_command

output = ""
shell = Shell.new(nrpe_command[:cmd], {:stdout => output,
:chomp
=>
true})
shell.runcommand
exitcode = shell.status.exitstatus

return exitcode, output
end

def self.plugin_for_command(command)
ret = nil
fname = nil
config = Config.instance

fdir = config.pluginconf["nrpe.conf_dir"] ||
"/etc/nagios/nrpe.d"
if config.pluginconf["nrpe.conf_file"]
fname = "#{fdir}/#{config.pluginconf['nrpe.conf_file']}"
else
fname = "#{fdir}/#{command}.cfg"
end

if File.exist?(fname)
File.readlines(fname).each do |check|
check.chomp!

if check =~ /command\[#{command}\]\s*=\s*(.+)$/
ret = {:cmd => $1}
end
end
end

ret
end
end
end
end


and the diff:
--- /usr/libexec/mcollective/mcollective/agent/nrpe.rb 2013-01-16
21:56:08.000000000 +0000
+++ nrpe.rb-with_debug 2013-07-05 07:52:46.000000000 +0100
@@ -38,15 +38,27 @@
# plugin.nrpe.conf_dir = /etc/nagios/nrpe
# plugin.nrpe.conf_file = checks.nrpe
def self.run(command)
+ Log.debug("HERE!!! in run")
nrpe_command = Nrpe.plugin_for_command(command)

return 3, "No such command: #{command}" unless nrpe_command

+ Log.debug("HERE!!! past plugin_for_command")
+
output = ""
+ Log.debug("HERE!!! output empty: #{output}")
+ Log.debug("HERE!!! trying to run Shell.new with
#{nrpe_command[:cmd]}")
+ #shell = Shell.new(nrpe_command[:cmd], {:stdout => output, :chomp
=> true})
+ #shell = Shell.new(nrpe_command[:cmd])
+ #shell = Shell.new()
+ #shell = Shell.new(nrpe_command[:cmd], {:stdout => output})
shell = Shell.new(nrpe_command[:cmd], {:stdout => output, :chomp
=> true})
+ Log.debug("HERE!!! past shell")
shell.runcommand
+ Log.debug("HERE!!! past shell.runcommand")
exitcode = shell.status.exitstatus

+ Log.debug("HERE!!! output: #{output}")
return exitcode, output
end

@@ -68,7 +80,9 @@
check.chomp!

if check =~ /command\[#{command}\]\s*=\s*(.+)$/
+ #Log.debug("HERE!!! check: #{check} : #{$1}")
ret = {:cmd => $1}
+ #Log.debug("HERE2!!! ret: #{ret}")
end
end
end


So to reiterate, this isn't my code, I just tried to install it and can't
get it to work. I've done it at least once before, few months ago,
and
behaviour was exactly the same, but I didn't have time to
investigate
back
then. It was most likely with git versions of nrpe plugin, but from
what
I
see not much has changed recently.
OK, thanks for the info, this is pretty strange.

Can you changing Shell.new... to ::MCollective::Shell.new...

Cool, this helped! When I get it to execute nagios plugin that executes
quickly, it's returning OK now, and didn't work before.
weird, then I wonder whats up with that, do you have perhaps an agent
called
shell installed?
Ah, yes, of course, I do. That explains it...

module MCollective
  module Agent
   class Shell < RPC::Agent

Maybe I'll just rename it, to avoid this conflict.


I get a timeout from a command that's taking 10 seconds to run (in essence
a wrapper around iostat 10 2) and would like to know how to increase this
timeout. I appreciate it might not make sense, plus that's a separate
issue, and one could argue it's a badly written plugin.
if your check takes 10 seconds thats probably longer than the timeout
defined in
the ddl..
OK, is there a way to configure this setting via plugin configuration? Or
does it make sense to make it configurable?

This long-running plugin is something I've been given that is supposed to
be standard across a lot of servers, not only those I manage, so I'm not
sure I'll be able to rewrite it in a sensible way. It could write a temp
file, read it, on every pass, making first pass always "unknown" or sth
like that, but that's completely irrelevant to this discussion.

Regards,
Daniel

--

---
You received this message because you are subscribed to the Google Groups "mcollective-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mcollective-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 4 | next ›
Discussion Overview
groupmcollective-users @
categoriespuppet
postedJul 4, '13 at 8:55p
activeJul 5, '13 at 1:58p
posts4
users2
websitepuppetlabs.com...

People

Translate

site design / logo © 2021 Grokbase