Page 1 of 1

Monitoring Windows server using check_nt

Posted: Wed Aug 19, 2015 8:19 am
by sushant4tech
Hi All,

I am monitoring a remote windows (windows server 2007) host. After installing NSClient++ on target host and setting up firewall i did manual checks which returned successful results. Please check the code below

Code: Select all

ubuntu@ip-172-30-1-33:/etc/nagios3/conf.d$ /usr/lib/nagios/plugins/check_nt -p 12489 -H 10.2.1.82 -v CPULOAD -l 5,80,90
CPU Load 6% (5 min average) |   '5 min avg Load'=6%;80;90;0;100
ubuntu@ip-172-30-1-33:/etc/nagios3/conf.d$ /usr/lib/nagios/plugins/check_nt -H 10.2.1.82 -p 12489 -v USEDDISKSPACE -d SHOWALL -l c
c:\ - total: 49.66 Gb - used: 23.78 Gb (48%) - free 25.87 Gb (52%) | 'c:\ Used Space'=23.78Gb;0.00;0.00;0.00;49.66
ubuntu@ip-172-30-1-33:/etc/nagios3/conf.d$ /usr/lib/nagios/plugins/check_nt -p 12489 -H 10.2.1.82 -v MEMUSE
Memory usage: total:12287.71 Mb - used: 2828.89 Mb (23%) - free: 9458.83 Mb (77%) | 'Memory usage'=2828.89Mb;0.00;0.00;0.00;12287.71
Since the test results were successful i added the code to service defs.

Code: Select all

define service{
                use             generic-service
                host_name       traffline_misc
                service_description     Disk Space
                check_command           check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
define service{
                use             generic-service
                host_name       traffline_misc
                service_description     Current Load
                check_command           check_nt!CPULOAD!-l 5,80,90
}
define service{
                use             generic-service
                host_name       traffline_misc
                service_description     Memory
                check_command           check_nt!MEMUSE!-l -w 80 -c 9
Since the manual test were fine, i was expecting no trouble but following were the results shown in CGI
Service Status Status Information
Current Load UNKNOWN missing -l parameters 
Disk Space UNKNOWN missing -l parameters 
Memory CRITICAL CRITICAL - Socket timeout after 10 seconds 

Re: Monitoring Windows server using check_nt

Posted: Wed Aug 19, 2015 2:33 pm
by jdalrymple
Impossible to troubleshoot completely without seeing your command definition, but I could take a blind stab... replace your 2nd ! with a space.

If that doesn't work - post your check_nt command def and we'll debug it for you.

Re: Monitoring Windows server using check_nt

Posted: Thu Aug 20, 2015 2:54 am
by sushant4tech
jdalrymple wrote:replace your 2nd ! with a space.
This didnt work out, i just got the error "check_nt: Could not parse arguments"
jdalrymple wrote:If that doesn't work - post your check_nt command def and we'll debug it for you.
However your suggestion about the check_nt definition was really helpfull as i forgot to check the command def earlier.

So i checked the check_nt def and found that it was defined as

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$'
}
i changed this to

Code: Select all

# 'cehck_nt' modified command definition
define command{
		command_name	check_nt
		command_line /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -v '$ARG1$' '$ARG2$'
}
It works perfectly now... Thank you...
2 out 3 services now work fine with following def

Code: Select all

define service{
		use			generic-service
		host_name		traffline_misc
		service_description	Current Load
		check_command		check_nt!CPULOAD!-l 5,80,90
}
define service{
		use			generic-service
		host_name		traffline_misc
		service_description	Memory
		check_command		check_nt!MEMUSE!-w 80 -c 90
}
However i now receive error "wrong -l argument" for Disk Space service. the definition of this service is as in the code below.

Code: Select all

define service{
                use                     generic-service
                host_name               traffline_misc
                service_description     Disk Space
                check_command           check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
Can you let me know why is it so?

Re: Monitoring Windows server using check_nt

Posted: Thu Aug 20, 2015 12:29 pm
by tgriep
Edit the check_nt command from this

Code: Select all

      command_name   check_nt
      command_line /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -v '$ARG1$' '$ARG2$'
to this

Code: Select all

      command_name   check_nt
      command_line /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -v '$ARG1$' $ARG2$
I think the single quotes around $ARG2$ are causing the issue.

Re: Monitoring Windows server using check_nt

Posted: Fri Aug 21, 2015 2:38 am
by sushant4tech
thanks, removing single quotes for the second argument $ARG2$ worked like charm.
What difference did it make actually is still beyond me. can you shed some light on it...

Re: Monitoring Windows server using check_nt

Posted: Fri Aug 21, 2015 2:08 pm
by jdalrymple
It's a shell expansion thing.

Just like the difference between:

Code: Select all

[root@localhost jdalrymple]# printf some stuff\n
some[root@localhost jdalrymple]# printf "some stuff\n"
some stuff