Nagios NRPE: Command not defined

70,088

Solution 1

Hello i solved this problem by adding the local address in the configuration file so nrpe.cfg allowed_host = 127.0.0.1, xxxx where xxxx is the IP of my nagios server. You should also be defined command [check_disk]=/usr/lib/nagios/plugins/check_disk-w 20%-c 10%-p /var

is very important that the command name [check_disk] is the same as that indicated on the route

Thanks to this, my problem was solved and I now have an excellent monitoring.

Yilmar Hernández

Solution 2

In my nrpe_local.cfg added following command:> command[check_mycommand]=/usr/lib/nagios/plugins/check_command 30 35

Try :

command[check_mycommand]=/usr/lib/nagios/plugins/check_command -w (warningTreshold) -c (criticalTreshold)
/etc/init.d/nagios-nrpe-server restart

And indeed kill all other daemons of nrpe which are already running. The cause could be it is already running by different users which may cause conflicts. eg. nagios-nrpe-server is running under user root and under user nagios

Also make sure you added your Nagios server's IP address to the allowed_hosts in /etc/nagios/nrpe.cfg :

allowed_hosts=<ip address of nagios server>

Else you won't be able to execute external commands with NRPE from Nagios.

Solution 3

Your command in nrpe.cfg should look like this:

command[check_mycommand]=/usr/lib/nagios/plugins/check_command -w $ARG1$ -c $ARG2$

then, your service in services.cfg file (or whatever it's name) check should look like this:

define service{
   servicegroups        Basic Functionality
   host_name            localhost
   service_description  Mycommand
   check_command        check_nrpe!check_mycommand -a '-w 30 -c 35'
   use                  generic-service
}

Please let me know if it solved your issue.

Solution 4

Did you start NRPE daemon with the correct config file? (nrpe -c config_file -d) The config file you are using there is nagios_local.conf or nrpe_local.cfg?

Solution 5

Hi i got this error and was able to solve it : in /etc/nagios/nrpe.cfg youll see :

command[check_var]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /var
command[check_slash]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_ssh]=/usr/lib64/nagios/plugins/check_ssh $ARG1$

but im sure you got confiused and set : commend.cfg with : check_disk and not check_slash

see that the line says " command[check_slash] " this is what the command.cfg wants to get.

Share:
70,088
Sandeep
Author by

Sandeep

Updated on July 30, 2020

Comments

  • Sandeep
    Sandeep almost 4 years

    In my nrpe_local.cfg added following command:

    command[check_mycommand]=/usr/lib/nagios/plugins/check_command 30 35
    

    and then restarted nrpe daemon.

    When I execute this command using nrpe I'm getting the following error:

    NRPE: Command 'check_mycommand' not defined
    

    I used following command to execute:

    /usr/lib/nagios/plugins/check_nrpe -H hostname -c check_mycommand
    

    I am unable to get any clue.

    In my nrpe_local.cfg there are 10 more commands added and they are working properly.