Error when add remote windows server

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.
rafael
Posts: 21
Joined: Thu Jul 13, 2017 11:06 pm

Error when add remote windows server

Post by rafael »

Hello,
I'm configuring Nagios 4.x monitor remote Windows host using NSClient++.And, i got error message as blow,
Error: Template 'windows-server' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/windows.cfg', starting on line 24)
Error processing object config files!
Here is short host defination
define host{
use windows-server ; Inherit default values from a template
host_name winserver ; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 172.16.201.2 ; IP address of the host
}
Here is short template
# Windows host definition template - This is NOT a real host, just a template!

define host{
name windows-server ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, Windows servers are monitored round the clock
check_interval 5 ; Actively check the server every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each server 10 times (max)
check_command check-host-alive ; Default command to check if servers are "alive"
notification_period 24x7 ; Send notification out at any time - day or night
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
hostgroups windows-servers ; Host groups that Windows servers should be a member of
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}
I'm newbies in Nagios, hope you could help me troubleshoot. Tks
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Error when add remote windows server

Post by dwhitfield »

Please attach your entire windows.cfg. Also, please attach your entire nagios.cfg.
rafael
Posts: 21
Joined: Thu Jul 13, 2017 11:06 pm

Re: Error when add remote windows server

Post by rafael »

Hi dwhitfield,
Please refer attached files.
One more information, I had upgraded Nagios 3.x to 4.x. But, I have never do anything since installed Nagios 3.x last year.
Thanks.
Attachments
nagios.cfg
(4.12 KiB) Downloaded 302 times
windows.cfg
(4.03 KiB) Downloaded 331 times
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Error when add remote windows server

Post by tgriep »

When the Nagios system starts up, it reads the configuration files in order and if you create templates, etc... they have to be defined in the nagios.cfg file before the host or service configs.
In your nagios.cfg file, the windows.cfg file is first in the list, move it to the bottom of the list and that should fix the error when starting the nagios process.
Be sure to check out our Knowledgebase for helpful articles and solutions!
rafael
Posts: 21
Joined: Thu Jul 13, 2017 11:06 pm

Re: Error when add remote windows server

Post by rafael »

Hello All,
Sorry for my replying too late due to busy other jobs.
I was followed up your guide but still failure. Please refer photo and windows.cfg
Image
wha't wrong from line 24 ?
Also, I tried reinstall NSClient++ (NSCP-0.5.0.62-x64.msi). But, I did not find NSC.INI file to uncomment module as some website comment
Image

Any help, Thanks you !
Attachments
windows.cfg
(3.9 KiB) Downloaded 241 times
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Error when add remote windows server

Post by mcapra »

Can you share an updated copy of:

Code: Select all

/usr/local/nagios/etc/nagios.cfg
/usr/local/nagios/etc/hostTemplates.cfg
This doesn't have anything to do with NSClient++ as of right now. Your windows.cfg file is referencing the windows-server template which needs to exist somewhere. Nagios can't seem to find it as of right now.

The output of a tree run against your Nagios installation path might also be useful. If you're using Debian or Ubuntu, use apt-get instead of yum:

Code: Select all

yum install -y tree
tree /usr/local/nagios/etc
Former Nagios employee
https://www.mcapra.com/
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Error when add remote windows server

Post by tgriep »

The issue is that you are using a template called windows-servers for your host called winserver that is missing and that causes the configuration error.

Try adding the following to the hosttemplates.cfg file to create the missing template.

Code: Select all

define host {
       name                          		windows-server
       hostgroups                    		windows-servers
       check_command                 		check-host-alive
       use                           		generic-host
       max_check_attempts            		10
       check_interval                		5
       retry_interval                		1
       check_period                  		24x7
       contact_groups                		admins
       notification_interval         		30
       notification_period           		24x7
       notification_options          		d,r
       register                    		0

}
See if that resolves the configuration error.

FYI, the newer version of the NSClient++, version 4.x.x or greater, the configuration file is called nsclient.ini so that is what you would need to edit.
Be sure to check out our Knowledgebase for helpful articles and solutions!
rafael
Posts: 21
Joined: Thu Jul 13, 2017 11:06 pm

Re: Error when add remote windows server

Post by rafael »

Dear All,
Other error relating contact defination,
[root@fepv-ms ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.2.0
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-01-2016
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Warning: sleep_time is deprecated and will be removed.
Warning: command_check_interval is deprecated and will be removed. Commands are always handled on arrival
Warning: p1_file is deprecated and will be removed.
Read main config file okay...
Error: Contactgroup 'admins' is not defined anywhere
Error: Could not add contactgroup 'admins' to host (config file '/usr/local/nagios/etc/objects/windows.cfg', starting on line 24)
Error processing object config files!
Maybe, I need someone share "contact sample" suite my state. Also, I attached my orginal "contact and contact template" files.
In other hand, Anyone can show me whole process of Nagios, how it's work ?. For me, It's too hard too understand. To feel ashame of me.
Thank you!
Attachments
contactTemplates.cfg
(1.06 KiB) Downloaded 251 times
contacts.cfg
(1.5 KiB) Downloaded 226 times
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Error when add remote windows server

Post by mcapra »

If you're interested in a monitoring solution for your organization, you might find Nagios XI to be a bit more accessible than Nagios Core. You can also get a free 1-hour consultation with a support technician by signing up for a Quickstart:
https://www.nagios.com/services/quickstart/

As a note, they do not offer quickstarts for Nagios Core; Just Nagios XI. It might also be worthwhile to spend some time understanding the different Nagios configuration objects:
https://assets.nagios.com/downloads/nag ... tions.html

Nagios configuration objects are the "building blocks" of how Nagios understands the infrastructure you want to monitor. Understanding them is critical in getting the most out of the software.

Here's the default Nagios Core contacts sample:

Code: Select all

###############################################################################
# CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS
#
#
# NOTES: This config file provides you with some example contact and contact
#        group definitions that you can reference in host and service
#        definitions.
#
#        You don't need to keep these definitions in a separate file from your
#        other object definitions.  This has been done just to make things
#        easier to understand.
#
###############################################################################



###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################

# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.

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                           nagios@localhost        ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }



###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################

# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagiosadmin
        }
Though, the above contact object references the "generic-contact" template, so you will need to make sure that template exists somewhere. Here's the one I currently have:

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!
        }
So you might want to add the admins contactgroup to your environment, if you intend to use it.
Former Nagios employee
https://www.mcapra.com/
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Error when add remote windows server

Post by dwhitfield »

mcapra wrote: As a note, they do not offer quickstarts for Nagios Core; Just Nagios XI.
Although, for clarity, we do offer Core support contracts: https://www.nagios.com/services/nagios- ... ort-plans/
Locked