Error: Template 'windows-server' specified in host

i have installed nagios 2.5 in my rhel 4 machine.when i do a preflight check i am getting a error like this

Error: Template ‘windows-server’ specified in host definition could not be not found (config file ‘/usr/local/nagios/etc/windows.cfg’, starting on line 2)

my windows.cfg file

define host{
use windows-server ; Inherit default values from a Windows server
host_name dev-sudhesh
alias Windows Server
address 192.168.142.125
}

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

define service{
use generic-service
host_name dev-sudhesh
service_description Uptime
check_command check_nt!UPTIME
}

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

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

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

define service{
use generic-service;
host_name dev-sudhesh
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}

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

PLease help me to solve this issue.

my hosts.cfg file

Host Definition

define host{

    use                             generic-host
    host_name                       linuxtest01.main.cobaltgroup.com
    alias                           Redhat Servers
    address                         192.168.142.119
    check_command                   check-host-alive
    max_check_attempts              5
    check_period                    24x7
    process_perf_data               0
    retain_nonstatus_information    0
    contact_groups                  admins
    notification_interval           30
    notification_period             24x7
    notification_options            d,u,r

}

define host{

    use                     generic-host
    host_name               dev-sudhesh
    alias                   Windows Servers
    address                 192.168.142.125
    check_command           check-host-alive
    max_check_attempts              5
    check_period                    24x7
    process_perf_data               0
    retain_nonstatus_information    0
    contact_groups                  admins
    notification_interval           30
    notification_period             24x7
    notification_options            d,u,r

    }

Change your host definition to look exactly like the following:

define host{
use generic-host ; Inherit default values from a Windows server
host_name generic service
alias Windows Server
address 192.168.142.125
}

You have defined your other hosts in your second post with generic-host and the first host definition with windows-server. That is where you are getting the error from nagios, change that and you should be alright!!!

thanks buddy i have done the following changes in my windows.cfg file.after that also i am getting error like this

Error: Invalid max_check_attempts value for host 'generic service’
Error: Could not register host (config file ‘/usr/local/nagios/etc/windows.cfg’, starting on line 2)

edited windows.cfg file

define host{
use generic-host ; Inherit default values from a Windows server
host_name generic service
alias Windows Server
address 192.168.142.125
}

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

define service{
use generic-service
host_name dev-sudhesh
service_description Uptime
check_command check_nt!UPTIME
}

Add the following into your host definitions:

You can also change that to any other value such as 3 or to what ever you want. That should fix the problem. Here is a couple of good websites that I use as a reference when I get stuck:

  1. nagios.sourceforge.net/docs/2_0/xodtemplate.html
  2. totkat.org/pages/nconf_commands.shtml

Let me know if you have any more questions.

thanks geofoxer that doucment was very useful for me.
right now i am getting error like this
Checking services…
Error: Service check command ‘check_nt’ specified in service ‘CPU Load’ for host ‘dev-sudhesh’ not defined anywhere!
Error: Service check command ‘check_nt’ specified in service ‘Explorer’ for host ‘dev-sudhesh’ not defined anywhere!
Error: Service check command ‘check_nt’ specified in service ‘Memory Usage’ for host ‘dev-sudhesh’ not defined anywhere!
Error: Service check command ‘check_nt’ specified in service ‘NSClient++ Version’ for host ‘dev-sudhesh’ not defined anywhere!
Error: Service check command ‘check_nt’ specified in service ‘Uptime’ for host ‘dev-sudhesh’ not defined anywhere!
Error: Service check command ‘check_nt’ specified in service ‘W3SVC’ for host ‘dev-sudhesh’ not defined anywhere!
Error: Service check command ‘check_nt’ specified in service ‘c:\ Drive Space’ for host ‘dev-sudhesh’ not defined anywhere!

and can i know wht is the function of checkcommand.cfg and command.cfg…

does check_nt exist in /usr/local/nagios/libexec?
if not, did you download the nagios plugins? If you haven’t, do that.

command.cfg has all of the command definitions, so when you use, say, check-host-alive, it finds the command in command.cfg.

yes check_nt exist in /usr/local/nagios/libexec

thanks a lot i am able to monitor my linux machines.but i am nt able to monitor my windows machines.by default i can monitor ping but other service i am not able to monitor and in the nagios web interface i am getting a error like check_nt: Could not parse arguments.

my command.cfg file

#sample command definitions for Nagios 2.6

Read the documentation for more information on this configuration file. I’ve

provided some comments here, but things may not be so clear without further

explanation, so make sure to read the HTML documentation!

Last Modified: 11-21-2006

################################################################################

################################################################################

COMMAND DEFINITIONS

SYNTAX:

define command{

template

name

command_name

command_line

}

WHERE:

= object name of another command definition that should be

used as a template for this definition (optional)

= object name of command definition, referenced by other

command definitions that use it as a template (optional)

= name of the command, as recognized/used by Nagios

= command line

################################################################################

################################################################################

SAMPLE SERVICE CHECK COMMANDS

These are some example service check commands. They may or may not work on

your system, as they must be modified for your plugins. See the HTML

documentation on the plugins for examples of how to configure command definitions.

################################################################################

################################################################################

NOTE: The following ‘check_local_…’ functions are designed to monitor

various metrics on the host that Nagios is running on (i.e. this one).

################################################################################

‘check_local_disk’ command definition

define command{
command_name check_local_disk
command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
}

‘check_local_load’ command definition

define command{
command_name check_local_load
command_line $USER1$/check_load -w $ARG1$ -c $ARG2$
}

‘check_local_procs’ command definition

define command{
command_name check_local_procs
command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
}

‘check_local_users’ command definition

define command{
command_name check_local_users
command_line $USER1$/check_users -w $ARG1$ -c $ARG2$
}

################################################################################

NOTE: The following ‘check_…’ commands are used to monitor services on

both local and remote hosts.

################################################################################

define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s -v $ARG1$ $ARG2$
}

‘check_dns’ command definition

define command{
command_name check_dns
command_line $USER1$/check_dns -H www.yahoo.com -s $HOSTADDRESS$
}

‘check_ftp’ command definition

define command{
command_name check_ftp
command_line $USER1$/check_ftp -H $HOSTADDRESS$
}

‘check_hpjd’ command definition

define command{
command_name check_hpjd
command_line $USER1$/check_hpjd -H $HOSTADDRESS$ -C public
}

‘check_http’ command definition

define command{
command_name check_http
command_line $USER1$/check_http -H $HOSTADDRESS$
}

‘check_nntp’ command definition

define command{
command_name check_nntp
command_line $USER1$/check_nntp -H $HOSTADDRESS$
}

‘check_ping’ command definition

define command{
command_name check_ping
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}

‘check_pop’ command definition

define command{
command_name check_pop
command_line $USER1$/check_pop -H $HOSTADDRESS$
}

‘check_smtp’ command definition

define command{
command_name check_smtp
command_line $USER1$/check_smtp -H $HOSTADDRESS$
}

‘check_tcp’ command definition

define command{
command_name check_tcp
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$
}

‘check_telnet’ command definition

define command{
command_name check_telnet
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 23
}

‘check_udp’ command definition

define command{
command_name check_udp
command_line $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$
}

C:\ volume

define command{
command_name check_nt_C_drive_repDom
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 1248 -v USEDDISKSPACE -l c -w 90 -c 95 -t 90
}

################################################################################

SAMPLE HOST CHECK COMMANDS

################################################################################

This command checks to see if a host is “alive” by pinging it

The check must result in a 100% packet loss or 5 second (5000ms) round trip

average time to produce a critical error.

Note: Only one ICMP echo packet is sent (determined by the ‘-p 1’ argument)

‘check-host-alive’ command definition

define command{
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 1
}

################################################################################

SAMPLE NOTIFICATION COMMANDS

These are some example notification commands. They may or may not work on

your system without modification. As an example, some systems will require

you to use “/usr/bin/mailx” instead of “/usr/bin/mail” in the commands below.

################################################################################

‘host-notify-by-email’ command definition

define command{
command_name host-notify-by-email
command_line /usr/bin/printf “%b” “***** Nagios 2.6 *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | -s “Host $HOSTSTATE$ alert for $HOSTNAME$!” $CONTACTEMAIL$
}

‘host-notify-by-epager’ command definition

define command{
command_name host-notify-by-epager
command_line /usr/bin/printf “%b” “Host ‘$HOSTALIAS$’ is $HOSTSTATE$\nInfo: $HOSTOUTPUT$\nTime: $LONGDATETIME$” | -s “$NOTIFICATIONTYPE$ alert - Host $HOSTNAME$ is $HOSTSTATE$” $CONTACTPAGER$
}

‘notify-by-email’ command definition

define command{
command_name notify-by-email
command_line /usr/bin/printf “%b” “***** Nagios 2.6 ***\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | -s " $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}

‘notify-by-epager’ command definition

define command{
command_name notify-by-epager
command_line /usr/bin/printf “%b” “Service: $SERVICEDESC$\nHost: $HOSTNAME$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nInfo: $SERVICEOUTPUT$\nDate: $LONGDATETIME$” | -s “$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$” $CONTACTPAGER$
}

################################################################################

SAMPLE PERFORMANCE DATA COMMANDS

These are sample performance data commands that can be used to send performance

data output to two text files (one for hosts, another for services). If you

plan on simply writing performance data out to a file, consider using the

host_perfdata_file and service_perfdata_file options in the main config file.

################################################################################

‘process-host-perfdata’ command definition

define command{
command_name process-host-perfdata
command_line /usr/bin/printf “%b” “$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n” >> /usr/local/nagios/var/host-perfdata.out
}

‘process-service-perfdata’ command definition

define command{
command_name process-service-perfdata
command_line /usr/bin/printf “%b” “$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n” >> /usr/local/nagios/var/service-perfdata.out
}

and my services.cfg

################################################################################

Sample object config file for Nagios

Read the documentation for more information on this configuration file. I’ve

provided some comments here, but things may not be so clear without further

explanation, so make sure to read the HTML documentation!

Last Modified: 09-17-2002

################################################################################

################################################################################

SERVICE DEFINITIONS

SYNTAX:

################################################################################

Generic service definition 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
obsess_over_service 1 ; We should obsess over this service
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
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across
retain_nonstatus_information 1 ; Retain non-status information

register			0	; DONT REGISTER THIS DEFINITION
}

Define a service to “ping” the local machine

define service{
use generic-service ; Name of service templ
host_name linuxtest01.main.cobaltgroup.com
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
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				generic-service	; Name of service
    host_name                       linuxtest01.main.cobaltgroup.com
    service_description             Root Partition
    is_volatile                     0
    check_period                    24x7
    max_check_attempts              4
    normal_check_interval           5
    retry_check_interval            1
    contact_groups                  admins
    notification_options            w,u,c,r
    notification_interval           960
    notification_period             24x7
    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				generic-service		; Name of service template to use
    host_name                       linuxtest01.main.cobaltgroup.com
    service_description             Current Users
    is_volatile                     0
    check_period                    24x7
    max_check_attempts              4
    normal_check_interval           5
    retry_check_interval            1
    contact_groups                  admins
notification_options		w,u,c,r
    notification_interval           960
    notification_period             24x7
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				generic-service	; Name of service
    host_name                       linuxtest01.main.cobaltgroup.com
    service_description             Total Processes
    is_volatile                     0
    check_period                    24x7
    max_check_attempts              4
    normal_check_interval           5
    retry_check_interval            1
    contact_groups                  admins
notification_options		w,u,c,r
    notification_interval           960
    notification_period             24x7
check_command			check_local_procs!250!400
    }

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

define service{

    use				generic-service		; Name of to use
    host_name                       linuxtest01.main.cobaltgroup.com
    service_description             Current Load
    is_volatile                     0
    check_period                    24x7
    max_check_attempts              4
    normal_check_interval           5
    retry_check_interval            1
    contact_groups                  admins
notification_options		w,u,c,r
    notification_interval           960
    notification_period             24x7
check_command			check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
    }

define service{

   use                             generic-service         ; Name of use
   host_name                       dev-sudhesh
   service_description             PING
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              4
   normal_check_interval           5
   retry_check_interval            1
   contact_groups                  admins
   notification_interval           960
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_ping!100.0,20%!500.0,60%
   }

define service{

   use                             generic-service         ; Name of use
   host_name                       dev-sudhesh
   service_description             NSClient++ Version
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              4
   normal_check_interval           5
   retry_check_interval            1
   contact_groups                  admins
   notification_interval           960
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!CLIENTVERSION

   }

define service{

   use                             generic-service         ; Name of use
   host_name                       dev-sudhesh
   service_description             Uptime
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              4
   normal_check_interval           5
   retry_check_interval            1
   contact_groups                  admins
   notification_interval           960
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!UPTIME

   }

Service definition

define service{

   use                             generic-service         ; Name of use
   host_name                       dev-sudhesh
   service_description             CPU Load  
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              3
   normal_check_interval           5
   retry_check_interval            2
   contact_groups                  admins
   notification_interval           240
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!CPULOAD!-l 5,80,90

   }

Service definition

define service{

   use                             generic-service         ; Name of use
   host_name                       dev-sudhesh
   service_description             Memory Usage
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              3
   normal_check_interval           5
   retry_check_interval            2
   contact_groups                  admins
   notification_interval           240
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!MEMUSE!-w 80 -c 90

   }

Service definition

define service{

   use                             generic-service         ; Name of use
   host_name                       dev-sudhesh
   service_description             c:\ Drive Space
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              3
   normal_check_interval           5
   retry_check_interval            2
   contact_groups                  admins
   notification_interval           240
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!USEDDISKSPACE!-l c -w 80 -c 90

   }

Service definition

define service{

   use                             generic-service         ; Name of use
   host_name                       dev-sudhesh
   service_description             W3SVC
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              3
   normal_check_interval           5
   retry_check_interval            2
   contact_groups                  admins
   notification_interval           240
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!SERVICESTATE!-d SHOWALL -l W3SVC

   }

Service definition

define service{

   use                             generic-service         ; Name of use
   host_name                       dev-sudhesh
   service_description             Explorer
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              3
   normal_check_interval           5
   retry_check_interval            2
   contact_groups                  admins
   notification_interval           240
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe

   }

define service{

   use                             generic-service         ; Name of use
   host_name                       svr-macafee
   service_description             PING
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              4
   normal_check_interval           5
   retry_check_interval            1
   contact_groups                  admins
   notification_interval           960
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_ping!100.0,20%!500.0,60%
   }

define service{

   use                             generic-service         ; Name of use
   host_name                       svr-macafee
   service_description             NSClient++ Version
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              4
   normal_check_interval           5
   retry_check_interval            1
   contact_groups                  admins
   notification_interval           960
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!CLIENTVERSION

   }

define service{

   use                             generic-service         ; Name of use
   host_name                       svr-macafee
   service_description             Uptime
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              4
   normal_check_interval           5
   retry_check_interval            1
   contact_groups                  admins
   notification_interval           960
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!UPTIME

   }

Service definition

define service{

   use                             generic-service         ; Name of use
   host_name                       svr-macafee
   service_description             CPU Load  
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              3
   normal_check_interval           5
   retry_check_interval            2
   contact_groups                  admins
   notification_interval           240
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!CPULOAD!-l 5,80,90

   }

Service definition

define service{

   use                             generic-service         ; Name of use
   host_name                       svr-macafee
   service_description             Memory Usage
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              3
   normal_check_interval           5
   retry_check_interval            2
   contact_groups                  admins
   notification_interval           240
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!MEMUSE!-w 80 -c 90

   }

Service definition

define service{

   use                             generic-service         ; Name of use
   host_name                       svr-macafee
   service_description             c:\ Drive Space
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              3
   normal_check_interval           5
   retry_check_interval            2
   contact_groups                  admins
   notification_interval           240
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!USEDDISKSPACE!-l c -w 80 -c 90

   }

Service definition

define service{

   use                             generic-service         ; Name of use
   host_name                       svr-macafee
   service_description             W3SVC
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              3
   normal_check_interval           5
   retry_check_interval            2
   contact_groups                  admins
   notification_interval           240
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!SERVICESTATE!-d SHOWALL -l W3SVC

   }

Service definition

define service{

   use                             generic-service         ; Name of use
   host_name                       svr-macafee
   service_description             Explorer
   is_volatile                     0
   check_period                    24x7
   max_check_attempts              3
   normal_check_interval           5
   retry_check_interval            2
   contact_groups                  admins
   notification_interval           240
   notification_period             24x7
   notification_options            w,u,c,r
   check_command                   check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe

   }

Please let me know if i have to do any modification in this 2 configuration file…currently i am montoring 3 machine.2 windows machine and one linux machine(nagios server).thank u