Executing event Handlers to correct action
Re: Executing event Handlers to correct action
It executed successfully as nagios user on remote machine and does what it supposed to do, but when i run using nrpe it failed.
./check_nrpe -H localhost -c remove_core
NRPE: Unable to read output
./check_nrpe -H localhost -c remove_core
NRPE: Unable to read output
Re: Executing event Handlers to correct action
This may be a sudo path issue.
Run this command on the remote system:
Then edit your command and change it to:
- Change /full/path/to/sudo to the the full path listed from the command above
- The 2>&1 redirects stderr to stdout so you can see the error
- The sudo path change may fix it, if it doesn't the 2>&1 should allow us to see what the issue is
The restart NRPE.
Now run this command from the other machine and post the full output:
Thank you
Run this command on the remote system:
Code: Select all
which sudo- Change /full/path/to/sudo to the the full path listed from the command above
- The 2>&1 redirects stderr to stdout so you can see the error
- The sudo path change may fix it, if it doesn't the 2>&1 should allow us to see what the issue is
Code: Select all
command[remove_core]=/full/path/to/sudo /usr/local/nagios/libexec/remove_core.sh 2>&1Now run this command from the other machine and post the full output:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H remote_host_IP -c remove_core Thank you
Re: Executing event Handlers to correct action
Please see the output below.
#which sudo
/bin/sudo
changed command[remove_core]=/bin/sudo /usr/local/nagios/libexec/remove_core.sh 2>&1 , restarted nrpe and ran
from Nagios server:
]# ./check_nrpe -H remote_ip-c remove_core
NRPE: Unable to read output
on remote machine:
]# ./check_nrpe -H localhost -c remove_core
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
I can run as normal user, but when i run as nagios user same error as above.
in sudo i have as below.
nagios ALL = NOPASSWD:/usr/local/nagios/libexec/remove_core.sh
nagios ALL = NOPASSWD:/bin/rm -f /var/core/core*
nagios ALL = NOPASSWD:/bin/rm -f /data/was/current/resources/Snap*
nagios ALL = NOPASSWD:/bin/rm -f /data/was/current/resources/javacore*
nagios ALL = NOPASSWD:/bin/rm -f /data/was/current/resources/heap*
The script i have is as follows,
#!/bin/bash
/bin/sudo /bin/rm -f /data/was/current/resources/Snap*;
/bin/sudo /bin/rm -f /data/was/current/resources/javacore*;
/bin/sudo /bin/rm -f /data/was/current/resources/heap*;
/bin/sudo /bin/rm -f /var/core/core*;
Is it ok to run as script for event handlers or need any changes in the script?
#which sudo
/bin/sudo
changed command[remove_core]=/bin/sudo /usr/local/nagios/libexec/remove_core.sh 2>&1 , restarted nrpe and ran
from Nagios server:
]# ./check_nrpe -H remote_ip-c remove_core
NRPE: Unable to read output
on remote machine:
]# ./check_nrpe -H localhost -c remove_core
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
I can run as normal user, but when i run as nagios user same error as above.
in sudo i have as below.
nagios ALL = NOPASSWD:/usr/local/nagios/libexec/remove_core.sh
nagios ALL = NOPASSWD:/bin/rm -f /var/core/core*
nagios ALL = NOPASSWD:/bin/rm -f /data/was/current/resources/Snap*
nagios ALL = NOPASSWD:/bin/rm -f /data/was/current/resources/javacore*
nagios ALL = NOPASSWD:/bin/rm -f /data/was/current/resources/heap*
The script i have is as follows,
#!/bin/bash
/bin/sudo /bin/rm -f /data/was/current/resources/Snap*;
/bin/sudo /bin/rm -f /data/was/current/resources/javacore*;
/bin/sudo /bin/rm -f /data/was/current/resources/heap*;
/bin/sudo /bin/rm -f /var/core/core*;
Is it ok to run as script for event handlers or need any changes in the script?
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Executing event Handlers to correct action
I believe you are going to need to add the following to your sudoers if not present
Code: Select all
Defaults:nagios !requirettyRe: Executing event Handlers to correct action
made the changes as suggested, but the results are the same its not working.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Executing event Handlers to correct action
One thing I noticed, is that your script has no output
Which would lead to
Can you change the script to
Code: Select all
#!/bin/bash
/bin/sudo /bin/rm -f /data/was/current/resources/Snap*;
/bin/sudo /bin/rm -f /data/was/current/resources/javacore*;
/bin/sudo /bin/rm -f /data/was/current/resources/heap*;
/bin/sudo /bin/rm -f /var/core/core*;Code: Select all
NRPE: Unable to read outputCode: Select all
#!/bin/bash
/bin/sudo /bin/rm -f /data/was/current/resources/Snap*;
/bin/sudo /bin/rm -f /data/was/current/resources/javacore*;
/bin/sudo /bin/rm -f /data/was/current/resources/heap*;
/bin/sudo /bin/rm -f /var/core/core*;
echo "Files deleted";Re: Executing event Handlers to correct action
./check_nrpe -H localhost -c remove_core
Files deleted
ls -ltr /var/core/
-rw-r--r-- 1 nagios nagios 0 Jun 9 09:54 core3
But the files weren't deleted.
Files deleted
ls -ltr /var/core/
-rw-r--r-- 1 nagios nagios 0 Jun 9 09:54 core3
But the files weren't deleted.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Executing event Handlers to correct action
I'm not sure what timezone you are in but the timestamp on that empty file is pretty recent, are you sure it isn't being automatically re-created?