Obtain Passive Interval from a Plugin

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
grenley
Posts: 96
Joined: Tue May 13, 2014 6:06 pm

Obtain Passive Interval from a Plugin

Post by grenley »

Hi.

Is it possible to get the nrds execution interval from inside a custom plugin?
I mean besides parsing a "crontab -l".

Thanks,
Rick
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Obtain Passive Interval from a Plugin

Post by tmcdonald »

I just looked through the whole NRDS installer you get when you deploy the NRDS agent, and the only place the interval is stored is in that cron entry.
Former Nagios employee
grenley
Posts: 96
Joined: Tue May 13, 2014 6:06 pm

Re: Obtain Passive Interval from a Plugin

Post by grenley »

okay. thanks.
Then, to make this easier, is there a way to get the Service name that the plugin is running under and which nrds config file invoked it (we may end up using multiple nrds configs)?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Obtain Passive Interval from a Plugin

Post by lmiltchev »

When you open the config under the "NRDS Config" in Nagios XI, you can view the commands (the names of the checks, i.e. "Check Disk", "Check Users", etc.). These are going to be your services.

If the host hasn't been configured yet, you will find it in the Unconfigured Objects.

The name of the host is whatever you set up, when you were installing NRDS on the client:

Code: Select all

./installnrds HOSTNAME INTERVAL
You can view the hostname in the crontab on the client:

Code: Select all

crontab -u nagios -l
Be sure to check out our Knowledgebase for helpful articles and solutions!
grenley
Posts: 96
Joined: Tue May 13, 2014 6:06 pm

Re: Obtain Passive Interval from a Plugin

Post by grenley »

Thanks for your reply.
I do understand all that.
What I'm trying to do is, from inside a custom plugin, is there a way to determine, programmatically, what service name this invocation of the plugin was called from and what nrds config file name called it
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Obtain Passive Interval from a Plugin

Post by abrist »

Unfortunately, no. If it was an active check, we could write a custom wrapper script to grab and pass certain nagios macros to the check plugin. But as it is a passive check, there is no way to fetch this type of config information remotely. You would have to write a custom php script to brag, parse, and serve up this information to be grabbed through a curl/wget/etc from the remote passive check.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
grenley
Posts: 96
Joined: Tue May 13, 2014 6:06 pm

Re: Obtain Passive Interval from a Plugin

Post by grenley »

I'm not looking for it remotely (i.e., from the XI server).
I want to get that info from the plugin as it is run on the agent.
I need it to set certain values based on the service name, etc.

So, let's say I have an entry in nrds.cfg:

Code: Select all

command[Test_MyPlugin]=/usr/local/nagios/libexec/check_myplugin -c 200
I would like to know, within the check_myplugin script, that my service name was Test_MyPlugin.
It would also be nice to know that the cfg file that this service was defined in was nrds.cfg (rather than some other cfg file)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Obtain Passive Interval from a Plugin

Post by scottwilkerson »

Actually, it will match whatever you have in the particular NRDS configuration you have on the XI server.

NRDS automagically will update the configuration on the remote host to the current version, so the value will always match what is on the XI server.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
grenley
Posts: 96
Joined: Tue May 13, 2014 6:06 pm

Re: Obtain Passive Interval from a Plugin

Post by grenley »

Looking at the nrds.pl script, it appears you can pass whatever cfg file you want and it will process.
I don't see where it would have to be nrds.cfg.
So, I was thinking we could have multiple crons on the nrds agent, say for different applications:

Code: Select all

*/2 * * * * /usr/local/nrdp/clients/nrds/nrds.pl -H '123.45.67.89' 2>&1
*/2 * * * * /usr/local/nrdp/clients/nrds/nrds.pl -H '123.45.67.89' -config 'app1.cfg' 2>&1
etc.
So, I would want to know, for this plugin invocation, what cfg file it came from and what the service name was.
That would create a kind of "unique key" I could use for various things.

That's the info I'm hoping is available to my plugin running on the agent.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Obtain Passive Interval from a Plugin

Post by tmcdonald »

The plugin would not have any idea what config file it was pulled from. It can make a guess based off its own name, since check_users is for the "Check Users" service, but your plugins would need to follow that naming convention.
Former Nagios employee
Locked