Page 1 of 2
Error when add remote windows server
Posted: Fri Jul 14, 2017 1:11 am
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
Re: Error when add remote windows server
Posted: Fri Jul 14, 2017 2:07 pm
by dwhitfield
Please attach your entire windows.cfg. Also, please attach your entire nagios.cfg.
Re: Error when add remote windows server
Posted: Fri Jul 14, 2017 10:31 pm
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.
Re: Error when add remote windows server
Posted: Mon Jul 17, 2017 12:17 pm
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.
Re: Error when add remote windows server
Posted: Thu Jul 20, 2017 12:38 am
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
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
Any help, Thanks you !
Re: Error when add remote windows server
Posted: Thu Jul 20, 2017 2:38 pm
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
Re: Error when add remote windows server
Posted: Thu Jul 20, 2017 3:35 pm
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.
Re: Error when add remote windows server
Posted: Fri Jul 21, 2017 4:24 am
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!
Re: Error when add remote windows server
Posted: Fri Jul 21, 2017 8:42 am
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.
Re: Error when add remote windows server
Posted: Fri Jul 21, 2017 12:21 pm
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/