check_apt returning NRPE: Command 'check_yum' not defined

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
User avatar
pelicanmedia
Posts: 22
Joined: Wed Feb 22, 2017 5:32 am
Location: Colchester, Essex, UK
Contact:

check_apt returning NRPE: Command 'check_yum' not defined

Post by pelicanmedia »

I am getting the wrong response to the check_apt plugin on a new server, set up today.
I do not have check_yum anywhere related to this host, yet I am getting the wrong response.
If I run check_apt locally I get the correct response:

Code: Select all

user@web-backups:~# /usr/lib/nagios/plugins/check_apt
APT OK: 0 packages available for upgrade (0 critical updates). |available_upgrades=0;;;0 critical_updates=0;;;0
In the config file for the host I have:

Code: Select all

###############################################################################
###############################################################################
#
# HOST DEFINITION
#
###############################################################################
###############################################################################

# Define a host for the local machine

define host{
  use                     linux-server
  host_name               host.name
  alias                   Web Backups
  address                 xxx.xxx.xxx.xxx
  }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

define service{
  use                     local-service
  host_name               host.name
  service_description     Drive Space
  check_command           check_hdd!10!5
  }

define service{
  use                     generic-service
  host_name               host.name
  service_description     Updates
  check_command           check_apt
  }

define service{
  use                     generic-service
  host_name               host.name
  service_description     Uptime
  check_command           check_remote_uptime
  }
In the commands.cfg on the server I have:

Code: Select all

# 'check_yum'
define command{
        command_name    check_yum
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_yum
        }

# 'check_apt'
define command{
        command_name    check_apt
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_apt
        }
In /etc/nagios/nrpe.cfg on the host I have:

Code: Select all

### SYSTEM UPDATES ###
#command[check_yum]=/usr/lib/nagios/plugins/check_yum
command[check_apt]=/usr/lib/nagios/plugins/check_apt
If I change /etc/nagios/nrpe.cfg on the host to:

Code: Select all

### SYSTEM UPDATES ###
#command[check_yum]=/usr/lib/nagios/plugins/check_yum
command[check_yum]=/usr/lib/nagios/plugins/check_apt
I get the correct response.... :? :?

Any ideas?
Thanks
User avatar
pelicanmedia
Posts: 22
Joined: Wed Feb 22, 2017 5:32 am
Location: Colchester, Essex, UK
Contact:

Re: check_apt returning NRPE: Command 'check_yum' not define

Post by pelicanmedia »

Figured it out. Badly written software...

My new host's host_name was web-backups.host.name running Ubuntu.
I had another host called monitor.host.name running CentOS plus another call just host.name, also on CentOS.

It appears Nagios ignores anything before host.name so the results I was being shown for monitor.host.name were actually the results from host.name. I only noticed this when searching for files containing 'check_yum' and noticing the below results:

Code: Select all

[1570533035] Warning: Duplicate definition found for service 'Uptime' on host 'monitor.host.name' (config file '/usr/local/nagios/etc/config/web-website.cfg', starting on line 40)
[1570533035] Warning: Duplicate definition found for service 'Updates' on host 'monitor.host.name' (config file '/usr/local/nagios/etc/config/web-website.cfg', starting on line 33)
[1570533035] Warning: Duplicate definition found for service 'Drive Space' on host 'monitor.host.name' (config file '/usr/local/nagios/etc/config/web-website.cfg', starting on line 26)
[1570533035] Warning: Duplicate definition found for service 'Uptime' on host 'web-backups.host.name' (config file '/usr/local/nagios/etc/config/web-backups.cfg', starting on line 40)
[1570533035] Warning: Duplicate definition found for service 'Updates' on host 'web-backups.host.name' (config file '/usr/local/nagios/etc/config/web-backups.cfg', starting on line 33)
[1570533035] Warning: Duplicate definition found for service 'Drive Space' on host 'web-backups.host.name' (config file '/usr/local/nagios/etc/config/web-backups.cfg', starting on line 26)
I have now changed the host_name's to 'web-backups' and 'monitor' (excluding .host.name) and everything is now working. Pretty poor if you cant use the FQDN for the host as the host_name in the config file for that host.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_apt returning NRPE: Command 'check_yum' not define

Post by scottwilkerson »

pelicanmedia wrote:I have now changed the host_name's to 'web-backups' and 'monitor' (excluding .host.name) and everything is now working. Pretty poor if you cant use the FQDN for the host as the host_name in the config file for that host.
It looks like you had some duplicate definitions whereas Nagios is just going to pick one of them.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
pelicanmedia
Posts: 22
Joined: Wed Feb 22, 2017 5:32 am
Location: Colchester, Essex, UK
Contact:

Re: check_apt returning NRPE: Command 'check_yum' not define

Post by pelicanmedia »

When I change the host_names back to monitor.host.name and web-backups.host.name I get the warning back in /usr/local/nagios/var/nagios.log.

Code: Select all

[1570539439] Warning: Duplicate definition found for service 'Uptime' on host 'monitor.host.name' (config file '/usr/local/nagios/etc/config/web-website.cfg', starting on line 40)
[1570539439] Warning: Duplicate definition found for service 'Updates' on host 'monitor.host.name' (config file '/usr/local/nagios/etc/config/web-website.cfg', starting on line 33)
[1570539439] Warning: Duplicate definition found for service 'Drive Space' on host 'monitor.host.name' (config file '/usr/local/nagios/etc/config/web-website.cfg', starting on line 26)
[1570539439] Warning: Duplicate definition found for service 'Uptime' on host 'web-backups.host.name' (config file '/usr/local/nagios/etc/config/web-backups.cfg', starting on line 40)
[1570539439] Warning: Duplicate definition found for service 'Updates' on host 'web-backups.host.name' (config file '/usr/local/nagios/etc/config/web-backups.cfg', starting on line 33)
[1570539439] Warning: Duplicate definition found for service 'Drive Space' on host 'web-backups.host.name' (config file '/usr/local/nagios/etc/config/web-backups.cfg', starting on line 26)
web-website.cfg

Code: Select all

###############################################################################
###############################################################################
#
# HOST DEFINITION
#
###############################################################################
###############################################################################

# Define a host for the local machine

define host{
  use                     linux-server
  host_name               host.name
  alias                   Website - Ltd
  address                 xxx.xxx.126.241
  }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

define service{
  use                     local-service
  host_name               host.name
  service_description     Drive Space
  check_command           check_hdd!10!5
  }

define service{
  use                     generic-service
  host_name               host.name
  service_description     Updates
  check_command           check_yum
  }

define service{
  use                     generic-service
  host_name               host.name
  service_description     Uptime
  check_command           check_remote_uptime
  }
web-monitor.cfg

Code: Select all

###############################################################################
###############################################################################
#
# HOST DEFINITION
#
###############################################################################
###############################################################################

# Define a host for the local machine

define host{
  use                     linux-server
  host_name               monitor.host.name
  alias                   Monitor
  address                 xxx.xxx.84.95
  }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

define service{
  use                     local-service
  host_name               monitor.host.name
  service_description     Drive Space
  check_command           check_hdd!10!5
  }

define service{
  use                     generic-service
  host_name               monitor.host.name
  service_description     Updates
  check_command           check_yum
  }

define service{
  use                     generic-service
  host_name               monitor.host.name
  service_description     Uptime
  check_command           check_remote_uptime
  }
web-backups.cfg

Code: Select all

###############################################################################
###############################################################################
#
# HOST DEFINITION
#
###############################################################################
###############################################################################

# Define a host for the local machine

define host{
  use                     linux-server
  host_name               web-backups.host.name
  alias                   Web Backups
  address                 xxx.xxx.60.110
  }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

define service{
  use                     local-service
  host_name               web-backups.host.name
  service_description     Drive Space
  check_command           check_hdd!10!5
  }

define service{
  use                     generic-service
  host_name               web-backups.host.name
  service_description     Updates
  check_command           check_apt
  }

define service{
  use                     generic-service
  host_name               web-backups.host.name
  service_description     Uptime
  check_command           check_remote_uptime
  }
As you can see there is no reference to monitor.host.name in web-website.cfg. So no duplicate definitions as they all have different host_names.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_apt returning NRPE: Command 'check_yum' not define

Post by scottwilkerson »

Can you look in other files in your config directory

Code: Select all

grep -R monitor.host.name /usr/local/nagios/etc/
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
pelicanmedia
Posts: 22
Joined: Wed Feb 22, 2017 5:32 am
Location: Colchester, Essex, UK
Contact:

Re: check_apt returning NRPE: Command 'check_yum' not define

Post by pelicanmedia »

Sure...

Code: Select all

[user@centos ~]# grep -R monitor.host.name /usr/local/nagios/etc/
/usr/local/nagios/etc/config/web-monitor.cfg:  host_name               monitor.host.name
/usr/local/nagios/etc/config/web-monitor.cfg:  host_name               monitor.host.name
/usr/local/nagios/etc/config/web-monitor.cfg:  host_name               monitor.host.name
/usr/local/nagios/etc/config/web-monitor.cfg:  host_name               monitor.host.name
[user@centos ~]# 
And just to confirm...

Code: Select all

[user@centos ~]# grep -R web-backups.host.name /usr/local/nagios/etc/
/usr/local/nagios/etc/config/web-backups.cfg:  host_name               web-backups.host.name
/usr/local/nagios/etc/config/web-backups.cfg:  host_name               web-backups.host.name
/usr/local/nagios/etc/config/web-backups.cfg:  host_name               web-backups.host.name
/usr/local/nagios/etc/config/web-backups.cfg:  host_name               web-backups.host.name
[user@centos ~]# 

Code: Select all

[user@centos ~]# grep -R host.name /usr/local/nagios/etc/
/usr/local/nagios/etc/config/web-backups.cfg:  host_name               web-backups.host.name
/usr/local/nagios/etc/config/web-backups.cfg:  host_name               web-backups.host.name
/usr/local/nagios/etc/config/web-backups.cfg:  host_name               web-backups.host.name
/usr/local/nagios/etc/config/web-backups.cfg:  host_name               web-backups.host.name
/usr/local/nagios/etc/config/contacts.cfg:	email 				support@host.name
/usr/local/nagios/etc/config/web-website.cfg:  host_name                       host.name
/usr/local/nagios/etc/config/web-website.cfg:  host_name                       host.name
/usr/local/nagios/etc/config/web-website.cfg:  host_name                       host.name
/usr/local/nagios/etc/config/web-website.cfg:  host_name                       host.name
/usr/local/nagios/etc/config/web-monitor.cfg:  host_name               monitor.host.name
/usr/local/nagios/etc/config/web-monitor.cfg:  host_name               monitor.host.name
/usr/local/nagios/etc/config/web-monitor.cfg:  host_name               monitor.host.name
/usr/local/nagios/etc/config/web-monitor.cfg:  host_name               monitor.host.name
[user@centos ~]# 
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_apt returning NRPE: Command 'check_yum' not define

Post by scottwilkerson »

This is very strange, I places the 3 files from this post in my server
https://support.nagios.com/forum/viewto ... 18#p294257

and the verify config doesn't have any duplicate definitions.

You don't by chance have a hostgroup attached to the linux-server template do you?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
pelicanmedia
Posts: 22
Joined: Wed Feb 22, 2017 5:32 am
Location: Colchester, Essex, UK
Contact:

Re: check_apt returning NRPE: Command 'check_yum' not define

Post by pelicanmedia »

I have one host group:

Code: Select all

define hostgroup{
        hostgroup_name           Servers - Linux
        members                  centos,host.name,monitor.host.name,web-backups.host.name, (plus a few other non related servers)
        }
The only other references to linux-server are in the default /config/templates.cfg and /objects/templates.cfg files.

It does seem to relate to the prefix to .host.name. As when I remove it from web-monitor.cfg, web-backups.cfg and the host group file everything works as it should.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_apt returning NRPE: Command 'check_yum' not define

Post by scottwilkerson »

My guess would be that the linux-server template contained an addition of the hostgroup "Servers - Linux" and this would create a new service for every member of the hostgroup.

Glad to hear everything is working as it should.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
pelicanmedia
Posts: 22
Joined: Wed Feb 22, 2017 5:32 am
Location: Colchester, Essex, UK
Contact:

Re: check_apt returning NRPE: Command 'check_yum' not define

Post by pelicanmedia »

This has not been resolved as there is obviously a bug/flaw where it ignores the host_name field in the .cfg files.

The only 'fix' that I can get to work is by removing .host.name from the host_name field. I should be able to use the full name of 'web-backups.host.name' and 'monitor.host.name' without the 2 configuration files clashing and giving me false reading and/or errors.
Locked