I am trying to setup event handler for ntpd service..
i created event handler script that restarts ntpd using command "/etc/init.d/ntpd restart" in nagios core.
on the remote server, i have below entries in the sudoers file
nagios ALL=NOPASSWD: /usr/sbin/ntpd
Defaults:nagios !requiretty
nagios ALL= NOPASSWD: /etc/init.d/ntpd restart
problem is it keeps throwing the errors "sudo: no tty present and no askpass program specified"..
when i run the restart command as nagios user on the server it works fine
su -s /bin/bash nagios
sudo -u root /etc/init.d/ntpd restart -- this works
but through event handler its not workking..am i missing something here ?
pls help
Shan
event handler issue
Re: event handler issue
correction : my event handler script has the entry - "sudo -u root /etc/init.d/ntpd restart" (because my ntpd script will work only if the UID matches to zero)
Re: event handler issue
Are you trying to restart ntpd on a remote server or the local Nagios server?
If it is a remote server, the following link is a guide for setting that up.
https://assets.nagios.com/downloads/nag ... h_NRPE.pdf
It says it is for Nagios XI but is should work just the same.
If it is a remote server, the following link is a guide for setting that up.
https://assets.nagios.com/downloads/nag ... h_NRPE.pdf
It says it is for Nagios XI but is should work just the same.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: event handler issue
Event handlers run without a TTY. Sudo complains if it's being executed without a TTY; that's the error you're seeing.
Your "!requiretty" command needs to be before any specific commands in your sudoers file:
Your "!requiretty" command needs to be before any specific commands in your sudoers file:
Code: Select all
Defaults:nagios !requiretty
nagios ALL=NOPASSWD: /usr/sbin/ntpd
nagios ALL= NOPASSWD: /etc/init.d/ntpd restart
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Re: event handler issue
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/