9

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.

Sandeep
  • 353
  • 1
  • 4
  • 11

9 Answers9

3

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.

Horaasje
  • 106
  • 10
3

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

Hamad
  • 5,096
  • 13
  • 37
  • 65
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.

Itai Ganot
  • 5,873
  • 18
  • 56
  • 99
1

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?

Xacosta
  • 246
  • 1
  • 4
  • Update my question because of mistakes. I am using nrpe_local.conf only. When I ran command nrpe -c nrep_local.conf not getting any output. As I told there are some other commands defined in nrep_local.cfg and they are working without any issue. The new command which I added is only not working. – Sandeep Dec 13 '12 at 09:29
1
  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.
Jim Black
  • 1,422
  • 1
  • 13
  • 26
1

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$
Haroldo Gondim
  • 7,725
  • 9
  • 43
  • 62
Prashanth
  • 91
  • 6
1

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.

batchen
  • 11
  • 1
0

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.

user1682960
  • 130
  • 7
0

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 ;)

m1ld
  • 1,190
  • 9
  • 26