Obtain Passive Interval from a Plugin
Obtain Passive Interval from a Plugin
Hi.
Is it possible to get the nrds execution interval from inside a custom plugin?
I mean besides parsing a "crontab -l".
Thanks,
Rick
Is it possible to get the nrds execution interval from inside a custom plugin?
I mean besides parsing a "crontab -l".
Thanks,
Rick
Re: Obtain Passive Interval from a Plugin
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
Re: Obtain Passive Interval from a Plugin
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)?
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)?
Re: Obtain Passive Interval from a Plugin
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:
You can view the hostname in the crontab on the client:
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 INTERVALCode: Select all
crontab -u nagios -lBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: Obtain Passive Interval from a Plugin
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
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
Re: Obtain Passive Interval from a Plugin
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.
"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.
Re: Obtain Passive Interval from a Plugin
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:
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)
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 200It 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
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.
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.
Re: Obtain Passive Interval from a Plugin
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:
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.
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.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.
Re: Obtain Passive Interval from a Plugin
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