大网数据广告活动
服务器运维问答

Nagios NRPE: Command “my_command” not defined

· 52CE 我爱测

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, …

问题原文

原帖链接 · buzzing_bee · CC BY-SA 4.0

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

已采纳解答

原帖链接 · Katherine Villyard · CC BY-SA 3.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-12-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0 / CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。