Page 1 of 1

New to Nagios, migrated an instance

Posted: Tue Oct 22, 2019 6:50 am
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                   [email protected] ; <<***** 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

Re: New to Nagios, migrated an instance

Posted: Tue Oct 22, 2019 1:50 pm
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?

Re: New to Nagios, migrated an instance

Posted: Wed Oct 23, 2019 4:06 am
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.

Re: New to Nagios, migrated an instance

Posted: Wed Oct 23, 2019 9:41 am
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.

Re: New to Nagios, migrated an instance

Posted: Wed Oct 23, 2019 9:54 am
by Zippyduda
Ah looks like I have fixed this as well.

There was a misspelling, needed to change windows-servers to windows-server

Re: New to Nagios, migrated an instance

Posted: Wed Oct 23, 2019 10:41 am
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

Re: New to Nagios, migrated an instance

Posted: Wed Oct 23, 2019 10:53 am
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

Re: New to Nagios, migrated an instance

Posted: Wed Oct 23, 2019 1:31 pm
by mbellerue
Awesome, thanks for posting your progress! Did you resolve all of your issues?

Re: New to Nagios, migrated an instance

Posted: Thu Oct 31, 2019 10:03 am
by Zippyduda
I did thank you :)

Re: New to Nagios, migrated an instance

Posted: Thu Oct 31, 2019 11:46 am
by scottwilkerson
Zippyduda wrote:I did thank you :)
Great!

Locking thread