LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-05-2005, 11:49 AM   #1
notque
LQ Newbie
 
Registered: Sep 2004
Posts: 5

Rep: Reputation: 0
Nagios Event Handler not running - NRPE: Unable to read output


I have created an event handler to restart tomcat using all of our startup scripts etc.

The script works from the machine it resides on running as the Nagios user.

Using ./check_nrpe –H hostname –c cycle_tomcat CRITICAL HARD 3

Fails giving me

NRPE: Unable to read output

I currently use check_disk and several other plugins from nrpe successfully. If I make an echo script and call it, it returns fine.

I’ve added

Echo “cycle_tomcat” > /tmp/event-handler.out

As the very first line of the script, and that works.

I’ve also tried setting up the restart-httpd event handler that comes with Nagios, and get the exact same problem. If I run it from the machine as the Nagios user, it works perfectly. If I call it from nrpe, it fails and gives me NRPE: Unable to read output.

The permissions are overly broad right now to make sure there’s not a problem, although everything is owned by nagios, with 7, and other plugins inside of the directory work fine.

Currently my listing in nrpe for trying the restart-httpd script is

[restart-httpd]=/usr/lib/nagios/plugins/restart-httpd
 
Old 01-07-2005, 09:06 AM   #2
notque
LQ Newbie
 
Registered: Sep 2004
Posts: 5

Original Poster
Rep: Reputation: 0
This is a continuation to the previous problems I've been having.

I have created an event handler to restart a service on a remote machine. I am calling the execution of the event handler through check_nrpe using the -c flag.

The script runs fine on the server when run from the nagios user. The script starts fine if run through check_nrpe but dies half way through execution.

I have the timeout set high, and it is not timing out. An strace of the command being run through check_nrpe shows a broken pipe halfway through execution.

The script runs small things fine. Here I'm using sleep commands, and it takes a while for the whole thing to go, and again I'm getting a broken pipe.

First, Is check_nrpe intended to run event handlers in this manner.

Second, Would there be anything in the code of check_nrpe to fail if a given time frame was too long?

I get the same error on 2 different check_nrpe plugins. I'm calling it explicitly with arguments, so the Nagios server is irrelevant.

I can send the whole strace if you'd like, but it's incredibly large. Anything you could do to assist would be greatly appreciated.

My intention is if I cannot get this working, I'll probably move to calling the script via an event handler on the Nagios server through ssh commands with keys. I'd rather not do this, as this is my understanding to how event handlers should be called.

I do not have a very good understanding of strace output, and had someone else do the digging through it, but here's the part that he pointed to.

[ --- STRACE OUTPUT ON SCRIPT RAN THROUGH CHECK_NRPE, SNIPPIT --- ]

21633 write(1, "Using CATALINA_BASE: /opt/tomc"..., 41) = -1 EPIPE (Broken pip
e)
21633 --- SIGPIPE (Broken pipe) ---
21630 <... wait4 resumed> [WIFSIGNALED(s) && WTERMSIG(s) == SIGPIPE], 0, NULL) =
21633
21630 open("/usr/share/locale/locale.alias", O_RDONLY) = 3 21630 fstat64(3, {st_mode=S_IFREG|0644, st_size=2601, ...}) = 0 21630 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)

[ --- END STRACE --- ]

I've now forwarded all output as well to dev/null, and still get the error.
 
Old 12-20-2005, 01:24 PM   #3
fookanen
LQ Newbie
 
Registered: Apr 2005
Location: Franklin, TN
Distribution: Gentoo
Posts: 5

Rep: Reputation: 0
In response to the "NRPE: Unable to read output" error

I was able to solve this by checking my file/directory permissions. You need to grant read and execute privileges to the user which runs the nrpe daemon (this can be found in your nrpe config file).

For example, say your check plugins are located at:

/usr/local/nrpe/check_*

Then make sure that the daemon user has read and execute premissions to each directory leading up to the plugin: /usr, /usr/local, and /usr/local/nrpe.

You can do this with
chmod og+rx <directory>

Also, do the same for your plugins.

chmod og+rx /usr/local/nrpe/check_*

Hope this helps!

-fookanen
 
Old 03-02-2007, 10:54 AM   #4
rjholtz
LQ Newbie
 
Registered: Jun 2004
Location: Dekalb, IL
Distribution: Fedora Core 6
Posts: 2

Rep: Reputation: 0
This answer just helped me a lot. I had everything installed, but the check_* didn't have execute permissions. I applied that and all was good.

Thanks Everyone!
 
Old 03-05-2007, 10:54 AM   #5
gimecoffee
LQ Newbie
 
Registered: Mar 2007
Location: Oregon, USA
Distribution: Mandriva
Posts: 9

Rep: Reputation: 0
Quote:
Originally Posted by rjholtz
This answer just helped me a lot. I had everything installed, but the check_* didn't have execute permissions. I applied that and all was good.

Thanks Everyone!
I found a post a few days ago that suggested using sudo instead and I think it was a lot easier. Just a thought.

Rois
Your life is going somewhere whether you have a strategy or not. Experience the High Life. - http://www.sailingthroughlife.net

Last edited by gimecoffee; 03-29-2008 at 02:25 PM.
 
Old 07-20-2007, 05:38 AM   #6
QCM
LQ Newbie
 
Registered: Jul 2007
Posts: 1

Rep: Reputation: 0
good morning for all,
i have the same probleme and i am just on fedora core 6 but only directory change for the nagios install,
well the nrpe unable te read output persiste again:
i gave the right to all plugins under the host machine:
chmod og+rx /etc/nagios/plugins/
and then on the remote i checked the nrpe dameon, it does run , so i added the root user on the nrpe.cgi(hoping that work well but nothing run), i mean when i launch the command on the host nagios:
# check_nrpe -H 138.96.250.129
NRPE v2.7
but with the -c tags nothing to do:
check_nrpe -H private.one-lab.org -c check_users
NRPE: Unable to read output
and this is my nrpe.cgi file on the host nagios:
################
#############################################################################
# Sample NRPE Config File
# Written by: Ethan Galstad (nagios@nagios.org)
#
# Last Modified: 12-11-2006
#
# NOTES:
# This is a sample configuration file for the NRPE daemon. It needs to be
# located on the remote host that is running the NRPE daemon, not the host
# from which the check_nrpe client is being executed.
#############################################################################


# PID FILE
# The name of the file in which the NRPE daemon should write it's process ID
# number. The file is only written if the NRPE daemon is started by the root
# user and is running in standalone mode.

pid_file=/var/run/nrpe.pid



# PORT NUMBER
# Port number we should wait for connections on.
# NOTE: This must be a non-priviledged port (i.e. > 1024).
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

server_port=5666



# SERVER ADDRESS
# Address that nrpe should bind to in case there are more than one interface
# and you do not want nrpe to bind on all interfaces.
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

#server_address=192.168.1.1



# NRPE USER
# This determines the effective user that the NRPE daemon should run as.
# You can either supply a username or a UID.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

nrpe_user=nrpe,admin,root



# NRPE GROUP
# This determines the effective group that the NRPE daemon should run as.
# You can either supply a group name or a GID.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

nrpe_group=nrpe



# ALLOWED HOST ADDRESSES
# This is an optional comma-delimited list of IP address or hostnames
# that are allowed to talk to the NRPE daemon.
#
# Note: The daemon only does rudimentary checking of the client's IP
# address. I would highly recommend adding entries in your /etc/hosts.allow
# file to allow only the specified host to connect to the port
# you are running this daemon on.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

allowed_hosts=127.0.0.1,138.96.250.127,138.96.250.129,87.98.251.120



# COMMAND ARGUMENT PROCESSING
# This option determines whether or not the NRPE daemon will allow clients
# to specify arguments to commands that are executed. This option only works
# if the daemon was configured with the --enable-command-args configure script
# option.
#
# *** ENABLING THIS OPTION IS A SECURITY RISK! ***
# Read the SECURITY file for information on some of the security implications
# of enabling this variable.
#
# Values: 0=do not allow arguments, 1=allow command arguments

dont_blame_nrpe=1



# COMMAND PREFIX
# This option allows you to prefix all commands with a user-defined string.
# A space is automatically added between the specified prefix string and the
# command line from the command definition.
#
# *** THIS EXAMPLE MAY POSE A POTENTIAL SECURITY RISK, SO USE WITH CAUTION! ***
# Usage scenario:
# Execute restricted commmands using sudo. For this to work, you need to add
# the nagios user to your /etc/sudoers. An example entry for alllowing
# execution of the plugins from might be:
#
# nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/
#
# This lets the nagios user run all commands in that directory (and only them)
# without asking for a password. If you do this, make sure you don't give
# random users write access to that directory or its contents!

# command_prefix=/usr/bin/sudo



# DEBUGGING OPTION
# This option determines whether or not debugging messages are logged to the
# syslog facility.
# Values: 0=debugging off, 1=debugging on

debug=0



# COMMAND TIMEOUT
# This specifies the maximum number of seconds that the NRPE daemon will
# allow plugins to finish executing before killing them off.

command_timeout=60



# CONNECTION TIMEOUT
# This specifies the maximum number of seconds that the NRPE daemon will
# wait for a connection to be established before exiting. This is sometimes
# seen where a network problem stops the SSL being established even though
# all network sessions are connected. This causes the nrpe daemons to
# accumulate, eating system resources. Do not set this too low.

connection_timeout=300



# WEEK RANDOM SEED OPTION
# This directive allows you to use SSL even if your system does not have
# a /dev/random or /dev/urandom (on purpose or because the necessary patches
# were not applied). The random number generator will be seeded from a file
# which is either a file pointed to by the environment valiable $RANDFILE
# or $HOME/.rnd. If neither exists, the pseudo random number generator will
# be initialized and a warning will be issued.
# Values: 0=only seed from /dev/[u]random, 1=also seed from weak randomness

#allow_weak_random_seed=1



# INCLUDE CONFIG FILE
# This directive allows you to include definitions from an external config file.

#include=<somefile.cfg>



# INCLUDE CONFIG DIRECTORY
# This directive allows you to include definitions from config files (with a
# .cfg extension) in one or more directories (with recursion).

#include_dir=<somedirectory>
#include_dir=<someotherdirectory>



# COMMAND DEFINITIONS
# Command definitions that this daemon will run. Definitions
# are in the following format:
#
# command[<command_name>]=<command_line>
#
# When the daemon receives a request to return the results of <command_name>
# it will execute the command specified by the <command_line> argument.
#
# Unlike Nagios, the command line cannot contain macros - it must be
# typed exactly as it should be executed.
#
# Note: Any plugins that are used in the command lines must reside
# on the machine that this daemon is running on! The examples below
# assume that you have plugins installed in a /usr/local/nagios/libexec
# directory. Also note that you will have to modify the definitions below
# to match the argument format the plugins expect. Remember, these are
# examples only!

# The following examples use hardcoded command arguments...

command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_disk1]=/usr/lib/nagios/plugins/check_disk -w 20 -c 10 -p /dev/sda3
command[check_disk2]=/usr/lib/nagios/plugins/check_disk -w 20 -c 10 -p /dev/hdb1
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200

# The following examples allow user-supplied arguments and can
# only be used if the NRPE daemon was compiled with support for
# command arguments *AND* the dont_blame_nrpe directive in this
# config file is set to '1'...

#command[check_users]=/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$
#command[check_load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$
#command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
#command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
##########
so please any help will be welecome.
 
Old 08-15-2009, 07:08 PM   #7
gnucom
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
Event handlers in nagios using NRPE.

Hey all,

I just got through this one and thought all of your comments were very helpful. I wrote a small post about my experience here that has an example of using NRPE to issue remote event handlers.

Check it out: http://blog.gnucom.cc/2009/event-han...os-using-nrpe/

Let me know if you all have any questions or comments!

Last edited by gnucom; 07-23-2010 at 01:20 PM. Reason: Updated links to page.
 
Old 04-05-2013, 06:27 AM   #8
grzeslaw
LQ Newbie
 
Registered: Nov 2008
Posts: 27

Rep: Reputation: 13
In my case, that error appear because there was wrong path to the service check in nrpe.cfg.
 
  


Reply

Tags
event, handler, nagios, nrpe


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios Addon NRPE didnt start? dwarf007 Linux - Software 3 04-27-2011 01:38 AM
Nagios/nrpe: SSL Issues Killbot_5000 Linux - Security 18 09-21-2010 05:27 PM
Nagios NRPE twantrd Linux - Software 1 10-20-2004 08:24 AM
:-( unable to GET EVENT: Input/output error WilliamS Slackware 1 10-12-2004 02:22 PM
TCP-IP event-handler in a Linux server Zingaro2002 Linux - Networking 4 06-06-2002 10:05 AM


All times are GMT -5. The time now is 06:29 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration