3

I have installed Nagios® Core™ 3.5.1 and NRPE v2.14 on my client which running RHEL 6.3

I have this error message on my Nagios

NRPE: Command 'check_mysql_connections' not defined 

On my nrpe.cfg I already set up the allowed_host, include_dir:

allowed_hosts=xx.xx.xx.xx dont_blame_nrpe=1 include_dir=/etc/nagios/services 

my command is on /etc/nagios/services/check_mysql_connections.cfg

command[check_mysql_connections]=/usr/lib64/nagios/plugins/check_mysql_all -K connections -H myHOST -u myUSERNAME -p myPASSWORD 

On Nagios Server, I already set up the nagios.cfg file, and add the commands-custom.cfg on /etc/nagios/objects which contains like this:

define command { command_name check_mysql_connections command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_mysql_connections } 

and on /etc/nagios/servers I have add the mysql.cfg

## Define Host Group ## define hostgroup { hostgroup_name mysql-databases alias MySQL Databases } ####################### ## Define Hosts ## define host { use linux-server host_name bdgbnbpmydb02 alias MySQL Database address xx.xx.xx.xx hostgroups mysql-databases contact_groups admins check_command check-host-alive } ####################### ## Define Service ## define service { use generic-service hostgroup_name mysql-databases service_description MySQL Connections check_command check_mysql_connections } 

I already kill the NRPE process, removing /var/run/nrpe.pid, and start the NRPE process again. And also my NRPE is NOT running under xinet.d

When I try to execute the command locally on the remote host, it gives result. And when I try to execute from the nagios server using this command:

/usr/lib64/nagios/plugins/check_nrpe -H xx.xx.xx.xx -c check_mysql_connections 

it also gives result. I don't know what went wrong, because all of my other commands running normally.

UPDATE & SOLVED

after so many years, I recall how to solve this problem.

I need to edit the custom commands (on Nagios Server) commands-custom.cfg on /etc/nagios/objects, so it will be like this:

define command { command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } 

and under the "Define Service" it was like this:

## Define Service ## define service { use generic-service hostgroup_name mysql-databases service_description MySQL Connections check_command check_nrpe!check_mysql_connections } 

In summarize, I need to separate the command to check the service to be check_nrpe and call the custom commands using check_nrpe!check_mysql_connections

Reference: https://support.nagios.com/forum/viewtopic.php?f=7&t=33448

11
  • When you run the command manually from your Nagios server, are you root user or nagios user ? Commented Dec 21, 2013 at 10:25
  • It's an aside, but: bdgbnbpmydb02? What a hostname! See also serverfault.com/questions/479945/… . Commented Dec 21, 2013 at 11:46
  • Sorry to belabour the obvious, but - since you are kind enough to confirm you've restarted NRPE on the client - have you also restarted the NAGIOS server since your last edit to the config files? Commented Dec 21, 2013 at 11:47
  • I'd say "check SELinux", but you'd be getting different error messages if that were interfering with the plugin. I assume that nrpe is running as the "nrpe" user; what does ls -ldZ /etc/nagios/services /etc/nagios/services/check_mysql_connections.cfg show? Commented Dec 21, 2013 at 13:38
  • How did you install NRPE? EPEL? Repoforge? Compiled? Commented Dec 21, 2013 at 16:11

6 Answers 6

1

Start at one end and work your way back.

  • You said "/usr/lib64/nagios/plugins/check_mysql_all -K connections -H myHOST -u myUSERNAME -p myPASSWORD" works on the command line.
  • You said that NRPE works on that server with other commands.
  • You said that the command fails on the command line from the nagios server.

This suggests to me that the problem is in the definition on the NRPE server. Is it possible that your obfuscated variables for myHOST, myUSERNAME, or myPASSWORD contain a character that is interpreted non-literally by NRPE? (I'm assuming you've already checked for typos and duplicate definitions!)

5
  • All command both success from Nagios server and client. And no, all of myHOST,myUSERNAME, & myPASSWORD, do not contain strange character, all pure alphabetical characters. Commented Dec 27, 2013 at 9:53
  • Oh, I'm sorry. I must have misread. :( Check for duplicate command definitions on the Nagios server itself. They may be hidden in /etc/nrpe. Commented Dec 27, 2013 at 15:15
  • I am sure there is no duplicate command definitions, since I've done installing nagios and nrpe, and I create it myself...maybe i just have to reinstall both nagios and nrpe?? Commented Dec 28, 2013 at 1:46
  • They're working for the other plugins. I assume you've already looked in /var/log/messages and /var/log/nagios3/nagios.log or the equivalent on your system... Commented Dec 28, 2013 at 3:14
  • 1
    your comment "This suggests to me that the problem is in the definition on the NRPE server" what bothers me at that time. So I try to re-define the commands, and it works. Thanks a lot Commented Nov 14, 2019 at 4:16
2

Follow these steps for adding a remote client disk check. These steps can be followed for the setup of mysql also.

Client


vi /etc/nagios/nrpe.cfg

allowed_hosts=127.0.0.1,nagios_server_ip_here dont_blame_nrpe=1 #checking root partion command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 25% -c 20% -p / 

Server


From the file /usr/local/nagios/etc/resource.cfg its given as $USER1$=/usr/local/nagios/libexec:

So, run the commands in terminal:

locate check_nrpe //find the location of check_nrpe cp /usr/lib/nagios/plugins/check_nrpe /usr/local/nagios/libexec/ cd /usr/local/nagios/libexec/ chown nagios:nagios check_nrpe 

Edit the file /usr/local/nagios/etc/objects/commands.cfg:

define command{ command_name check_disk command_line $USER1$/check_nrpe -H '$HOSTADDRESS$' -t 30 -c check_disk } 

Edit /usr/local/nagios/etc/servers/clients.cfg:

define service { use generic-service host_name BI Server service_description Disk check_command check_disk notifications_enabled 1 } 

Restart services

/etc/init.d/nagios restart //server side /etc/init.d/nagios-nrpe-server restart //client side 

You can also check the commands in terminal as nagios user,

su - nagios cd /usr/local/nagios/libexec/ ./check_nrpe -H nagios_client_ip_here -t 30 -c check_mysql ./check_nrpe -H nagios_client_ip_here -t 30 -c check_disk 
0

Normally, I would suspect a permissions problem with that plugin. Be sure to run your manual tests as the nagios (or nrpe) user.

But in this case, it's claiming the NRPE command isn't even defined, so it's not even getting as far as running it...

Put the NRPE command def directly into nrpe.cfg, not in an included file. (And then restart NRPE.)

I recall having a similar problem (but with the NRPE from EPEL), a few years ago, where it wouldn't include another file in nrpe.cfg for some reason. I never did figure out why the include file didn't work, though.

2
  • i've done that, and it's just the same, i put command definition to /etc/nagios/nrpe.cfg and it got the same error Commented Dec 28, 2013 at 1:44
  • Then either you're looking at the wrong box, or the NRPE daemon isn't using that config file. Commented Dec 29, 2013 at 16:56
0

I had same issue for one of new checks I had implemented. Tried running check manually from Nagios Server

[[email protected]]$ /usr/lib64/nagios/plugins/check_nrpe -H db1.example.com -c check_mysql NRPE: Command 'check_mysql' not defined 

Turned out that Nagios NRPE Daemon on Nagios Client Server needed to restarted since it sources everything from nrpe.d into program memory

[[email protected]]$ sudo /etc/init.d/nrpe restart Shutting down Nagios NRPE daemon (nrpe): [ OK ] Starting Nagios NRPE daemon (nrpe): [ OK ] 

Ran the check again and was succeeding this time

[[email protected]]$ /usr/lib64/nagios/plugins/check_nrpe -H db1.example.com -c check_mysql OK: MySQL is running fine. 
0

I had the same symptom. So maybe this will save someone else some time. My problem was that I was missing the .cfg extension on the files in the include directory.

My include dir was include_dir=/etc/nagios/nrpe.d

The machine is running Ubuntu 14.04 for reference, using NRPE v2.15

-1

I had a similar issue sometime ago, it turned out that someone already installed NRPE in the server (i didn't know), and when i tried to access it took the old NRPE version and configuration, the solution was look for the old NRPE and redirect the access...

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.