Sandeep
Sandeep

Reputation: 363

Nagios NRPE: Command not defined

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.

Upvotes: 9

Views: 79015

Answers (9)

m1ld
m1ld

Reputation: 1200

Probably will help to someone.

In my case problem was in typo. I created file /etc/nrpe.d/commands.cgf instead of /etc/nrpe.d/commands.cfg ;)

Upvotes: 0

batchen
batchen

Reputation: 11

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.

Upvotes: 1

Prashanth
Prashanth

Reputation: 91

I have solved this by adding the below lines to my nrpe.cfg file and restarting the nrpe. Basically, we are telling to nagios to recognize the commands that we are running.

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$

Upvotes: 1

Itai Ganot
Itai Ganot

Reputation: 6305

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.

Upvotes: 3

Yilmar Hernández
Yilmar Hernández

Reputation: 31

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

Upvotes: 3

user1682960
user1682960

Reputation: 130

I had a similar problem and checking in syslog I could see that nrpe had write problems in /var/run/

Nov  6 08:30:05 xxxxxx nrpe[39777]: Cannot write to pidfile '/var/run/nrpe.pid' - check your privileges.

I found here:

https://bugs.launchpad.net/ubuntu/+source/nagios-nrpe/+bug/957367

that the solution was quiet simple. Just edit nrpe.cfg and change:

pid_file=/var/run/nrpe.pid

to

pid_file=/var/run/nagios/nrpe.pid

kill nrpe manually and start it again with /etc/init.d/nagios-nrpe-server start

It just worked for me.

Upvotes: 0

Horaasje
Horaasje

Reputation: 106

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.

Upvotes: 3

Jim Black
Jim Black

Reputation: 1482

  1. Be sure you killed off all the old daemons, including any forks.
  2. After a clean restart of NRPE, check /var/log/messages for any errors?! Especially things like "NRPE: ERROR - can not bind to port/port already in use".
  3. Are you positive that an inetd controlled NRPE is not being used?
  4. If the above doesn't help, do step 1 again, then when starting NRPE do not include the '-d' flag and exam the output.

Upvotes: 1

Xacosta
Xacosta

Reputation: 246

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?

Upvotes: 1

Related Questions