Warning: Duplicate definition found for command

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.
FabienA
Posts: 16
Joined: Thu Jan 12, 2017 8:17 am

Warning: Duplicate definition found for command

Post by FabienA »

Hi guys,

I have a Duplicate warning on my Nagios Core 4.2.4...
I have already one Nagios 3.2.0 and i have import (cut/past) configurations files.

When i check my configuration between start a nagios service, i have this message :
[root@canetd01 etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.2.4
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 12-07-2016
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Warning: Duplicate definition found for command 'notify-host-by-email' (config file '/usr/local/nagios/etc/objects/commands.cfg', starting on line 27)
Error: Could not add object property in file '/usr/local/nagios/etc/objects/commands.cfg' on line 28.
Error processing object config files!


***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
And i have run this command (found in this forum):
[root@canetd01 etc]# grep -r -A 5 -B 5 'notify-host-by-email' /usr/local/nagios/etc/
/usr/local/nagios/etc/objects/commands.cfg-# you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below.
/usr/local/nagios/etc/objects/commands.cfg-#
/usr/local/nagios/etc/objects/commands.cfg-################################################################################
/usr/local/nagios/etc/objects/commands.cfg-
/usr/local/nagios/etc/objects/commands.cfg-
/usr/local/nagios/etc/objects/commands.cfg:# 'notify-host-by-email' command definition
/usr/local/nagios/etc/objects/commands.cfg-define command{
/usr/local/nagios/etc/objects/commands.cfg: command_name notify-host-by-email
/usr/local/nagios/etc/objects/commands.cfg- command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
/usr/local/nagios/etc/objects/commands.cfg- }
/usr/local/nagios/etc/objects/commands.cfg-
/usr/local/nagios/etc/objects/commands.cfg-# 'notify-service-by-email' command definition
/usr/local/nagios/etc/objects/commands.cfg-define command{
--
/usr/local/nagios/etc/objects/templates.cfg- service_notification_period 24x7 ; service notifications can be sent anytime
/usr/local/nagios/etc/objects/templates.cfg- host_notification_period 24x7 ; host notifications can be sent anytime
/usr/local/nagios/etc/objects/templates.cfg- service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events
/usr/local/nagios/etc/objects/templates.cfg- host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events
/usr/local/nagios/etc/objects/templates.cfg- service_notification_commands notify-service-by-email ; send service notifications via email
/usr/local/nagios/etc/objects/templates.cfg: host_notification_commands notify-host-by-email ; send host notifications via email
/usr/local/nagios/etc/objects/templates.cfg- register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
/usr/local/nagios/etc/objects/templates.cfg- }
/usr/local/nagios/etc/objects/templates.cfg-
/usr/local/nagios/etc/objects/templates.cfg-
/usr/local/nagios/etc/objects/templates.cfg-

In this configuration files, i create a command (notify-host-by-email) and then i use this command... I don't know how to fixed this warning...

Thanks for your Help
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Warning: Duplicate definition found for command

Post by dwhitfield »

FabienA wrote: I have already one Nagios 3.2.0
Are these on the same system? If so, you will need to uninstall 3.2.0. Did you try to upgrade? What instructions did you use? Did you install 3.2.0 via repos or via source?
FabienA
Posts: 16
Joined: Thu Jan 12, 2017 8:17 am

Re: Warning: Duplicate definition found for command

Post by FabienA »

I have 2 servers one on Nagios 4.2.4 (the new server) and one on Nagios 3.2.0.
I have installed Nagios 4.2.4 and tested this (it's ok). After my install and my first test i have got configuration files to my Nagios 3.2.0.

When i want checked my configuration i have this duplicate error...

And i don't know how fixed this error.. because for me it's normal..
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Warning: Duplicate definition found for command

Post by dwhitfield »

Most often this type of behavior can be attributed to a hostgroup and/or servicegroup memerbship. If you have checks set up directly for the host in the host's config, be careful that the host is not also inheriting checks from a hostgroup or servicegroup with the same checks configured.

In order to help you track this down, what's the output of ll /usr/local/nagios/etc/objects/?

It might be easiest to post/PM your objects.cache. It's probably at /usr/local/nagios/var/objects.cache but you can set the location in /usr/local/nagios/etc/nagios.cfg. Attaching it as a file is probably best, but if you want to PM it for security purposes, that works too. Just make sure you update this post after PMing the objects.cache.

UPDATE: objects.cache shared with techs
FabienA
Posts: 16
Joined: Thu Jan 12, 2017 8:17 am

Re: Warning: Duplicate definition found for command

Post by FabienA »

Thanks for your reply, this is the result for the ll /usr/local/nagios/etc/objects/ command.
[root@canetd01 objects]# ll /usr/local/nagios/etc/objects/
total 36
drwxr-xr-x. 2 nagios nagios 6 13 janv. 15:30 bkpcfg
drwxr-xr-x. 2 root root 153 13 janv. 15:57 cfgcanetp04
-rw-rw-r--. 1 nagios nagios 7688 10 janv. 17:21 commands.cfg
-rw-rw-r--. 1 nagios nagios 2143 13 janv. 15:36 contacts.cfg
-rw-rw-r--. 1 nagios nagios 3096 10 janv. 17:21 printer.cfg.bkp
-rw-rw-r--. 1 nagios nagios 10621 13 janv. 16:01 templates.cfg
-rw-rw-r--. 1 nagios nagios 3180 10 janv. 17:21 timeperiods.cfg
-rw-rw-r--. 1 nagios nagios 4019 13 janv. 15:12 windows.cfg
I will send you a PM for the objects.cache file.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Warning: Duplicate definition found for command

Post by rkennedy »

On top of the objects.cache, please send over the full output of this - it will allow us to see everything at play in your Nagios configuration files.

Code: Select all

grep -R '' /usr/local/nagios/etc/
Former Nagios Employee
FabienA
Posts: 16
Joined: Thu Jan 12, 2017 8:17 am

Re: Warning: Duplicate definition found for command

Post by FabienA »

hi rkennedy,

I'm not sure to understand your reply..
Where I do send this command :
grep -R '' /usr/local/nagios/etc/
?

You say on top of the objects.cache, but my objects.cache is on the "/usr/local/nagios/var" folder. Then I do change your command to grep -R '' /usr/local/nagios/var/ ?
Or i do send my command on the objects.cache file ?
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Warning: Duplicate definition found for command

Post by rkennedy »

Just run it over the command line, and send over the full output it produces. This will show us the files / contents contained in your entire /usr/local/nagios/etc/ directory.
Former Nagios Employee
FabienA
Posts: 16
Joined: Thu Jan 12, 2017 8:17 am

Re: Warning: Duplicate definition found for command

Post by FabienA »

Ok thanks for your explain :)
I send you a result to : { grep -R '' /usr/local/nagios/etc/ } on PM.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Warning: Duplicate definition found for command

Post by rkennedy »

It looks like you have multiple commands.cfg - which I imagine could be overlapping -

Code: Select all

/usr/local/nagios/etc/objects/commands.cfg:
and

Code: Select all

/usr/local/nagios/etc/commands.cfg
You'll want to make sure you don't have any duplicate definitions between the two. The same thing applies for other objects in your system - if the same configuration exists twice it will not work.
Former Nagios Employee
Locked