Custom Actions Question
Custom Actions Question
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?
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
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
Re: Custom Actions Question
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:
ping.sh
I didn't need to modify the sudoers.
In the Actions component:
Code: Select all
/usr/local/nagios/libexec/ping.sh %hostaddress%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 0Code: Select all
ll ping.sh
-rwxr-xr-- 1 nagios nagios 97 Nov 6 12:37 ping.shBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: Custom Actions Question
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
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
Something like this?
NEWSCRIPT.sh
visudo
Add action for
NEWSCRIPT.sh
Code: Select all
#!/bin/bash
sudo -i -u nagios /usr/local/nagios/libexec/cdm-update.sh $1
Code: Select all
apache ALL = NOPASSWD:/usr/local/nagios/libexec/NEWSCRIPT.sh *Code: Select all
/usr/local/nagios/libexec/NEWSCRIPT.sh %hostaddress%Re: Custom Actions Question
@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.
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!
Re: Custom Actions Question
Please. if it doesn't work for me I'll then post in much more detail what I'm trying to do.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.
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
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
Re: Custom Actions Question
I sent you a PM.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Custom Actions Question
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!
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
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
Re: Custom Actions Question
Yeah, as I said, this could be a security issue. I worked for me, but I didn't like the "workaround", either.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.
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!