Page 1 of 2

Windows Check_nt issues

Posted: Tue Jan 07, 2014 4:52 pm
by TmyFrn
First time Nagios install and setup. No problem with external, passive checks. I am now trying to set up checks for windows machines.

I am able to do a manual check and get good responses, like such:

Code: Select all

     /usr/lib/nagios/plugins/check_nt -H 10.2.1.82 -p 12489 -v USEDDISKSPACE -d SHOWALL -l c
     c:\ - total: 59.90 Gb - used: 18.56 Gb (31%) - free 41.34 Gb (69%) | 'c:\ Used Space'=18.56Gb;0.00;0.00;0.00;59.90

Code: Select all

     /usr/lib/nagios/plugins/check_nt -H 10.2.1.82 -p 12489 -v UPTIME
     System Uptime - 3 day(s) 22 hour(s) 17 minute(s)
When these run from the windows.cfg file I get an errors:
DriveSpace gives: missing -l parameters
UPTIME gives: socket timeout after 10 seconds

There are 6 default commands in the windows.cfg file and they all give the "socket timeout error" or "missing -l parameters".

From the windows.cfg file (complete file below):

Code: Select all

define service{
	use			generic-service
	hostgroup_name		windows-servers
	service_description	C:\ Drive Space
	check_command		check_nt!USEDDISKSPACE!-l c -w 80 -c 90
	}

define service{
	use			generic-service
	hostgroup_name		windows-servers
	service_description	Uptime
	check_command		check_nt!UPTIME
	}
The original windows.cfg file referenced "windows-server" as the host template to use. I only have the generic-host_nagios2.cfg, so had windows.cfg reference that instead. Could that be the problem, or any other ideas?

Thanks,

~ Tommy

Nagios Output in attachment:
Screen Shot 2014-01-07 at 1.45.06 PM.png
Complete copy of windows.cfg:

Code: Select all

###############################################################################
# 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	winserver	; The name we're giving to this host
#	alias		My Windows Server	; A longer name associated with the host
#	address		192.168.1.2	; IP address of the host
#	}

define host{
	use				generic-host		; Inherit default values from a template
	host_name			off_10.2.1.82_b1
	alias				Office Off-Site Backup 1
	address				10.2.1.82
	hostgroups			windows-servers		; Host groups this host is associated with
	}

###############################################################################
###############################################################################
#
# 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
	hostgroup_name		windows-servers
	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
	hostgroup_name		windows-servers
	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
	hostgroup_name		windows-servers
	service_description	CPU Load
	check_command		check_nt!CPULOAD!-l 5,80,90
	}

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

define service{
	use			generic-service
	hostgroup_name		windows-servers
	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
	hostgroup_name		windows-servers
	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
	hostgroup_name		windows-servers
	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
	hostgroup_name		windows-servers
	service_description	Explorer
	check_command		check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
	}

Re: Windows Check_nt issues

Posted: Tue Jan 07, 2014 5:00 pm
by slansing
How is your check_nt command definition set up? You will certainly need to pass the exact same arguments as you did from the CLI, such as "-v -d and -l":

The following is an example from one of my Nagios servers:

Command:

Code: Select all

$USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
Service:

Code: Select all

check_nt!USEDDISKSPACE!-l C -w 80 -c 95

Re: Windows Check_nt issues

Posted: Tue Jan 07, 2014 5:29 pm
by TmyFrn
My nt.cfg file was different. I modified it slightly and it fixed some of the checks. I'll have to fiddle around now and see whats up with the ones that don't work.

I copied the check_nt command, commented out original copy and modified the copied one as in here.

Code: Select all

# 'check_nt' command definition
#define command {
#        command_name    check_nt
#        command_line    /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -v '$ARG1$'
#}

define command {
	command_name    check_nt
	command_line    /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -v '$ARG1$' '$ARG2$'
}

# 'check_nscp' command definition
define command {
	command_name	check_nscp
	command_line	/usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -v '$ARG1$'
}
It seems the check_nscp command was correct and more like what I wanted, but when I tried to use it, I got errors.
The modification above works for all but the DriveSpace check, still says wrong -l argument.

Thanks,

~ Tommy

Re: Windows Check_nt issues

Posted: Tue Jan 07, 2014 6:01 pm
by lmiltchev
Do you get the "wrong -l argument" when you run the check in the CLI?

Re: Windows Check_nt issues

Posted: Tue Jan 07, 2014 6:38 pm
by TmyFrn
I can run this from CLI:

Code: Select all

/usr/lib/nagios/plugins/check_nt -H 10.2.1.82 -p 12489 -v USEDDISKSPACE -l c
c:\ - total: 59.90 Gb - used: 18.56 Gb (31%) - free 41.34 Gb (69%) | 'c:\ Used Space'=18.56Gb;0.00;0.00;0.00;59.90
This is my service command in windows.cfg:

Code: Select all

define service{
	use			generic-service
	hostgroup_name		windows-servers
	service_description	C:\ Drive Space
	check_command		check_nt!USEDDISKSPACE!-l c
	}
This is what Nagios gives: wrong -l argument

Seems to me it should work, only two ARGS. I would like to add more args for critical and warning levels also.

Re: Windows Check_nt issues

Posted: Tue Jan 07, 2014 7:44 pm
by TmyFrn
Don't know if I resolved this in the proper way, but it is working now.

I changed the service in windows.cfg from:

Code: Select all

define service{
	use			generic-service
	hostgroup_name		windows-servers
	service_description	C:\ Drive Space
	check_command		check_nt!USEDDISKSPACE!-l c -w 80 -c 90
	}
to be:

Code: Select all

define service{
        use                     generic-service
        hostgroup_name          windows-servers
        service_description     C:\ Drive Space XX
        check_command           check_ntc
        }
. . . thus making a new command named check_ntc (c is for drive c).

I then added this command definition to the nt.cfg file:

Code: Select all

define command {
        command_name    check_ntc
        command_line    /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -v USEDDISKSPACE -l c -w 80 -c 90
	}
The main problem I see with this is that I can't check another drive now. I'll keep playing around with it and see what comes.

Maybe it will become clear to me later how to avoid this work around, but until then it works and I'm ok with that.

~ Tommy

Re: Windows Check_nt issues

Posted: Wed Jan 08, 2014 12:59 pm
by lmiltchev
Sounds good. Let us know if you have any more questions/issues.

Re: Windows Check_nt issues

Posted: Wed Jan 08, 2014 1:08 pm
by TmyFrn
Thanks for the quick response on this forum. The first reply set me on the right path to resolve the issue. Much appreciated.

I finally decided to NOT use the windows.cfg method as it required that every host I added to it use all of the checks in it and not all were valid or applied. I ended up making a template file with all check_nt services that I might ever want to use (small list for now) and just make a new .cfg file for each Windows host I want to monitor and use the appropriate checks. I also added a number of commands to the nt.cfg to let me further fine-tune commands.

If anyone has a more efficient method I'd be happy to know.

Thanks all,

~ Tommy

Re: Windows Check_nt issues

Posted: Wed Jan 08, 2014 1:39 pm
by slansing
Templates are generally recommended, it makes managing your systems easier when your environment grows and scales. You can also set up host/service groups to group together hosts and services which are alike.

Re: Windows Check_nt issues

Posted: Sun Jan 11, 2015 10:27 am
by mamartin
I was having the same problem. It seems that check_nt will timeout if the port variable is not supplied. So, I switched all of the checks over to the check_nscp definition. But then the disk space checks started giving me the "wrong -l argument" message, unless I ran it manually.

I used TmyFrn's method of making a new definition, but I modified it so you don't have to make a separate definition for each volume:

The disk check definition in nt.cfg

Code: Select all

# 'check_ntdsk' command definition
define command {
        command_name    check_ntdsk
        command_line    /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -v '$ARG1$' -l '$ARG2$' -w 80 -c 90
}
And the volume checks in windows.cfg

Code: Select all

define service{
        use                             generic-service
        service_description             C:\ Drive Space
        hostgroup_name                  windows-servers
        notification_interval           15
        check_command                   check_ntdsk!USEDDISKSPACE!C
        }

define service{
        use                             generic-service
        service_description             D:\ Drive Space
        hostgroup_name                  windows-servers
        notification_interval           15
        check_command                   check_ntdsk!USEDDISKSPACE!D
        }
And now everything is happy!