Finally I managed to run the script with NRPE using root privilegies.<br><br><br>The script didn't work. I tried with one of the NRPE samples adding sudo to the command definition:<br><br>command[check_users]=sudo /usr/lib/nagios/plugins/check_users -w 5 -c 10<br>
<br><br>I commented the command_prefix option and I commented require_tty in the sudoers file<br><br>#Defaults requiretty<br><br><br>I think this last option is needed If you're passing parameters to the script.<br>
<br><br><br>Thanks,<br><br><br><br><div class="gmail_quote">2009/4/24 Luis Sanchez <span dir="ltr"><<a href="mailto:luis.sanchez.sanchez@gmail.com">luis.sanchez.sanchez@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I'm trying to run a script in a remote machine using root privileges (this is just a simple sample, just some output to a file).<br><br><br>I run this command from the nagios server machine:<br><br>/usr/lib/nagios/plugins/check_nrpe -H 192.168.168.33 -p 5666 -c service_restart<br>
<br><br>and I get this error message:<br><br>NRPE: Unable to read output<br><br><br>I have added nagios user to the sudoers list (all the privileges to avoid permission problems). The NRPE daemon is started and listening in the correct port.<br>
<br>The NRPE log in the monitorized machine is (no reference to the error):<br><br>Apr 24 15:06:49 outrun nrpe[26716]: INFO: SSL/TLS initialized. All network traffic will be encrypted.<br>Apr 24 15:06:49 outrun nrpe[26717]: Starting up daemon<br>
Apr 24 15:06:49 outrun nrpe[26717]: Warning: Daemon is configured to accept command arguments from clients!<br>Apr 24 15:06:49 outrun nrpe[26717]: Listening for connections on port 5666<br>Apr 24 15:06:49 outrun nrpe[26717]: Allowing connections from: 192.168.168.20,127.0.0.1<br>
<br><br>If I change the nrpe configuration and comment command_prefix option. It works.<br><br><br>I'm using centos 5.2 in the monitorized machine and the monitoring machine.<br>The NRPE version is 2.12 and nagios server version is 3.0.6<br>
<br><br>This is just a test to check how to execute commands being root. In fact the real aim is use event handlers to autoheal the monitorized machine by restarting a service if it gets down.<br><br>Any idea on how to solve the problem? <br>
Thank you very much for your help<br><br>BTW hereunder you can find more configuration data.<br><br><br>MONITORIZED REMOTE MACHINE /etc/sudoers<br>-----------------------------------------------------<br><br>nagios ALL=(ALL) NOPASSWD: ALL<br>
<br><br><br>MONITORIZED REMOTE MACHINE NRPE CONFIGURATION<br>-------------------------------------------------------------------<br>log_facility=daemon<br>pid_file=/var/run/nrpe.pid<br>server_port=5666<br>nrpe_user=nagios<br>
nrpe_group=nagios<br>allowed_hosts=192.168.168.20,127.0.0.1<br><br>dont_blame_nrpe=1<br>command_prefix=/usr/bin/sudo<br>debug=1<br>command_timeout=60<br>connection_timeout=300<br>command[service_restart]=/usr/lib/nagios/plugins/service_restart<br>
<br><br>MONITORIZED REMOTE MACHINE SCRIPT IN /usr/lib/nagios/plugins/service_restart<br>------------------------------------------------------------------------<br>#!/bin/sh<br>#<br># Event handler script for restarting the web server on the local machine<br>
#<br># Note: This script will only restart the web server if the service is<br># retried 3 times (in a "soft" state) or if the web service somehow<br># manages to fall into a "hard" error state.<br>
#<br><br>whoami >> /tmp/asd.txt<br>echo -n "hola" >> /tmp/asd.txt<br>exit 0<br><br>
</blockquote></div><br>