Check_Winfile Plugin

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
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Check_Winfile Plugin

Post by kwhogster »

Nagios Core 4 on Ubuntu 16.04
Setting up NRPE check for winfile plugin get this

Check Windows Temp Folder Notifications for this service have been disabled UNKNOWN 07-23-2017 18:09:00 0d 0h 23m 14s 3/3 Incorrect command line arguments supplied

In my NSCLIENT.ini

Code: Select all

; A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>
[/settings/external scripts/scripts]

; Check Windows Temp Folder 
check_winfile = scripts\\check_winfile.exe $ARG1$ $ARG2$ $ARG3$


I placed the check_winfile.exe in the folder c:\program files\nsclient++\scripts folder
After I updated the nsclient.ini file saved it and then restarted the nsclient service.

On the Nagios server

In my Commands.cfg file added this command

Code: Select all

define command{
        command_name    check_winfile
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -t 120 -c check_winfile --target c:\windows\temp --filter "size gt 1073741824" -delete
}
I then defined a service on the server I am testing

Code: Select all

define service {
        host_name               SERVER1
        service_description     Check Windows Temp Folder
        check_command           check_nrpe!check_winfile
        servicegroups           Windows Temp
        check_interval          1
        check_period            backup_WIN08P
        notification_period     backup_WIN08P
        use                     generic-service
        }
When I run it from the console I get this

root@serv17:/usr/lib/nagios/plugins# ./check_nrpe -H 10.2.8.33 -t 120 -c check_winfile -a --target c:\windows\temp --filter "size gt 10737411824" --delete
./check_nrpe: unrecognized option '--filter'
./check_nrpe: unrecognized option '--delete'


FRom the server I ran the command from a dos prompt

C:\Program Files\NSClient++\scripts>check_winfile --target c:\windows\temp --filter "size gt 1073741824" -delete
Can't opendir(c:\windows\temp/vmware-SYSTEM): Invalid argument
at check_winfile.pl line 81
FILE OK - 0 files out of 16 to consider |'selected files'=0;;; 'all files'=16 'deleted files'=0


Any ideas

Thanks

Tom
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Check_Winfile Plugin

Post by kwhogster »

Update

From the console I had to place single quote around the arguments

root@tgcs017:/usr/lib/nagios/plugins# ./check_nrpe -H 10.2.8.69 -t 120 -c check_winfile -a '--target c:\windows\temp --filter "size gt 10737411824" --delete'
Request contained illegal characters set /settings/external scripts/allow nasty characters=true!|


But that is what I get
Now pointing to the nsclient.ini

Thanks
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Check_Winfile Plugin

Post by kwhogster »

This can be locked I fixed it.

In nclient.ini

; Section for external scripts configuration options (CheckExternalScripts).
[/settings/external scripts]

; COMMAND ALLOW NASTY META CHARS - This option determines whether or not the we will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
; allow nasty characters = 0
allow nasty characters = 1

changed allow nasty characters = 0 to allow nasty characters = 1 (true)

In the command.cfg had to add quotes around arguments
looks like this now

define command{
command_name check_winfile
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 120 -c check_winfile '--target c:\windows\temp --filter "size gt 1073741824" -delete'
}



Please LOCK this as resolved
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: Check_Winfile Plugin

Post by tacolover101 »

i'm glad you solved this. the allow nasty solution works, however i'd like to shed light as to why this actually happened.

you were passing this -

Code: Select all

command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -t 120 -c check_winfile --target c:\windows\temp --filter "size gt 1073741824" -delete
since your arguments weren't encapsulated with ' or ", it will only take the 3 arguments you initially specified -

Code: Select all

check_winfile = scripts\\check_winfile.exe $ARG1$ $ARG2$ $ARG3$
cheers
bolson

Re: Check_Winfile Plugin

Post by bolson »

Closing topic as resolved.

Thank you for using the Nagios Support Forum.
Locked