Monitoring a Windows Directory Config Issue
Monitoring a Windows Directory Config Issue
Hi, I'm new to the GUI style NAGIOS XI configuration and I'm stuggling to implement a simple task of monitoring a number of Windows file directories. Basically if there is a file in a specified directory, it means there's a problem so I'd like it to be monitored and alerting for this purpose.
I have tried to set-up the plug-in named "count_file.pl" (attached) as follows (Test Subject):
Command:
Command = count_file
Command line = $USER1$/count_file.pl -H $HOSTADDRESS$ $ARG1$ $ARG2$
Command type = Unclassified
Service:
Command View = $USER1$/count_file.pl -H $HOSTADDRESS$ $ARG1$ $ARG2$
$ARG1$ = D:\Temp
$ARG2$ = 0 0
Aditional Templates = Generic Service
The Hostname, Host group and Service Group have all been specified using the GUI. Can anybody tell me if the above syntax seems correct? I can't seem to get a correct repsonse from the Service so I'm presuming not.
Many thanks
Dan
I have tried to set-up the plug-in named "count_file.pl" (attached) as follows (Test Subject):
Command:
Command = count_file
Command line = $USER1$/count_file.pl -H $HOSTADDRESS$ $ARG1$ $ARG2$
Command type = Unclassified
Service:
Command View = $USER1$/count_file.pl -H $HOSTADDRESS$ $ARG1$ $ARG2$
$ARG1$ = D:\Temp
$ARG2$ = 0 0
Aditional Templates = Generic Service
The Hostname, Host group and Service Group have all been specified using the GUI. Can anybody tell me if the above syntax seems correct? I can't seem to get a correct repsonse from the Service so I'm presuming not.
Many thanks
Dan
You do not have the required permissions to view the files attached to this post.
Last edited by dbsaust on Sun Oct 30, 2011 7:18 pm, edited 2 times in total.
Re: Monitoring a Windows Directory Config Issue
Can you try testing this plugin and your defined arguments from the command-line? What kind of output is it giving?
http://support.nagios.com/wiki/index.ph ... k_Commands
http://support.nagios.com/wiki/index.ph ... k_Commands
Re: Monitoring a Windows Directory Config Issue
db,
Is the D:\Temp wrapped in single quotes? It MUST be wrapped in single quotes otherwise the backslash will try to escape the :.
Secondly, are you using this plugin to monitor a remote directory on a Windows machine? If so you'll probably need to be using NSClient++ or some other client if you aren't doing so already.
Is the D:\Temp wrapped in single quotes? It MUST be wrapped in single quotes otherwise the backslash will try to escape the :.
Secondly, are you using this plugin to monitor a remote directory on a Windows machine? If so you'll probably need to be using NSClient++ or some other client if you aren't doing so already.
Nicholas Scott
Former Nagios employee
Former Nagios employee
Re: Monitoring a Windows Directory Config Issue
Thanks both for your replies.
In order to help my understanding I've tried to go back to basics from the command as mentioned. I would run the perl script locally as follows:
/usr/local/nagios/libexec/count_file.pl /etc 0 0
Critical: Filecount of '/etc' too large 244 > 0.
So to expand on this, I ran the same command locally as specified via the "problems with check commands link":
su -c '/usr/local/nagios/libexec/count_file.pl /etc 0 0' nagios
Critical: Filecount of '/etc' too large 244 > 0.
If I throw the local hostname in I think this is where I'm getting the problems with my syntax:
(Unquoted filepath)
su -c '/usr/local/nagios/libexec/count_file.pl -H localhost /etc 0 0' nagios
Usage: "Filename" "Critical number of files" "Warning number of files"
examples: /usr/local/nagios/libexec/count_file.pl <dir> 1 10
examples: /usr/local/nagios/libexec/count_file.pl <dir> 3:10 1:3
(Single quoted filepath as would be required for the Windows D:\ drive)
su -c '/usr/local/nagios/libexec/count_file.pl -H localhost '/etc' 0 0' nagios
Usage: "Filename" "Critical number of files" "Warning number of files"
examples: /usr/local/nagios/libexec/count_file.pl <dir> 1 10
examples: /usr/local/nagios/libexec/count_file.pl <dir> 3:10 1:3
Can you guys please help me on how to determine a hostname (locally or externally) and get this to run as I wish?
Many thanks in advance
DB
In order to help my understanding I've tried to go back to basics from the command as mentioned. I would run the perl script locally as follows:
/usr/local/nagios/libexec/count_file.pl /etc 0 0
Critical: Filecount of '/etc' too large 244 > 0.
So to expand on this, I ran the same command locally as specified via the "problems with check commands link":
su -c '/usr/local/nagios/libexec/count_file.pl /etc 0 0' nagios
Critical: Filecount of '/etc' too large 244 > 0.
If I throw the local hostname in I think this is where I'm getting the problems with my syntax:
(Unquoted filepath)
su -c '/usr/local/nagios/libexec/count_file.pl -H localhost /etc 0 0' nagios
Usage: "Filename" "Critical number of files" "Warning number of files"
examples: /usr/local/nagios/libexec/count_file.pl <dir> 1 10
examples: /usr/local/nagios/libexec/count_file.pl <dir> 3:10 1:3
(Single quoted filepath as would be required for the Windows D:\ drive)
su -c '/usr/local/nagios/libexec/count_file.pl -H localhost '/etc' 0 0' nagios
Usage: "Filename" "Critical number of files" "Warning number of files"
examples: /usr/local/nagios/libexec/count_file.pl <dir> 1 10
examples: /usr/local/nagios/libexec/count_file.pl <dir> 3:10 1:3
Can you guys please help me on how to determine a hostname (locally or externally) and get this to run as I wish?
Many thanks in advance
DB
Re: Monitoring a Windows Directory Config Issue
Nicholas, to confirm, I do have the NSClient++ installed on the Windows server. However I think the problem I've hit is before I even get to the point of connecting to the Windows server?
Many thanks
Many thanks
Re: Monitoring a Windows Directory Config Issue
DB,
Keep in mind that if you're going to run that perl script, the actual perl script itself has to reside on the server that it will be running. NSClient.org has a good reference for this:
http://nsclient.org/nscp/wiki/doc/usage/nagios/nrpe
As you can see, the Nagios XI server simply runs the check_nrpe plugin, which attempts to connect to the remote windows box, where the NRPE/NSClient++ application hears the Nagios XI request, runs the given arguments and returns the status of the whatever the Nagios XI server wanted the NRPE/NSClient++ application to run.
Also, watch the quotes,
Opens and closes the single quotes a couple times so it interprets this as this:
string: '/usr/local/nagios/libexec/count_file.pl -H localhost'
then the command: /etc
then the string: ' 0 0'
then the command: nagios
Keep in mind that if you're going to run that perl script, the actual perl script itself has to reside on the server that it will be running. NSClient.org has a good reference for this:
http://nsclient.org/nscp/wiki/doc/usage/nagios/nrpe
As you can see, the Nagios XI server simply runs the check_nrpe plugin, which attempts to connect to the remote windows box, where the NRPE/NSClient++ application hears the Nagios XI request, runs the given arguments and returns the status of the whatever the Nagios XI server wanted the NRPE/NSClient++ application to run.
Also, watch the quotes,
Code: Select all
'/usr/local/nagios/libexec/count_file.pl -H localhost '/etc' 0 0' nagiosstring: '/usr/local/nagios/libexec/count_file.pl -H localhost'
then the command: /etc
then the string: ' 0 0'
then the command: nagios
Nicholas Scott
Former Nagios employee
Former Nagios employee
Re: Monitoring a Windows Directory Config Issue
Hi Nicholas,
I also provided a single quoted version of the command I was trying to run locally on the nagios server (just to test in a basic form) but no luck with this either:
I.e. su -c '/usr/local/nagios/libexec/count_file.pl -H localhost /etc 0 0' nagios
The error response I get is:
Usage: "Filename" "Critical number of files" "Warning number of files"
examples: /usr/local/nagios/libexec/count_file.pl <dir> 1 10
examples: /usr/local/nagios/libexec/count_file.pl <dir> 3:10 1:3
I have installed the plugin on the remote server and it works fine from a windows cmd prompt. But I'm still not sure of the correct syntax to get this to run from the Nagios server itself. As the above doens't work for me due to a syntax issue, can you please explain how would I best place the quotations for a Windows server check given the following example:
Remote server script is located here:
c:\documents and settings\sqladmin\desktop\count_file.pl
Hostname is:
auitsupport01
Directory I wish to monitor is:
c:\documents and settings\sqladmin\desktop\test
Critical and Warning alerts is for 1 file or more so:
0 0
I would expect to use the following but it doesn't like this:
su -c 'c:\documents and settings\sqladmin\desktop\count_file.pl -H auitsupport01 c:\documents and settings\sqladmin\desktop\test 0 0' nagios
Or to run the script from the Nagios server but have it replicate to the terminal server:
su -c '/usr/local/nagios/libexec/count_file.pl -H auitsupport01 c:\documents and settings\sqladmin\desktop\test 0 0' nagios
Can you please advise me how I can arrange this command to get it to work on the remote server? Atleast so that I don't interupt the command half way through when specifying variables?
Many thanks
DB
I also provided a single quoted version of the command I was trying to run locally on the nagios server (just to test in a basic form) but no luck with this either:
I.e. su -c '/usr/local/nagios/libexec/count_file.pl -H localhost /etc 0 0' nagios
The error response I get is:
Usage: "Filename" "Critical number of files" "Warning number of files"
examples: /usr/local/nagios/libexec/count_file.pl <dir> 1 10
examples: /usr/local/nagios/libexec/count_file.pl <dir> 3:10 1:3
I have installed the plugin on the remote server and it works fine from a windows cmd prompt. But I'm still not sure of the correct syntax to get this to run from the Nagios server itself. As the above doens't work for me due to a syntax issue, can you please explain how would I best place the quotations for a Windows server check given the following example:
Remote server script is located here:
c:\documents and settings\sqladmin\desktop\count_file.pl
Hostname is:
auitsupport01
Directory I wish to monitor is:
c:\documents and settings\sqladmin\desktop\test
Critical and Warning alerts is for 1 file or more so:
0 0
I would expect to use the following but it doesn't like this:
su -c 'c:\documents and settings\sqladmin\desktop\count_file.pl -H auitsupport01 c:\documents and settings\sqladmin\desktop\test 0 0' nagios
Or to run the script from the Nagios server but have it replicate to the terminal server:
su -c '/usr/local/nagios/libexec/count_file.pl -H auitsupport01 c:\documents and settings\sqladmin\desktop\test 0 0' nagios
Can you please advise me how I can arrange this command to get it to work on the remote server? Atleast so that I don't interupt the command half way through when specifying variables?
Many thanks
DB
Re: Monitoring a Windows Directory Config Issue
dbsaust,
The reason
doesn't work is because it has no idea what -H is. Try running this on your local nagios machine:
No quotes there, if you're going to run it using su I suppose you could do it this way:
Now notice in this plugin you cannot specify which host to run it on. You have to use check_nrpe with NSClient++. I strong suggest you read the following link in order to get the most control out of your monitoring soluation:
http://nsclient.org/nscp/wiki/doc/usage/nagios/nrpe
The reason
Code: Select all
su -c '/usr/local/nagios/libexec/count_file.pl -H localhost /etc 0 0' nagiosCode: Select all
/usr/local/nagios/libexec/count_file.pl /tmp 5 10Code: Select all
su -c '/usr/local/nagios/libexec/count_file.pl /tmp 5 10'http://nsclient.org/nscp/wiki/doc/usage/nagios/nrpe
Nicholas Scott
Former Nagios employee
Former Nagios employee
Re: Monitoring a Windows Directory Config Issue
Hi Nicholas,
I'm getting much closer now, I managed to work out the correct command to run from the command line on the Nagios box (error in red);
[root@aunagiosxi libexec]# ./check_nrpe -H 10.215.222.104 -c count_file.pl -a c:\documents and settings\sqladmin\desktop\test 0 0
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
I looked into the dll file on the client machine to allow arguments and nasty meta chars as that was the first error I received, then after another go the ns++ client log gives me the following:
2011-10-21 17:53:00: message:NSClient++.cpp
No handler for command: 'count_file.pl'
2011-10-21 17:53:00: message:include\NSCHelper.cpp:238: No handler for command 'count_file.pl'.
I've read through the supporting link you attached but I'm not quite sure what to do at this junction, can you please advise where to read or what to check out for next?
Many thanks
DB
I'm getting much closer now, I managed to work out the correct command to run from the command line on the Nagios box (error in red);
[root@aunagiosxi libexec]# ./check_nrpe -H 10.215.222.104 -c count_file.pl -a c:\documents and settings\sqladmin\desktop\test 0 0
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
I looked into the dll file on the client machine to allow arguments and nasty meta chars as that was the first error I received, then after another go the ns++ client log gives me the following:
2011-10-21 17:53:00: message:NSClient++.cpp
2011-10-21 17:53:00: message:include\NSCHelper.cpp:238: No handler for command 'count_file.pl'.
I've read through the supporting link you attached but I'm not quite sure what to do at this junction, can you please advise where to read or what to check out for next?
Many thanks
DB
Re: Monitoring a Windows Directory Config Issue
I am not sure if this will help but you can try editing your nsc.ini file this way:
1. Under the "[External Script]" section, uncomment this line:
and edit it accordingly. I believe you may have to uncomment also ";CheckExternalScripts.dll".
2. Restart nsclient++
Try your command again and see if they will work. If they don't, try editing also the "[NRPE]" section -> "# SCRIPT DIRECTORY". Uncomment this line:
and edit it accordingly. Restart nsclient++ and try your commands.
1. Under the "[External Script]" section, uncomment this line:
Code: Select all
;script_dir=c:\my\script\dir2. Restart nsclient++
Try your command again and see if they will work. If they don't, try editing also the "[NRPE]" section -> "# SCRIPT DIRECTORY". Uncomment this line:
Code: Select all
;script_dir=scripts\Be sure to check out our Knowledgebase for helpful articles and solutions!