Custom Actions 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:

Custom Actions Question

Post by BanditBBS »

Ok, so I can guess the custom actions component is running commands as apache, right?

If I am correct on that, what on earth do I need to add to the sudoers file to allow apache to run this command: sudo -i -u nagios /usr/local/nagios/libexec/cdm-update.sh %hostaddress%

Any ideas?
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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Custom Actions Question

Post by lmiltchev »

Is there any reason why you want to use "sudo -i -u nagios"? I tried the following scenario, which worked OK for me.

In the Actions component:

Code: Select all

/usr/local/nagios/libexec/ping.sh %hostaddress%
ping.sh

Code: Select all

#!/bin/bash

/usr/local/nagios/libexec/check_ping -H $1 -w 100.0,20% -c 500.0,60% -p 3 -4
exit 0

Code: Select all

ll ping.sh
-rwxr-xr-- 1 nagios nagios 97 Nov  6 12:37 ping.sh
I didn't need to modify the sudoers.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Custom Actions Question

Post by BanditBBS »

I need it executed as nagios from nagios' shell. The script does some scp and for key issues it needs to be as nagios.
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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Custom Actions Question

Post by scottwilkerson »

Something like this?

NEWSCRIPT.sh

Code: Select all

#!/bin/bash
sudo -i -u nagios /usr/local/nagios/libexec/cdm-update.sh $1

visudo

Code: Select all

apache ALL = NOPASSWD:/usr/local/nagios/libexec/NEWSCRIPT.sh *
Add action for

Code: Select all

/usr/local/nagios/libexec/NEWSCRIPT.sh %hostaddress%
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Custom Actions Question

Post by lmiltchev »

@BanditBBS
I tried something similar and it worked but this could be a security issue... I can PM you my configs if you want me to.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Custom Actions Question

Post by BanditBBS »

lmiltchev wrote:@BanditBBS
I tried something similar and it worked but this could be a security issue... I can PM you my configs if you want me to.
Please. if it doesn't work for me I'll then post in much more detail what I'm trying to do.
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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Custom Actions Question

Post by lmiltchev »

I sent you a PM.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Custom Actions Question

Post by BanditBBS »

Go ahead and close this up!

Your PM didn't work for me, but it was along the same lines I was going and eventually it would have ended up being security issue. So, instead I created a couple scripts to output the hostaddress to a file and put those as actions. Then I just put a cron job in for nagios that runs every 5 minutes that uses those files.

Thanks for trying though!
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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Custom Actions Question

Post by lmiltchev »

Your PM didn't work for me, but it was along the same lines I was going and eventually it would have ended up being security issue.
Yeah, as I said, this could be a security issue. I worked for me, but I didn't like the "workaround", either. :)
I am glad you found a better way!
I am locking this topic.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked