Need nagios config help

Asgorath

[H]ard|Gawd
Joined
Jul 12, 2004
Messages
1,253
Ok, so I have running via the install on 'Network Security Tools'

I have it running with the 'minimal ping configuration' with just one host, and it's working fine.

However, I want to monitor a windows box, so I'm following the tutorial here...

http://www.thegeekstuff.com/2008/07/how-to-monitor-remote-windows-machine-using-nagios-on-linux/

As soon as I uncomment windows.cfg in nagios.cfg, the nagios service won't restart. It tells me to check my configuration.

I'm not sure where it's going bad. Any good nagios people in here who would be willing to help me out? I've been bangin my head against the wall all day. I can easily reset everything i've done via the NST interface to a basic ping config.

It may be easier in chat if you wanna PM me we can talk on AIM or gmail chat
 
windows.cfg
Code:
###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################


# Create a service for monitoring the version of NSCLient++ that is installed
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility.goodmandean.com
	service_description	NSClient++ Version
	check_command		check_nt!CLIENTVERSION
	}



# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility.goodmandean.com
	service_description	Uptime
	check_command		check_nt!UPTIME
	}



# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility.goodmandean.com
	service_description	CPU Load
	check_command		check_nt!CPULOAD!-l 5,80,90
	}



# Create a service for monitoring 
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility.goodmandean.com
	service_description	Memory Usage
	check_command		check_nt!MEMUSE!-w 80 -c 90
	}



# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility.goodmandean.com
	service_description	C:\ Drive Space
	check_command		check_nt!USEDDISKSPACE!-l c -w 80 -c 90
	}



# Create a service for monitoring the W3SVC service
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility.goodmandean.com
	service_description	W3SVC
	check_command		check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
	}



# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility.goodmandean.com
	service_description	Explorer
	check_command		check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
	}

hosts.cfg
Code:
define host {
	use			generic-host
	host_name		probe-eth0.goodmandean.com
	address			192.168.1.140
        check_command		check-host-alive
        max_check_attempts	10
	notification_interval	120
	notification_period	24x7
	notification_options	d,u,r
	contact_groups		nst-admins
}
define host {
	use			generic-host
	host_name		la-utility.goodmandean.com
	address			192.168.1.13
        check_command		check-host-alive
        max_check_attempts	10
	notification_interval	120
	notification_period	24x7
	notification_options	d,u,r
	contact_groups		nst-admins
}
 
services.cfg
Code:
define service  {
use	generic-service
host_name 	web1
service_description	HTTP
is_volatile	0
check_period	24x7
max_check_attempts	3
normal_check_interval	5
retry_check_interval	1
contact_groups	flcd-admins
notification_interval	120
notification_period	24x7
notification_options	w,u,c,r
check_command	check_http
}



define service {
	use	generic-service
	host_name	berlin
	service_description	SMTP
	is_volatile	0
	check_period	24x7
	max_check_attempts	3
	normal_check_interval	5
	retry_check_interval	1
	contact_groups	flcd-admins
	notification_interval	240
	notification_period	24x7
	notification_options	w,u,c,
	check_command	check_smtp
}


define service {
	host_name	koeln
	service_description	check koeln diskspace
	check_command	check-disk-koeln
	max_check_attempts	5
	normal_check_interval	5
	retry_check_interval	3
	check_period	24x7
	notification_interval	30
	notification_period	24x7
	notification_options	w,c,r
	contact_groups	flcd-admins
}

define service {
        host_name       Phoenix
        service_description     check Phoenix diskspace
        check_command   check-disk-Phoenix
        max_check_attempts      5
        normal_check_interval   5
        retry_check_interval    3
        check_period    24x7
        notification_interval   30
        notification_period     24x7
        notification_options    w,c,r
        contact_groups  flcd-admins
}

define service {
        host_name       Phoenix
        service_description     check Phoenix uptime
        check_command   check-uptime
        max_check_attempts      5
        normal_check_interval   5
        retry_check_interval    3
        check_period    24x7
        notification_interval   30
        notification_period     24x7
        notification_options    w,c,r
        contact_groups  flcd-admins
}


define service {
        host_name       probe
        service_description     check probe diskspace
        check_command   check-disk-probe
        max_check_attempts      5
        normal_check_interval   5
        retry_check_interval    3
        check_period    24x7
        notification_interval   30
        notification_period     24x7
        notification_options    w,c,r
        contact_groups  flcd-admins
}

define service {
        host_name       samba1
        service_description     check samba1 diskspace
        check_command   check-disk-samba1
        max_check_attempts      5
        normal_check_interval   5
        retry_check_interval    3
        check_period    24x7
        notification_interval   30
        notification_period     24x7
        notification_options    w,c,r
        contact_groups  flcd-admins
}
 
where did you get services.cfg from?

your hosts and your services should be in one .cfg file eg windows.cfg and this file should be linked to via the nagios.cfg.

if you have linux boxes then make a second config called linux,, add the services and the hosts in there and link that in you nagios.cfg etc etc
 
Last edited:
I tried following that tutorial that I have linked above, and they used the methodoligy that you described. It was giving me the same problem...as soon as I linked in windows.cfg in my nagios.cfg, it broke the config.

My current configs are a bit fubar'd.

Do you have a sample config you can post that involves monitoring some windows hosts? If there is sensitive info in there just ###### it out or something.

I think a fully working example would help me out alot.
 
Have you run nagios -v on the nagios.cfg file? If not, that should give you a better idea of what the problem is.
 
I wiped out my config and started again, then started working on that tutorial again.

First thing...the check_nt service was not defined in commands.cfg. I added the entry, per the tutorial. Then restarted nagios. No problem.
# 'check_nt' command definition
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$

Next, templates.cfg did not exist and nagios.cfg had no reference of it. So I created it, added it to the nagios.cfg.

Here is the code of my templates.cfg
Code:
###############################################################################
# TEMPLATES.CFG - SAMPLE OBJECT TEMPLATES
#
# Last Modified: 10-03-2007
#
# NOTES: This config file provides you with some example object definition
#        templates that are refered by other host, service, contact, etc.
#        definitions in other config files.
#       
#        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.
#
###############################################################################



###############################################################################
###############################################################################
#
# CONTACT TEMPLATES
#
###############################################################################
###############################################################################

# Generic contact definition template - This is NOT a real contact, just a template!

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!
        }




###############################################################################
###############################################################################
#
# HOST TEMPLATES
#
###############################################################################
###############################################################################

# Generic host definition template - This is NOT a real host, just a template!

define host{
        name                            generic-host    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }


# Linux host definition template - This is NOT a real host, just a template!

define host{
	name				linux-server	; The name of this host template
	use				generic-host	; This template inherits other values from the generic-host template
	check_period			24x7		; By default, Linux hosts are checked round the clock
	check_interval			5		; Actively check the host every 5 minutes
	retry_interval			1		; Schedule host check retries at 1 minute intervals
	max_check_attempts		10		; Check each Linux host 10 times (max)
        check_command           	check-host-alive ; Default command to check Linux hosts
	notification_period		workhours	; Linux admins hate to be woken up, so we only notify during the day
							; Note that the notification_period variable is being overridden from
							; the value that is inherited from the generic-host template!
	notification_interval		120		; Resend notifications every 2 hours
	notification_options		d,u,r		; Only send notifications for specific host states
	contact_groups			admins		; Notifications get sent to the admins by default
	register			0		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A 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
	}


# We define a generic printer template that can be used for most printers we monitor

define host{
	name			generic-printer	; The name of this host template
	use			generic-host	; Inherit default values from the generic-host template
	check_period		24x7		; By default, printers are monitored round the clock
	check_interval		5		; Actively check the printer every 5 minutes
	retry_interval		1		; Schedule host check retries at 1 minute intervals
	max_check_attempts	10		; Check each printer 10 times (max)
	check_command		check-host-alive	; Default command to check if printers are "alive"
	notification_period	workhours		; Printers are only used during the workday
	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
	register		0		; DONT REGISTER THIS - ITS JUST A TEMPLATE
	}


# Define a template for switches that we can reuse
define host{
	name			generic-switch	; The name of this host template
	use			generic-host	; Inherit default values from the generic-host template
	check_period		24x7		; By default, switches are monitored round the clock
	check_interval		5		; Switches are checked every 5 minutes
	retry_interval		1		; Schedule host check retries at 1 minute intervals
	max_check_attempts	10		; Check each switch 10 times (max)
	check_command		check-host-alive	; Default command to check if routers are "alive"
	notification_period	24x7		; Send notifications at any time
	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
	register		0		; DONT REGISTER THIS - ITS JUST A TEMPLATE
	}




###############################################################################
###############################################################################
#
# SERVICE TEMPLATES
#
###############################################################################
###############################################################################

# Generic service definition template - This is NOT a real service, just a template!

define service{
        name                            generic-service 	; The 'name' of this service template
        active_checks_enabled           1       		; Active service checks are enabled
        passive_checks_enabled          1    		   	; Passive service checks are enabled/accepted
        parallelize_check               1       		; Active service checks should be parallelized (disabling this can lead to major performance problems)
        obsess_over_service             1       		; We should obsess over this service (if necessary)
        check_freshness                 0       		; Default is to NOT check service 'freshness'
        notifications_enabled           1       		; Service notifications are enabled
        event_handler_enabled           1       		; Service event handler is enabled
        flap_detection_enabled          1       		; Flap detection is enabled
        failure_prediction_enabled      1       		; Failure prediction is enabled
        process_perf_data               1       		; Process performance data
        retain_status_information       1       		; Retain status information across program restarts
        retain_nonstatus_information    1       		; Retain non-status information across program restarts
        is_volatile                     0       		; The service is not volatile
        check_period                    24x7			; The service can be checked at any time of the day
        max_check_attempts              3			; Re-check the service up to 3 times in order to determine its final (hard) state
        normal_check_interval           10			; Check the service every 10 minutes under normal conditions
        retry_check_interval            2			; Re-check the service every two minutes until a hard state can be determined
        contact_groups                  admins			; Notifications get sent out to everyone in the 'admins' group
	notification_options		w,u,c,r			; Send notifications about warning, unknown, critical, and recovery events
        notification_interval           60			; Re-notify about service problems every hour
        notification_period             24x7			; Notifications can be sent out at any time
         register                        0       		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }


# Local service definition template - This is NOT a real service, just a template!

define service{
	name				local-service 		; The name of this service template
	use				generic-service		; Inherit default values from the generic-service definition
        max_check_attempts              4			; Re-check the service up to 4 times in order to determine its final (hard) state
        normal_check_interval           5			; Check the service every 5 minutes under normal conditions
        retry_check_interval            1			; Re-check the service every minute until a hard state can be determined
        register                        0       		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
	}

I tried to restart nagios, but it failed. Here is the -v output.
[root@probe-eth0 nagios]# /usr/sbin/nagios -v /usr/nagios/nagios.cfg

Nagios 2.11
Copyright (c) 1999-2007 Ethan Galstad (http://www.nagios.org)
Last Modified: 03-12-2008
License: GPL

Reading configuration data...

Error: Cannot open main configuration file '/usr/nagios/nagios.cfg' for reading!

***> 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.

[root@probe-eth0 nagios]#

From what I understand, that template shouldn't do much of anything, its just there to define object definitions. I don't see a path in that file, and the path I entered in nagios.cfg is correct.
from nagios.cfg
# Command definitions
cfg_file=/etc/nagios/commands.cfg

# Host and service definitions for monitoring this machine
cfg_file=/etc/nagios/localhost.cfg
cfg_file=/etc/nagios/templates.cfg

I have a windows.cfg that I modified, but I didn't want to put it in until we at least got past this step. Any advice?
 
My windows.cfg
Code:
###############################################################################
# WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE
#
# Last Modified: 06-13-2007
#
# NOTES: This config file assumes that you are using the sample configuration
#	 files that get installed with the Nagios quickstart guide.
#
###############################################################################




###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# Define a host for the Windows machine we'll be monitoring
# Change the host_name, alias, and address to fit your situation

define host{
	use		windows-server	; Inherit default values from a template
	host_name	la-utility	; The name we're giving to this host
	alias		la-utility.goodmandean.com	; A longer name associated with the host
	address		192.168.1.13	; IP address of the host
	}




###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################


# Define a hostgroup for Windows machines
# All hosts that use the windows-server template will automatically be a member of this group

define hostgroup{
	hostgroup_name	windows-servers	; The name of the hostgroup
	alias		Windows Servers	; Long name of the group
	}




###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################


# Create a service for monitoring the version of NSCLient++ that is installed
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility
	service_description	NSClient++ Version
	check_command		check_nt!CLIENTVERSION
	}



# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility
	service_description	Uptime
	check_command		check_nt!UPTIME
	}



# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility
	service_description	CPU Load
	check_command		check_nt!CPULOAD!-l 5,80,90
	}



# Create a service for monitoring 
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility
	service_description	Memory Usage
	check_command		check_nt!MEMUSE!-w 80 -c 90
	}



# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility
	service_description	C:\ Drive Space
	check_command		check_nt!USEDDISKSPACE!-l c -w 80 -c 90
	}



# Create a service for monitoring the W3SVC service
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility
	service_description	W3SVC
	check_command		check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
	}



# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above

define service{
	use			generic-service
	host_name		la-utility
	service_description	Explorer
	check_command		check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
	}

Here's a listing of what files are in my nagios directory
[root@probe-eth0 nagios]# ls -D
cgi.cfg commands.cfg localhost.cfg minimal.cfg nagios.cfg nrpe.cfg private templates.cfg
 
Code:
[root@probe-eth0 nagios]# ls -l
total 108
-rw-rw-r-- 1 nagios nagios  9467 2009-01-08 10:21 cgi.cfg
-rw-rw-r-- 1 nagios nagios  8643 2009-04-27 17:17 commands.cfg
-rw-rw-r-- 1 nagios nagios 12469 2008-04-09 11:25 localhost.cfg
-rw-rw-r-- 1 nagios nagios 11095 2009-01-08 10:21 minimal.cfg
-rw-rw-r-- 1 nagios nagios 30930 2009-04-27 17:18 nagios.cfg
-rw-rw-r-- 1 nagios nagios  7077 2007-02-23 15:51 nrpe.cfg
drwxrws--- 2 nagios nagios  4096 2009-04-27 17:25 private
-rw-r--r-- 1 root   nagios 10814 2009-04-27 17:18 templates.cfg
 
Anyone able to help? I'm a bit stuck on this...I'm thinking of ordering a nagios book to help me walk through a good configuration.
 
[root@probe-eth0 nagios]# /usr/sbin/nagios -v /usr/nagios/nagios.cfg

I think your nagios.cfg file is in /etc/nagios not /usr/nagios hence why it can't be opened.
 
The error you might be seeing is because of the contact groups in the templates.cfg file. Do you have a contact group of admins defined somewhere?
 
[root@probe-eth0 nagios]# /usr/sbin/nagios -v /usr/nagios/nagios.cfg

I think your nagios.cfg file is in /etc/nagios not /usr/nagios hence why it can't be opened.

good call...

I ran this...

Code:
[root@probe-eth0 nagios]# /usr/sbin/nagios -v /etc/nagios/nagios.cfg

Nagios 2.11
Copyright (c) 1999-2007 Ethan Galstad (http://www.nagios.org)
Last Modified: 03-12-2008
License: GPL

Reading configuration data...

Error: Invalid service notification option 's' in contact definition.
Error: Could not add object property in file '/etc/nagios/templates.cfg' on line 33.

***> 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.
 
The error you might be seeing is because of the contact groups in the templates.cfg file. Do you have a contact group of admins defined somewhere?

Yes I do, in localhost.cfg
Code:
###############################################################################
# LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
#
# Last Modified: 11-27-2006
#
# NOTE: This config file is intended to servce as an *extremely* simple 
#       example of how you can create your object configuration file(s).
#
###############################################################################



###############################################################################
###############################################################################
#
# TIME PERIODS
#
###############################################################################
###############################################################################

# This defines a timeperiod where all times are valid for checks, 
# notifications, etc.  The classic "24x7" support nightmare. :-)

define timeperiod{
        timeperiod_name 24x7
        alias           24 Hours A Day, 7 Days A Week
        sunday          00:00-24:00
        monday          00:00-24:00
        tuesday         00:00-24:00
        wednesday       00:00-24:00
        thursday        00:00-24:00
        friday          00:00-24:00
        saturday        00:00-24:00
        }


# 'workhours' timeperiod definition
define timeperiod{
	timeperiod_name	workhours
	alias		"Normal" Working Hours
	monday		09:00-17:00
	tuesday		09:00-17:00
	wednesday	09:00-17:00
	thursday	09:00-17:00
	friday		09:00-17:00
	}


# 'nonworkhours' timeperiod definition
define timeperiod{
	timeperiod_name	nonworkhours
	alias		Non-Work Hours
	sunday		00:00-24:00
	monday		00:00-09:00,17:00-24:00
	tuesday		00:00-09:00,17:00-24:00
	wednesday	00:00-09:00,17:00-24:00
	thursday	00:00-09:00,17:00-24:00
	friday		00:00-09:00,17:00-24:00
	saturday	00:00-24:00
	}


# 'none' timeperiod definition
define timeperiod{
	timeperiod_name	none
	alias		No Time Is A Good Time
	}



###############################################################################
###############################################################################
#
# COMMANDS
#
###############################################################################
###############################################################################

# NOTE: Sample command definitions can now be found in the sample commands.cfg 
#       file




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

# In this simple config file, a single contact will receive all alerts.
# This assumes that you have an account (or email alias) called
# "nagios-admin" on the local host.

define contact{
        contact_name                    nagios-admin
        alias                           Nagios Admin
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-by-email
        host_notification_commands      host-notify-by-email
        email                           nagios-admin@localhost
        }



###############################################################################
###############################################################################
#
# 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                 nagios-admin
        }



###############################################################################
###############################################################################
#
# HOSTS
#
###############################################################################
###############################################################################

# Generic host definition template - This is NOT a real host, just a template!

define host{
        name                            generic-host    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }


# Linux host definition template - This is NOT a real host, just a template!

define host{
	name				linux-server	; The name of this host template
	use				generic-host	; This template inherits other values from the generic-host template
	check_period			24x7		; By default, Linux hosts are checked round the clock
	max_check_attempts		10		; Check each Linux host 10 times (max)
        check_command           	check-host-alive ; Default command to check Linux hosts
	notification_period		workhours	; Linux admins hate to be woken up, so we only notify during the day
							; Note that the notification_period variable is being overridden from
							; the value that is inherited from the generic-host template!
	notification_interval		120		; Resend notification every 2 hours
	notification_options		d,u,r		; Only send notifications for specific host states
	contact_groups			admins		; Notifications get sent to the admins by default
	register			0		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
	}


# Since this is a simple configuration file, we only monitor one host - the
# local host (this machine).

define host{
        use                     linux-server            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the linux-server host template definition.
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        }



###############################################################################
###############################################################################
#
# HOST GROUPS
#
###############################################################################
###############################################################################

# We only have one host in our simple config file, so there is no need to
# create more than one hostgroup.

define hostgroup{
        hostgroup_name  test
        alias           Test Servers
        members         localhost
        }



###############################################################################
###############################################################################
#
# SERVICES
#
###############################################################################
###############################################################################

# Generic service definition template - This is NOT a real service, just a template!

define service{
        name                            generic-service 	; The 'name' of this service template
        active_checks_enabled           1       		; Active service checks are enabled
        passive_checks_enabled          1    		   	; Passive service checks are enabled/accepted
        parallelize_check               1       		; Active service checks should be parallelized (disabling this can lead to major performance problems)
        obsess_over_service             1       		; We should obsess over this service (if necessary)
        check_freshness                 0       		; Default is to NOT check service 'freshness'
        notifications_enabled           1       		; Service notifications are enabled
        event_handler_enabled           1       		; Service event handler is enabled
        flap_detection_enabled          1       		; Flap detection is enabled
        failure_prediction_enabled      1       		; Failure prediction is enabled
        process_perf_data               1       		; Process performance data
        retain_status_information       1       		; Retain status information across program restarts
        retain_nonstatus_information    1       		; Retain non-status information across program restarts
        is_volatile                     0       		; The service is not volatile
        register                        0       		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }


# Local service definition template - This is NOT a real service, just a template!

define service{
	name				local-service 		; The name of this service template
	use				generic-service		; Inherit default values from the generic-service definition
        check_period                    24x7			; The service can be checked at any time of the day
        max_check_attempts              4			; Re-check the service up to 4 times in order to determine its final (hard) state
        normal_check_interval           5			; Check the service every 5 minutes under normal conditions
        retry_check_interval            1			; Re-check the service every minute until a hard state can be determined
        contact_groups                  admins			; Notifications get sent out to everyone in the 'admins' group
	notification_options		w,u,c,r			; Send notifications about warning, unknown, critical, and recovery events
        notification_interval           60			; Re-notify about service problems every hour
        notification_period             24x7			; Notifications can be sent out at any time
        register                        0       		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
	}


# Define a service to "ping" the local machine

define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        service_description             PING
	check_command			check_ping!100.0,20%!500.0,60%
        }


# Define a service to check the disk space of the root partition
# on the local machine.  Warning if < 20% free, critical if
# < 10% free space on partition.

define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        service_description             Root Partition
	check_command			check_local_disk!20%!10%!/
        }



# Define a service to check the number of currently logged in
# users on the local machine.  Warning if > 20 users, critical
# if > 50 users.

define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        service_description             Current Users
	check_command			check_local_users!20!50
        }


# Define a service to check the number of currently running procs
# on the local machine.  Warning if > 250 processes, critical if
# > 400 users.

define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        service_description             Total Processes
	check_command			check_local_procs!250!400!RSZDT
        }



# Define a service to check the load on the local machine. 

define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        service_description             Current Load
	check_command			check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
        }
 
Removing the 's' will fix the error your seeing now...looks like it is a Nagios 3.x thing and not in Nagios 2.x
 
In your templates.cfg file remove the s from the host and service notification lines

define contact{
name generic-contact
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
register 0
}
 
Ok, had to also comment out 'retry_interval' in a few places in templates.cfg.
Code:
[root@probe-eth0 nagios]# /usr/sbin/nagios -v /etc/nagios/nagios.cfg

Nagios 2.11
Copyright (c) 1999-2007 Ethan Galstad (http://www.nagios.org)
Last Modified: 03-12-2008
License: GPL

Reading configuration data...

Warning: Duplicate definition found for service 'generic-service' (config file '/etc/nagios/templates.cfg', starting on line 154)
Warning: Duplicate definition found for service 'local-service' (config file '/etc/nagios/templates.cfg', starting on line 183)
Running pre-flight check on configuration data...

Checking services...
        Checked 5 services.
Checking hosts...
        Checked 1 hosts.
Checking host groups...
        Checked 1 host groups.
Checking service groups...
        Checked 0 service groups.
Checking contacts...
        Checked 1 contacts.
Checking contact groups...
        Checked 1 contact groups.
Checking service escalations...
        Checked 0 service escalations.
Checking service dependencies...
        Checked 0 service dependencies.
Checking host escalations...
        Checked 0 host escalations.
Checking host dependencies...
        Checked 0 host dependencies.
Checking commands...
        Checked 23 commands.
Checking time periods...
        Checked 4 time periods.
Checking extended host info definitions...
        Checked 0 extended host info definitions.
Checking extended service info definitions...
        Checked 0 extended service info definitions.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
[root@probe-eth0 nagios]#

Now it's working. Now it's time to actually add some hosts in.
 
Last edited:
dancingcool.gif
 
How do you organize your nagios stuff?

I just created a new windows.cfg file and am having it monitor one host. It has alot of definitions in it. Should I make a new cfg file for every windows host, put all the windows hosts in their own windows directory, and then tell nagios.cfg to read all the cfg files in the directories...so I don't have to specify each additional server I want to montior?
 
Personally I have a hosts, services, hostgroup, servicegroup, templates and contacts file. Now that I am monitoring our servers in customer locations I have created files for each customer. I don't think there is a proper way to do it....just easier for me to follow I guess. :eek:
 
Back
Top