NRPE Configuration Question

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

NRPE Configuration Question

Post by BanditBBS »

I started another thread asking some questions about NRDS, but I'd really prefer to continue using NRPE and have active checks instead of passive. The major issue isn't getting to scripts copied up to the servers, the issue is having to update nrpe.cfg and restart NRPE when adding a completely new command.

My question is, is there a way to add new command definitions without having to restart NRPE?
  • I see in the config file a, "include" variable that will include definitions from an external file. If I use that an modify the definitions in the included file, does NRPE need restarted?
  • The other option I thought of was adding a command definition of "command[check_whatever]=/usr/opt/nagios/libexec/$ARG1$ $ARG2$ $ARG3$" I think that would work, but I'd prefer the include option if it works as I hope.
Thanks again!
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NRPE Configuration Question

Post by abrist »

BanditBBS wrote: If I use that an modify the definitions in the included file, does NRPE need restarted?
I am just full of bad news today. NRPE reads the configs on startup of the service, these are retained in memory as the service is running. During startup, it will follow the include tree defined in the nrpe.cfg, but only during startup. This is why it requires a restart.
BanditBBS wrote:The other option I thought of was adding a command definition of "command[check_whatever]=/usr/opt/nagios/libexec/$ARG1$ $ARG2$ $ARG3$" I think that would work, but I'd prefer the include option if it works as I hope.
This is quite clever, I am interested as to whether this works or not. Though your security team may be less than happy with the implementation as it would widen the potential security problems of nrpe. I would suggest that you make sure that there are no plugins of the "dangerous" sort in libexec before deployment, or maybe create a nested directory in libexec for the additional scripts:

Code: Select all

command[check_whatever]=/usr/opt/nagios/libexec/bandits_scripts/$ARG1$ $ARG2$ $ARG3$
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.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: NRPE Configuration Question

Post by BanditBBS »

I have mentioned my security dept a few times, haven't I? :)

What they don't know won't hurt them! Actually, locked down by IP and other measures of security should be good. I'll be testing this just as soon as one of the AIX admins gets back and restarts NRPE so I can test.

Jim
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: NRPE Configuration Question

Post by sreinhardt »

Just to add a hopeful note to abrist's depression inducing line of answers. Starting with core, and potentially moving to agents, this may be something I am going to look at remedying after the conference, depending on how we are handling it in memory. If the structures are similar to objects.cache, and I just need to modify a few additional functions and lists, it should be done relatively shortly.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NRPE Configuration Question

Post by abrist »

BanditBBS wrote:I have mentioned my security dept a few times, haven't I?
We have the memories of elephants up here in MN. :)
BanditBBS wrote: I'll be testing this just as soon as one of the AIX admins gets back and restarts NRPE so I can test.

How many admins does it take to restart a benign service?

Only one, because there is only one true admin, but he works in mysterious ways. Have you prostrated recently? :P
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.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: NRPE Configuration Question

Post by BanditBBS »

That command definition works! I will no longer need to restart NRPE after one final update to the config file. The other security on this is, a 'hacker' would have to know the command definition name to even execute it, si I could call it check_jhsgjhfgfghasdfhgadf. Good luck guessing that :) Thats if you can get past the allowed_from directive also.

Jim/Bandit
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NRPE Configuration Question

Post by abrist »

I started a doc concerning advanced nrpe tips a while back - this one is definitely getting added before it hits the nagios library.
BanditBBS wrote: The other security on this is, a 'hacker' would have to know the command definition name to even execute it, si I could call it check_jhsgjhfgfghasdfhgadf. Good luck guessing that :) Thats if you can get past the allowed_from directive also.
Even if they knew the command, compromised your network, and mitm'ed the connection, they would still have the ssl issue to get around. You do use ssl right? :P

One other security hole I thought about - could you pass relative paths through it? For example:

Code: Select all

command[check_whatever]=/usr/opt/nagios/libexec/$ARG1$ $ARG2$ $ARG3$
$ARG1$ = "../../../../bin/bash"
$ARG2$ = "<nasty shell code here>"
I would assume you could pass relative paths like the command above. The best way to implement this, may be to pass the command to a wrapper script that can attempt to do some sanity checking/scrubbing of the input before passing it to the shell. But then again, that would be pita, and would nearly reproduce what nrpe already does. If you trust your network, it is probably not a big deal, though it would be an abdication of my responsibility to at least not mention it.
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.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: NRPE Configuration Question

Post by BanditBBS »

I plead the 5th about ssl and I trust my network for the other issues mentioned.

Jim
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NRPE Configuration Question

Post by abrist »

And on that note - should we lock this up proper?
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.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: NRPE Configuration Question

Post by BanditBBS »

abrist wrote:And on that note - should we lock this up proper?
Yes sir, I'm good with this being locked.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Locked