check_nt!SERVICESTATE

Hi

I am trying to monitor some services on a windows 2003 server but they are not standard windows services. i can’t seem to find any documentation on the check_nt!SERVICESTATE command which will actually help me to figure out what i need to use as their service names!!

I have read the commands.cfg which reads:-

‘check_nt’ command definition

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

not very helpful, i read the online documentation which isn’t much help either :frowning:

Can someone please point me towards some good documentation for the check_nt command?

i have the latest nagios r3, the latest plugins and the suggested “NSClient” (latest version) if it helps.

Thanks in advance
richard

have you tried to execute :
“nagios-dir/libexec/check_nt --help” ?

yes, but it says:-

nagios@uk-lds-nag-01:/usr/local/nagios/libexec> ls -l check_nt
-rwxr-xr-x 1 nagios nagios 76981 2008-02-26 14:26 check_nt
nagios@uk-lds-nag-01:/usr/local/nagios/libexec> check_nt --help
-bash: check_nt: command not found

i am logged in as the nagios user by the way but i get the same if I su to root and try again :frowning:

Heh. This should provide you with a list of all active services running on that server, from which you can infer what your services are calling themselves, for use with the -l parameter when you set up your service checks.

./check_nt -H -p 12489 -v SERVICESTATE -d SHOWALL

HTH

/S

edit: try “./check_nt --help” i.e.

[root@localhost libexec]# check_nt --help
-bash: check_nt: command not found
[root@localhost libexec]# ./check_nt --help
check_nt v1590 (nagios-plugins 1.4.11)
Copyright (c) 2000 Yves Rubin ([email protected])
Copyright (c) 2003-2006 Nagios Plugin De...
...

hmm, running that in a SSH session gives me an error:-

uk-lds-nag-01:/usr/local/nagios/libexec # ./check_nt -H 172.16.1.22 -p 12489 -v SERVICESTATE -d SHOWALL
No service/process specified

HOWEVER, on a side note, if i use the command
**./**check_nt --help

I now get the helpfile :wink:

edit:
I added the SHOWALL to a new definition thusly and received the same “No service/process specified” message. I added a ! to the end of the check_command to no avail.

The helpfile states:-
**

SERVICESTATE =
, Check the state of one or several services.
Request a -l parameters with the following syntax:
-l ,,,…
You can specify -d SHOWALL in case you want to see working services
in the returned string.

**

hmm, I guess I misunderstood the meaning of -d SHOWALL
I took it to mean it would return all services, but I guess it doesn’t. Perhaps it means it returns the name of those services that it was asked to check in the -l parameter, ratehr than just the ‘OK’ (i guess if you check several services at once this would make sense). Anyway, not really of any help in this case.

I think as far as working out what services are called, it’ll be a manual process of opening up ‘services’ on your taget server and right-clicking to get the properties. You should see the service name at the top of the general tab.

HTH

/S

Hmm, I type this name from one of my services and it says it’s not running lol (even though it is!)

Do I need to check “allow service to interact with desktop” as I did with the NSClient service?

I wouldn’t have thought so. Did you run the command from the command line? can you post the command used and the output?

login as: root
Using keyboard-interactive authentication.
Password:
Last login: Thu Feb 28 11:44:41 2008 from 192.168.100.98
Have a lot of fun...
uk-lds-nag-01:~ # cd /usr/local/nagios/libexec/
uk-lds-nag-01:/usr/local/nagios/libexec # ./check_nt -H 172.16.1.22 -v SERVICESTATE -l MPLHostedCommsServer -d SHOWALL                    Connection refused
could not fetch information from server
uk-lds-nag-01:/usr/local/nagios/libexec #

oh and just before you/anyone asks, it CAN see the machine as i get reports on UPTIME, C: drive space and so on just fine!

EDIT:-
Here is a screenshot:-
%between%http://img259.imageshack.us/img259/9827/40262018bv4.th.jpg

It can’t connect… try changing the port. Add:

-p 12489

[Edit: assuming it’s runnign on that port, otherwise whatever you have chosen. The nagios checks work because nagios runs the check_nt command as already configered in command.cfg, which will include the -p parameter, but as you are running it from the command line it needs to be added there in order for it to connect]

if that doesn’t yeild anything useful the only thing I can suggest is seeing whether the nsclient module on your target server can actually see the service running. have a look at trac.nakednuns.org/nscp/wiki/CheckServiceState
which gives some example on how to test nsclient++ from the command line on your windows server. It may be that nsclient++ can’t see the service, and if that;s the case then no amount of fiddling with check_nt on your nagios box is ever going to help.

hey strides, thanks for the suggestions; as this is a network at work and i am now at home, i can’t check again until tomorrow but i wanted to say thank you for your help with this; regardless of if it ultimately works or not, at least you have given me some great help and lots of food for thought!

I think that these services should be recognised as we have another environment which is monitored by another nagois server - thing is, this is a 3rd party company and we’re paying them boat loads of cash each month. the idea is for us to move it in-house and save

Hi there

You’re too kind !shy

I can’t imagine how they’ve managed to get it working, but it really shouldn’t be this hard !! I had a bit of a deeper think over a large brandy and it occured that there are a couple things to try but whether or not anything will come of it who knows. First, it might be worth running “sc query” from a command prompt on your windows server to see if there is anything spurios or obviously different about the service name. Sadly, “sc” doesn’t have much to offer in the way of other information, but luckily there is a handy tool available from microsoft (now anyway, used to be sysinternals) called “psservice” which is part of the pstools suite of ‘groovy stuff’. If you can grab that (less than a meg) and unzip it, give "psservice security " a shot. That’ll show you a useful view of which accounts can do things like query the status of the service - you’d want to hope that the account you have nsclient++ running under (local system?) would have that privelege! :smiley:

As I say, whether or not either of those will reveal anything useful is anyones guess, but, one hopes that at least either one or both of "psservice query " or "sc query " will be able to see and reveal “STATE : 4 RUNNING” for your service, and if so, this is ultimately good news. That means if push comes to shove you can at least slap something like Perl on your windows server and write a little script to run that command and capture the STATE from the output. Then use something like NRPE to call the script from your nagios server to check the status of the service - job done! OK, it’s a cludge, but if it works and saves you money in the long run, happy days :slight_smile: Who knows… have a look-see if NRPE is already installed… perhaps that’s how they are doing it!

Any road up, time for another large brandy. Keep us posted on your progress!

Ta

/S
PS Get psservice here

Good morning
Ok, I have downloaded the PS kit from the link (thanks again!) and here is the output:-

%between%http://img184.imageshack.us/img184/6076/psservicebz2.th.jpg
As you can see, NT AUTHORITY\SYSTEM has “Query status” permission; NSClient is running under “Local System Account” so it should be able to query it OK.

I also re-ran the ./check_nt from the terminal of the nagios machine (but included the port this time lol!) and :-

**uk-lds-nag-01:/usr/local/nagios/libexec # ./check_nt -H 172.16.1.22 -p 12489 -v SERVICESTATE -l MPLHostedCommsServer -d SHOWALL
MPLHostedCommsServer: Started
uk-lds-nag-01:/usr/local/nagios/libexec #
**

So it CAN query it, it must be “user error” hahaha, so back into the .cfg file for checks etc and I’ll report back once done :slight_smile:

regards

Well, it sure WAS user-error by the looks; my Nagios screen now shows (excuse the formatting here btw, can’t be bothered with MORE screenshots lol)

3mplanet-com01

MPLHostedCommsServer

OK 	02-29-2008 09:50:48 	0d 0h 0m 34s 	1/3 	MPLHostedCommsServer: Started 

The service definition had a total noob error; spot the difference and guess which worked lol:-

check_nt!PROCSTATE!-l MPLHostedCommsServer -d SHOWALL

check_nt!SERVICESTATE!-l MPLHostedCommsServer -d SHOWALL

*kicks himself until black and blue (then asks his boss if he can go home lol).

Well, at least this has educated me a little more in the mysterious ways of Nagios. I really can not thank you enough for your replies passes large bottle of brandy to strides

Cheers!

heh, always the way… I’ll put a quid on option 2 saving the day. :slight_smile:

Glad your up and running chap, it’s been fun

Cheers

/S
(hung over) :evil:

hi,

i have the same issue as you and i found it on a site cant remeber which one it was but you could find all the services that you need by looking at the registery
You can find this information when going to the registry for the corresponding service : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
from there u can look at the info and monitor which service u required
e.g. check_command check_nt!SERVICESTATE!-d SHOWALL -l “Terminal Services”

One can also run “sc query” on the Windows machine to get a list of services and their names…