check_nt: Could not parse arguments

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
hellheim
Posts: 3
Joined: Mon Jul 16, 2018 12:44 pm

check_nt: Could not parse arguments

Post by hellheim »

Hello,

it is my first time setting up nagios core on ubuntu server 18LTS. for the most part i followed online tutorials and this has helped me a lot. and i was able to do a lot. i wanted to add a windows server 2016 host - this seems a bit trickie.
i have installed nsclient++ on the server.
this is what i get in the nagios screen :

winserver C:\ Drive Space UNKNOWN 07-16-2018 17:58:36 0d 0h 12m 44s 3/3 check_nt: Could not parse arguments
CPU Load UNKNOWN 07-16-2018 17:59:35 0d 0h 11m 45s 3/3 check_nt: Could not parse arguments
Memory UsageUNKNOWN 07-16-2018 18:01:32 0d 0h 11m 21s 3/3 check_nt: Could not parse arguments
en so on .... for others

can someone please help me with this ? what info do you need ?

vim /usr/local/nagios/etc/nagios.cfg:
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_file=/usr/local/nagios/etc/objects/windows.cfg ( windows server 2016 file)


vi /usr/local/nagios/etc/objects/windows.cfg: ( some commands - you get the picture)

Code: Select all

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.174.10            ; IP address of the host
}
define hostgroup {

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

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

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

    use                     generic-service
    host_name               winserver
    service_description     Memory Usage
    check_command           check_nt!MEMUSE!-w 80 -c 90
}

define service {

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

define service {

    use                     generic-service
    host_name               winserver
    service_description     W3SVC
    check_command           check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}

define service {

    use                     generic-service
    host_name               winserver
    service_description     Explorer
    check_command           check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}

vim /usr/local/nagios/etc/objects/commands.cfg ( some commands - you get the picture)

Code: Select all

define command {

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

define command {

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


define command {

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

define command {

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

define command {

    command_name    check_nt
    command_line    $USER1$/check_nt -H 192.168.174.10 -p 12489 -v -s dhpBh6O4Meyc7DFS $ARG1$ $ARG2$
}
when i cd to cd /usr/local/nagios/libexec and execute the following: ./check_nt -H 192.168.174.10 -p 12489 -s dhpBh6O4Meyc7DFS -v CLIENTVERSION
i get: NSClient++ 0.5.2.35 2018-01-28

when i execute :

root@nagios:/usr/local/nagios/libexec# /usr/local/nagios/libexec/check_nt -H 192.168.174.10 -p 12489 -s dhpBh6O4Meyc7DFS -v MEMUSE
Memory usage: total:5502.99 MB - used: 1404.93 MB (26%) - free: 4098.05 MB (74%) | 'Memory usage'=1404.93MB;0.00;0.00;0.00;5502.99

so is this working ??? i don't understand what i'm doing wrong. can some please kindly help me with this perhaps ?
kind regards
Last edited by lmiltchev on Wed Jul 18, 2018 2:33 pm, edited 2 times in total.
Reason: Please use [code][/code] tags around config output
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check_nt: Could not parse arguments

Post by npolovenko »

@hellheim, Glad you made it this far. So here's your service definition:

Code: Select all

define service {

    use                     generic-service
    host_name               winserver
    service_description     Memory Usage
    check_command           check_nt!MEMUSE!-w 80 -c 90
}
And here is the command:

Code: Select all

define command {

    command_name    check_nt
    command_line    $USER1$/check_nt -H 192.168.174.10 -p 12489 -v -s dhpBh6O4Meyc7DFS $ARG1$ $ARG2$
}
! is a divider between $ARGS$. So once this service checks passes through the command it's going to look like this:

Code: Select all

/usr/local/nagios/libexec/check_nt -H 192.168.174.10 -p 12489 -v -s dhpBh6O4Meyc7DFS MEMUSE -w 80 -c 90
So, this worked:

Code: Select all

root@nagios:/usr/local/nagios/libexec# /usr/local/nagios/libexec/check_nt -H 192.168.174.10 -p 12489 -s dhpBh6O4Meyc7DFS -v MEMUSE
Memory usage: total:5502.99 MB - used: 1404.93 MB (26%) - free: 4098.05 MB (74%) | 'Memory usage'=1404.93MB;0.00;0.00;0.00;5502.99
But thry with the arguments:

Code: Select all

/usr/local/nagios/libexec/check_nt -H 192.168.174.10 -p 12489 -v -s dhpBh6O4Meyc7DFS MEMUSE -w 80 -c 90
hellheim
Posts: 3
Joined: Mon Jul 16, 2018 12:44 pm

Re: check_nt: Could not parse arguments

Post by hellheim »

okay, but what do i change in order for the error do go away.
i'm sorry if i son't understand.
where do i change the command ??
because when i change command to this like so :

define service {

use generic-service
host_name winserver
service_description Memory Usage
# check_command check_nt!MEMUSE!-w 80 -c 90
check_command /usr/local/nagios/libexec/check_nt -H 192.168.174.10 -p 12489 -v -s dhpBh6O4Meyc7DFS MEMUSE -w 80 -c 90
}

i get error when restarting nagios service
so this is probably not the way
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: check_nt: Could not parse arguments

Post by lmiltchev »

You need to pass an argument, e.g. MEMUSE, after the "-v"... It is not going to work the way you have your check_nt command defined as of now... Change your command to:

Code: Select all

define command {
    command_name    check_nt
    command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s dhpBh6O4Meyc7DFS -v $ARG1$ $ARG2$
}
Testing from the command line:

Code: Select all

/usr/local/nagios/libexec/check_nt -H 192.168.174.10 -p 12489 -s dhpBh6O4Meyc7DFS -v MEMUSE -w 80 -c 90
$HOSTADDRESS$ will resolve to your winserver IP address
$ARG1$ is 'MEMUSE'
$ARG2$ is '-w 80 -c 90'

With the check_nt configured this way, you should be able to use your existing "Memory Usage" service definition.

Code: Select all

define service {

    use                     generic-service
    host_name               winserver
    service_description     Memory Usage
    check_command           check_nt!MEMUSE!-w 80 -c 90
}
Test your configuration, just in case before restarting nagios:

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios cannot start/restart with config errors. If you see any errors, post them on the forum. Thanks!
Be sure to check out our Knowledgebase for helpful articles and solutions!
hellheim
Posts: 3
Joined: Mon Jul 16, 2018 12:44 pm

Re: check_nt: Could not parse arguments

Post by hellheim »

awesome !
this is working now, thank you so much for this help. thank you for explaining so good to me.
all services a put in are working, i commented some because i don't want to see all.

but i have this :
winserver


C:\ Drive Space

OK 07-18-2018 19:11:52 0d 0h 11m 1s 1/3 c: - total: 50.40 Gb - used: 26.48 Gb (53%) - free 23.92 Gb (47%)

CPU Load

OK 07-18-2018 19:11:40 0d 0h 21m 13s 1/3 CPU Load 1% (5 min average)

Memory Usage

OK 07-18-2018 19:03:38 0d 0h 9m 15s 1/3 Memory usage: total:5502.99 MB - used: 1444.64 MB (26%) - free: 4058.35 MB (74%)

NSClient++ Version

OK 07-18-2018 19:04:36 0d 0h 18m 17s 1/3 NSClient++ 0.5.2.35 2018-01-28

Uptime

OK 07-18-2018 19:05:35 0d 0h 17m 18s 1/3 System Uptime - 0 day(s) 0 hour(s) 19 minute(s)


looking okay to me :)

thank you so much for taking the effort in helping me !
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: check_nt: Could not parse arguments

Post by lmiltchev »

Great! I am glad I could help! :)

I will be locking this topic now. If you have any more questions/issues, please start a new thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked