New to Nagios, migrated an instance

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.
Locked
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

New to Nagios, migrated an instance

Post by Zippyduda »

Hello all :)

First time poster! I'm new to Nagios but have just migrated an instance from 4.1.1, Ubuntu 12 to 4.4.5, Ubuntu 18.
The instance uses adagios and pnp4nagios additionally.

I've ran into two issues, likely due to not understanding how Nagios reads it's config files:

Code: Select all

root@hostname:/etc/adagiosconf/objects# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.4.5
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2019-08-20
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
Warning: Duplicate definition found for contact 'generic-contact' (config file '/etc/adagiosconf/objects/templates.cfg', starting on line 27)
Error: Could not add object property in file '/etc/adagiosconf/objects/templates.cfg' on line 28.
Error: Could not register host (config file '/etc/adagiosconf/objects/switch.cfg', starting on line 20)
   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 definitions.  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.
Here are the lines it is complaining about:

templates.cfg Lines 27 and 28

Code: Select all

define contact{
        name                            generic-contact         ; The name of this contact template
        service_notification_period     24x7                    ; service notifications can be sent anytime
        host_notification_period        24x7                    ; host notifications can be sent anytime
        service_notification_options    w,u,c,r,f,s             ; send notifications for all service states, flapping events, and scheduled downtime events
        host_notification_options       d,u,r,f,s               ; send notifications for all host states, flapping events, and scheduled downtime events
        service_notification_commands   notify-service-by-email ; send service notifications via email
        host_notification_commands      notify-host-by-email    ; send host notifications via email
        register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
        }
switch.cfg Line 20

Code: Select all

define host {

    use                     generic-switch                      ; Inherit default values from a template
    host_name               linksys-abc123d                     ; The name we're giving to this switch
    alias                   linksys ABC123D Switch        ; A longer name associated with the switch
    address                 192.168.1.X                       ; IP address of the switch
    hostgroups              switches                            ; Host groups this switch is associated with
}
I've checked all of the .cfg files and can't find a duplicate entry. The "generic-contact" contact is used by the main contact in contacts.cfg but that's how it's meant to work isn't it?

Code: Select all

define contact {

    contact_name            nagiosadmin             ; Short name of user
    use                     generic-contact         ; Inherit default values from generic-contact template (defined above)
    alias                   Nagios Admin            ; Full name of user
    email                   my.email@example.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
And is also referenced in contacts/user.cfg files

Additionally adagios is giving me this error:

Destination for new objects (/etc/adagiosconf/objects) is not defined in nagios.cfg

Even though it is listed as below:

cfg_file=/etc/adagiosconf/objects/commands.cfg
cfg_file=/etc/adagiosconf/objects/contacts.cfg
cfg_file=/etc/adagiosconf/objects/timeperiods.cfg
cfg_file=/etc/adagiosconf/objects/templates.cfg
cfg_file=/etc/adagiosconf/objects/localhost.cfg
cfg_dir=/etc/adagiosconf/objects

I also tried it as /usr/local/nagios/etc/objects
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: New to Nagios, migrated an instance

Post by mbellerue »

For switch.cfg, is the IP address actually set to 192.168.1.X? I could see Nagios complaining about that.

For the duplicate definition, what happens if you just comment out the generic-contact definition in templates.cfg? Does the error go away? Do notifications work?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

Re: New to Nagios, migrated an instance

Post by Zippyduda »

I just set the IP address to .X for the sake of this thread :lol:

When I commented out the generic-contact in templates.cfg and did the nagios config check it just moved onto the next entry in the file. I then commented out everything it errored about (ended up being every single .cfg file) and it moved onto files in the contacts, hosts etc. etc. directories

What's strange is these .cfg files worked on the old server so not sure why Nagios is complaining about them now.
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

Re: New to Nagios, migrated an instance

Post by Zippyduda »

Ah I think I have seen one issue.

I was including config files twice in nagios.cfg

Once in cfg_file and once in cfg_dir

The next issue I have is:

Warning: Duplicate definition found for hostgroup 'windows-servers' (config file '/etc/adagiosconf/objects/windows.cfg', starting on line 40)
Error: Could not add object property in file '/etc/adagiosconf/objects/windows.cfg' on line 42.
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

Re: New to Nagios, migrated an instance

Post by Zippyduda »

Ah looks like I have fixed this as well.

There was a misspelling, needed to change windows-servers to windows-server
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

Re: New to Nagios, migrated an instance

Post by Zippyduda »

Now I'm getting this:

Error: Unexpected token or statement in file '/etc/adagiosconf/objects/resource.cfg' on line 32.

# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/local/nagios/libexec

Which seems fine to me.

Nagios plugins directory has nagios user and group and relevant permissions to access it all...

I'm setting it exactly how the documentation says to:

Page 5 of https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

Re: New to Nagios, migrated an instance

Post by Zippyduda »

Looks like I had to use resource.cfg from /usr/local/nagios/etc/ instead of /etc/adagiosconf/objects/

This helped: https://serverfault.com/questions/63666 ... ring-pre-f
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: New to Nagios, migrated an instance

Post by mbellerue »

Awesome, thanks for posting your progress! Did you resolve all of your issues?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

Re: New to Nagios, migrated an instance

Post by Zippyduda »

I did thank you :)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: New to Nagios, migrated an instance

Post by scottwilkerson »

Zippyduda wrote:I did thank you :)
Great!

Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked