You are here

check_log not defined

7 posts / 0 new
Last post
Sandra Fredenburgh
sandra.fredenburgh's picture
check_log not defined

Sorry for the newb inquiry. I am new to nagios and trying to set up a basic log monitor script. It appears that the check_log plugin is installed on my systems. This config should be relatively simple; however, I am running into a wall when I try to run the command from my server using nrpe:

/usr/local/nagios/libexec/check_nrpe -H 1.2.3.4 -c /usr/local/nagios/libexec/check_log -a /data01/home/s604367/apache-tomcat*/logs/catalina.out
NRPE: Command '/usr/local/nagios/libexec/check_log' not defined

The check_nrpe function is working since I am able to check other functionality.

The command is defined in checkcommands.cfg
define command {
command_name check_log
command_line /usr/local/nagios/libexec/check_log $ARG1$
}

The command runs flawlessly locally on the client:
/usr/local/nagios/libexec/check_log -F /data01/home/s604367/apache-tomcat*/logs/catalina.out -O /tmp/foo.log -q "exception|severe|corba.timeout"
Log check ok - 0 pattern matches found

I have checked permisioning and even added user nagios to sudoers. Nothing seems to get this dumb plugin working. I am about ready to configure the check_logfiles plugin instead. I just don't understand why the basic check_log is not working for me

Any guidance would be appreciated.

#############################################################################
# NRPE Config File for Opsview - DO NOT AMEND THIS FILE!
#
# NOTES
# This is the 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.
############################################################################>
#
# DO NOT AMEND THIS FILE
#
# This file will be overwritten on an upgrade.  Changes should be made in
#     /usr/local/nagios/etc/nrpe_local/override.cfg
# which will not be changed on an upgrade.
#
#############################################################################<br />
<br />
<br />
# LOG FACILITY<br />
# The syslog facility that should be used for logging purposes.<br />
<br />
log_facility=daemon<br />
<br />
<br />
<br />
# PID FILE<br />
# The name of the file in which the NRPE daemon should write it's process ID<br />
# number.&nbsp; The file is only written if the NRPE daemon is started by the root<br />
# user and is running in standalone mode.<br />
<br />
pid_file=/var/tmp/nrpe.pid<br />
<br />
<br />
<br />
# PORT NUMBER<br />
# Port number we should wait for connections on.<br />
# NOTE: This must be a non-priviledged port (i.e. &gt; 1024).<br />
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd<br />
<br />
server_port=5666<br />
<br />
<br />
<br />
# SERVER ADDRESS<br />
# Address that nrpe should bind to in case there are more than one interface<br />
# and you do not want nrpe to bind on all interfaces.<br />
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd<br />
<br />
#server_address=127.0.0.1<br />
<br />
<br />
<br />
# NRPE USER<br />
# This determines the effective user that the NRPE daemon should run as.<br />
# You can either supply a username or a UID.<br />
#<br />
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd<br />
<br />
nrpe_user=nagios<br />
<br />
<br />
<br />
# NRPE GROUP<br />
# This determines the effective group that the NRPE daemon should run as.<br />
# You can either supply a group name or a GID.<br />
#<br />
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd<br />
<br />
nrpe_group=nagios<br />
<br />
<br />
<br />
# ALLOWED HOST ADDRESSES<br />
# This is an optional comma-delimited list of IP address or hostnames<br />
# that are allowed to talk to the NRPE daemon.<br />
#<br />
# Note: The daemon only does rudimentary checking of the client's IP<br />
# address.&nbsp; I would highly recommend adding entries in your /etc/hosts.allow<br />
# file to allow only the specified host to connect to the port<br />
# you are running this daemon on.<br />
#<br />
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd<br />
<br />
#allowed_hosts=127.0.0.1<br />
<br />
<br />
<br />
# COMMAND ARGUMENT PROCESSING<br />
# This option determines whether or not the NRPE daemon will allow clients<br />
# to specify arguments to commands that are executed.&nbsp; This option only works<br />
# if the daemon was configured with the --enable-command-args configure script<br />
# option.<br />
#<br />
# *** ENABLING THIS OPTION IS A SECURITY RISK! ***<br />
# Read the SECURITY file for information on some of the security implications<br />
# of enabling this variable.<br />
#<br />
# Values: 0=do not allow arguments, 1=allow command arguments<br />
<br />
dont_blame_nrpe=1<br />
<br />
<br />
<br />
# COMMAND PREFIX<br />
# This option allows you to prefix all commands with a user-defined string.<br />
# A space is automatically added between the specified prefix string and the<br />
# command line from the command definition.<br />
#<br />
# *** THIS EXAMPLE MAY POSE A POTENTIAL SECURITY RISK, SO USE WITH CAUTION! ***<br />
# Usage scenario:<br />
# Execute restricted commmands using sudo.&nbsp; For this to work, you need to add<br />
# the nagios user to your /etc/sudoers.&nbsp; An example entry for alllowing<br />
# execution of the plugins from might be:<br />
#<br />
# nagios&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/<br />
#<br />
# This lets the nagios user run all commands in that directory (and only them)<br />
# without asking for a password.&nbsp; If you do this, make sure you don't give<br />
# random users write access to that directory or its contents!<br />
<br />
# command_prefix=/usr/bin/sudo<br />
<br />
<br />
<br />
# DEBUGGING OPTION<br />
# This option determines whether or not debugging messages are logged to the<br />
# syslog facility.<br />
# Values: 0=debugging off, 1=debugging on<br />
<br />
debug=0<br />
<br />
<br />
<br />
# COMMAND TIMEOUT<br />
# This specifies the maximum number of seconds that the NRPE daemon will<br />
# allow plugins to finish executing before killing them off.<br />
<br />
command_timeout=60<br />
<br />
<br />
<br />
# CONNECTION TIMEOUT<br />
# This specifies the maximum number of seconds that the NRPE daemon will<br />
# wait for a connection to be established before exiting. This is sometimes<br />
# seen where a network problem stops the SSL being established even though<br />
# all network sessions are connected. This causes the nrpe daemons to<br />
# accumulate, eating system resources. Do not set this too low.<br />
<br />
#connection_timeout=300<br />
<br />
<br />
<br />
# WEEK RANDOM SEED OPTION<br />
# This directive allows you to use SSL even if your system does not have<br />
# a /dev/random or /dev/urandom (on purpose or because the necessary patches<br />
# were not applied). The random number generator will be seeded from a file<br />
# which is either a file pointed to by the environment valiable $RANDFILE<br />
# or $HOME/.rnd. If neither exists, the pseudo random number generator will<br />
# be initialized and a warning will be issued.<br />
# Values: 0=only seed from /dev/[u]random, 1=also seed from weak randomness<br />
<br />
#allow_weak_random_seed=1<br />
<br />
<br />
<br />
# INCLUDE CONFIG FILE<br />
# This directive allows you to include definitions from an external config file.<br />
<br />
#include=&lt;somefile.cfg&gt;<br />
<br />
<br />
<br />
# INCLUDE CONFIG DIRECTORY<br />
# This directive allows you to include definitions from config files (with a<br />
# .cfg extension) in one or more directories (with recursion).<br />
<br />
#include_dir=&lt;somedirectory&gt;<br />
#include_dir=&lt;someotherdirectory&gt;<br />
<br />
<br />
<br />
# COMMAND DEFINITIONS<br />
# Command definitions that this daemon will run.&nbsp; Definitions<br />
# are in the following format:<br />
#<br />
# command[&lt;command_name&gt;]=&lt;command_line&gt;<br />
#<br />
# When the daemon receives a request to return the results of &lt;command_name&gt;<br />
# it will execute the command specified by the &lt;command_line&gt; argument.<br />
#<br />
# Unlike Nagios, the command line cannot contain macros - it must be<br />
# typed exactly as it should be executed.<br />
#<br />
# Note: Any plugins that are used in the command lines must reside<br />
# on the machine that this daemon is running on!&nbsp; The examples below<br />
# assume that you have plugins installed in a /usr/local/nagios/libexec<br />
# directory.&nbsp; Also note that you will have to modify the definitions below<br />
# to match the argument format the plugins expect.&nbsp; Remember, these are<br />
# examples only!<br />
<br />
# All entries should be in the following form<br />
<br />
command[check_users]=/usr/local/nagios/libexec/check_users $ARG1$<br />
command[check_load]=/usr/local/nagios/libexec/check_load $ARG1$<br />
command[check_disk]=/usr/local/nagios/libexec/check_disk $ARG1$<br />
command[check_swap]=/usr/local/nagios/libexec/check_swap $ARG1$<br />
command[check_procs]=/usr/local/nagios/libexec/check_procs $ARG1$<br />
command[check_memory]=/usr/local/nagios/libexec/check_memory $ARG1$<br />
command[check_file_age]=/usr/local/nagios/libexec/check_file_age $ARG1$<br />
command[check_dir_age]=/usr/local/nagios/libexec/check_dir_age $ARG1$<br />
command[check_mailq]=/usr/local/nagios/libexec/check_mailq $ARG1$<br />
command[check_hpjd]=/usr/local/nagios/libexec/check_hpjd $ARG1$<br />
command[check_ntp]=/usr/local/nagios/libexec/check_ntp $ARG1$<br />
command[check_ntp_peer]=/usr/local/nagios/libexec/check_ntp_peer $ARG1$<br />
command[check_ntp_time]=/usr/local/nagios/libexec/check_ntp_time $ARG1$<br />
command[check_snmp]=/usr/local/nagios/libexec/check_snmp $ARG1$<br />
command[check_time]=/usr/local/nagios/libexec/check_time $ARG1$<br />
command[check_tcp]=/usr/local/nagios/libexec/check_tcp $ARG1$<br />
command[check_cluster]=/usr/local/nagios/libexec/check_cluster $ARG1$<br />
command[check_ide_smart]=/usr/local/nagios/libexec/check_ide_smart $ARG1$<br />
command[check_postgres]=/usr/local/nagios/libexec/check_postgres $ARG1$<br />
command[check_time_skew]=/usr/local/nagios/libexec/check_time_skew $ARG1$<br />
command[check_ro_mounts]=/usr/local/nagios/libexec/check_ro_mounts $ARG1$<br />
command[check_raid]=/usr/local/nagios/libexec/check_raid $ARG1$<br />
command[check_smart]=/usr/local/nagios/libexec/check_smart -d $ARG1$<br />
command[check_cpu_stats]=/usr/local/nagios/libexec/check_cpu_stats $ARG1$<br />
command[check_docker]=/usr/local/nagios/libexec/check_docker $ARG1$<br />
command[check_log]=/usr/local/nagios/libexec/check_log $ARG1$<br />
<br />
# Use either ADH ciphers or certificates.<br />
ciphers=ADH-AES256-SHA:ADH-AES128-SHA<br />
#cacert_file=<br />
#cert_file=<br />
#privatekey_file=<br />
<br />
# NOTE: additional command definitions should be put into a file such as<br />
#&nbsp; &nbsp; &nbsp; &nbsp;/usr/local/nagios/etc/nrpe_local/override.cfg<br />
include_dir=/usr/local/nagios/etc/nrpe_local</p>
</div>

<div>&nbsp;</div>

Duncan Ferguson
dferguson's picture
Sandra,

Sandra,

NRPE: Command '/usr/local/nagios/libexec/check_log' not defined

This error is actually on the client, not the Opsview Monitor server.

When you run a plugin using 'check_nrpe -H <address> -c <command>', this talks to an NRPE daemon running on the remove machine identified by '<address>' with a request ro tune 'command'.

The NRPE daemon has a configuration file that it uses to deinfe what '<command>' is - this is located at /usr/local/nagios/etc/nrpe.cfg

You can make changes to this file, but these changes will be lost on an upgrade, so instead you can create a file called /usr/local/nagios/etc/nrpe_local/custom.cfg (or simialr) that will contain a line like:

command[check_log]=/usr/local/nagios/libexec/check_log $ARG1$

and then restart the NRPE daemon (/etc/init.d/opsview-slave restart)

The command definition you have provided above is set to work on the "local machine" - in this case the master server. 

The command line you are testing needs to be changed slightly to be:

/usr/local/nagios/libexec/check_nrpe -H 1.2.3.4 -c check_log -a "/data01/home/s604367/apache-tomcat*/logs/catalina.out"

and that change will also need to be made in the UI:

command: check_nrpe
args: -H $HOSTADDRESS$ -c check_log -a "/data01/home/s604367/apache-tomcat*/logs/catalina.out"

 

  Duncs

 

Sandra Fredenburgh
sandra.fredenburgh's picture
My check is working now.

My check is working now.  Thanks so much Duncs!

Now my next problem is with the Opsview monitor. The service check has been updated and the command runs successfully on test; however, the Opsview monitor appears to be caching the old service check error.  I have refreshed and bounced the opsware/view agents twice.  This error does not want to go away.  Any advice on how to clear it?

 

 

 

Duncan Ferguson
dferguson's picture
Did you get any errors when

Did you get any errors when you performed a reload after changing the check?

  Duncs

Sandra Fredenburgh
sandra.fredenburgh's picture
Everything is clear now.

Everything is clear now.  Thanks again for your help!

Duncan Ferguson
dferguson's picture
Thanks for letting me know

Thanks for letting me know

  Duncs

theodor.macris_86865
theodor.macris_86865's picture
In short, yes. I think you

In short, yes. I think you should use check_logfiles instead. It seems to be a far more robust and flexible plugin.