Monitor several folders size in Windows

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Monitor several folders size in Windows

Post by lpereira »

Hello all:
This is related this post https://support.nagios.com/forum/viewto ... 16&t=45210

i was able to monitor a Windows folder by his size. however i'm unable to figure out how to monitor multiple folders

i have downloaded the script from here:
https://exchange.nagios.org/directory/P ... bs/details

Code: Select all

Set WshShell = WScript.CreateObject("WScript.Shell")
If WScript.Arguments.Length = 0 Then
  Set ObjShell = CreateObject("Shell.Application")
  ObjShell.ShellExecute "wscript.exe" _
    , """" & WScript.ScriptFullName & """ RunAsAdministrator", , "runas", 1
  WScript.Quit
End if

Dim strfolder
Dim intwarning
Dim intcritic
Dim wsh
Dim intvelkost
Dim intjednotka
Dim Perf_Data
'##########################################################'
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wsh = CreateObject("WScript.Shell")
'##########################################################'
If Wscript.Arguments.Count = 3 Then
strfolder = Wscript.Arguments(0)
intwarning = Wscript.Arguments(1)
intcritic = Wscript.Arguments(2)

Set objFolder = objFSO.GetFolder(strfolder)
intjednotka = 1048576 '1MB->bytes'
intvelkost = objFolder.Size/intjednotka
Perf_Data = "|'FolderSize'=" & round (objFolder.Size / 1048576,1) & "MB;"


if (objFolder.Size/1024000) > Cint(intcritic) then 
Wscript.Echo "CRITICAL:" & round (objFolder.Size / 1048576,1) & " MB" & Perf_Data
Wscript.Quit(2)
elseif (objFolder.Size/1048576) > Cint(intwarning) then 
Wscript.Echo "WARNING:" & round (objFolder.Size / 1048576,1) & " MB" & Perf_Data
Wscript.Quit(1)
else
Wscript.Echo "OK:" & round (objFolder.Size /1048576,1) & " MB" & Perf_Data
Wscript.Quit(0)
end if

else
Wscript.Echo "UNKNOWN:"& strfolder &"-" & intwarning & "-" & intcritic
Wscript.Quit(3)
End If

what i did is add the folder path in nsclient.ini
; A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>
[/settings/external scripts/scripts]
check_foldersize=C:\windows\System32\cscript.exe //NoLogo //T:30 "C:\Program Files\nsclient++\scripts\check_folder_size.vbs" "E:\System Volume Information" 8192 5120
i have tried to add a similar line below pointing to the same folder on drive G but i got only one output when i run the command Nagios Side.

can anyone tell me how can i get this working?

thanks
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Monitor several folders size in Windows

Post by cdienger »

Can you attach the similar line that you added as well as the command you're running on the XI side?

It sounds like commands that you're running on XI probably point to the same command in the ini file.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: Monitor several folders size in Windows

Post by lpereira »

cdienger wrote:Can you attach the similar line that you added as well as the command you're running on the XI side?

It sounds like commands that you're running on XI probably point to the same command in the ini file.
what i'm running is

Code: Select all

 ./check_nrpe -H ServerIP -t 30 -c check_foldersize -n
and the return is (for instance)

Code: Select all

CRITICAL:218709.9 MB|'FolderSize'=218709.9MB
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Monitor several folders size in Windows

Post by cdienger »

In that case it will only run one of the definitions in the ini file. You'll want to do something like:

Code: Select all

[/settings/external scripts/scripts]
    check_foldersize=C:\windows\System32\cscript.exe //NoLogo //T:30 "c:\program files\nsclient++\scripts\check_folder_size.vbs" "$ARG1$" 50 78
and then specify the folder when you run the command:

Code: Select all

./check_nrpe -H NSCLIENTIP -c check_foldersize -a "c:\program files\nsclient++"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: Monitor several folders size in Windows

Post by lpereira »

cdienger wrote:In that case it will only run one of the definitions in the ini file. You'll want to do something like:

Code: Select all

[/settings/external scripts/scripts]
    check_foldersize=C:\windows\System32\cscript.exe //NoLogo //T:30 "c:\program files\nsclient++\scripts\check_folder_size.vbs" "$ARG1$" 50 78
and then specify the folder when you run the command:

Code: Select all

./check_nrpe -H NSCLIENTIP -c check_foldersize -a "c:\program files\nsclient++"
i'm getting the following error linux side

Code: Select all

 ./check_nrpe -H SERVERIP -c check_foldersize -a "F:\System Volume Information" -n
Exception processing request: Request contained arguments (not currently allowed, check the allow arguments option).
i did what you recommended on the nsclient file

Code: Select all

[/settings/external scripts/scripts]
check_foldersize=C:\windows\System32\cscript.exe //NoLogo //T:30 "c:\program files\nsclient++\scripts\check_folder_size.vbs" "$ARG1$" 8192 5120
[/settings/external scripts/alias]
check_folder_size.vbs=check_foldersize

User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Monitor several folders size in Windows

Post by cdienger »

make sure the nsclient.ini file contains:

Code: Select all

[/settings/external scripts]
allow arguments = true
allow nasty characters = true
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: Monitor several folders size in Windows

Post by lpereira »

cdienger wrote:make sure the nsclient.ini file contains:

Code: Select all

[/settings/external scripts]
allow arguments = true
allow nasty characters = true
yes the nsclient.ini has those two lines
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Monitor several folders size in Windows

Post by cdienger »

Check the entire file for lines starting with allow arguments and allow nasty characters. You man need to set it in a couple places. Make sure to restart the nsclient service after making any changes.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: Monitor several folders size in Windows

Post by lpereira »

Yes i reviewed them all... in some options is set to "0", i changed them to "1" and i got the following msj

Code: Select all

[root@Nagios XI libexec]# ./check_nrpe -H IP SERVER -c check_foldersize -a "C:\System Volume Information" -n
Exception processing request: Request contained arguments (not currently allowed, check the allow arguments option).
So, i assume 0 is correct
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Monitor several folders size in Windows

Post by scottwilkerson »

you want these to be set to true

Code: Select all

allow arguments = true
Once they all are, you need to restart the NSClient{++ service.

If this still doesn't work, can you attach the nsclient.ini from this windows machine so we can take a look?

Thanks.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked