Ad Widget

Collapse

monitoring large windows folders

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aperezl
    Junior Member
    • Oct 2012
    • 7

    #1

    monitoring large windows folders

    Hello,

    Im interested in monitoring the size of certain windows folders. The problem Im facing woth with is when I click "properties", it tooks about 20-30mins to windows to show the total size.

    The folder is not specially large (~70G), but has many levels of folders, about 20....

    I've tried to create some userparameter config in the zabbix_agent.conf, pointing to batch, vbs, wmi ... utilities like "du for windows" ... but all of them take about 30 mins to complete, so zabbix server receives a timeout at 30s.

    How can I achieve this?

    thanks
  • mmarkwitzz
    Senior Member
    • Jan 2011
    • 106

    #2
    My solution to dodge the timeout is to create a script that executes itself again like this:

    1) zabbix executes script.vbs.
    2) script.vbs tries to read the folder size from a log file (explained below).
    3) script.vbs executes itself again using wmiprvse, overcoming the ability of zabbix to kill the script and all it's spawned child processes on timeout. We'll call this instance OOP script.vbs.
    4) script.vbs exits.
    5) OOP script.vbs reads the size of the folder by whatever means you like (objFSo.GetFolder(x).Size) and saves the size in a log file.
    ...
    5) zabbix executes script.vbs
    6) script.vbs tries to read the folder size from a log file, which should exist now as OOP script.vbs saved it to the log file.
    7) go to 3)


    Make sure you set the interval of the item large enough (1h or more) as to let an instance of OOP script.vbs finish the job.

    Code:
    Dim objFSO, objShell, strResult
    Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("WScript.Shell") 
    Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") 
    strCurPath = objFSO.GetParentFolderName(WScript.ScriptFullName)
    
    
    
    
    
    'CHECK OUT OF PROCESS
    Function CheckOutOfProcess
    	'OOP MARKER
    	If (WScript.Arguments.Count > 0) Then strMarker = WScript.Arguments(0)
    	
    	'SCRIPT WAS LAUNCHED OOP	
    	If (StrComp(strMarker, "$", 1) = 0) Then	
    		'MESSAGE
    		Call WScript.Echo("Started oop...")
    
                    '***********
                    Call SaveSizeOfFolderToLogFile(WScript.Arguments(1))
    		
    		'QUIT
    		Call WScript.Quit
    	End If	
    End Function
    
    
    'LAUNCH OUT OF PROCESS
    Function LaunchOutOfProcess
    	'RESULT
    	LaunchOutOfProcess = False
    
    	'MARKER
    	strArguments = "$"
    
    	'ARGUMENT STRING
    	For x = 0 To WScript.Arguments.Count - 1
    		strArguments = strArguments & " " & Chr(34) & WScript.Arguments(x) & Chr(34)
    	Next
    
    	strExe = Chr(34) & "cscript.exe" & Chr(34) & " //nologo"
    	strExeArguments = Chr(34) & strCurPath & "\" & "zabbix_vbs_logger.vbs" & Chr(34) & " " & Chr(34) & 
    
    WScript.ScriptFullName & Chr(34) & " " & strArguments & " " & Chr(34) & strCurPath & "\" & objFSO.GetBaseName
    
    (WScript.ScriptName) & ".log" & Chr(34)
    
    	Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Pkt,(Shutdown)}!\\.
    
    \root\cimv2")
    
    	'CONFIGURE STARTUP INFO
    	Set objStartup = objWMIService.Get("Win32_ProcessStartup")
    	Set objConfig = objStartup.SpawnInstance_
    	objConfig.ShowWindow = 1
    
    	Err.Clear
    
    	'CREATE PROCESS VIA WMI WIN32_PROCESS.CREATE TO CIRCUMVENT THE ZABBIX MECHANISM FOR 
    	'KILLING THE PROCESS AND ALL CHILDREN AFTER THE TIMEOUT OCCURS
    	Set objProcess = objWMIService.Get("Win32_Process")
    	nResult = objProcess.Create(strExe & " " & strExeArguments, strCurPath, objConfig, intProcessID)
    	
    	'RESULT
    	If (nResult = 0) Then LaunchOutOfProcess = True
    End Function
    
    
    
    Function ReadSizeOfFolderFromLogFile
    	ReadSizeOfFolderFromLogFile = "ReadSizeOfFolderFromLogFile"
    
            '*************
            'replace this function with your code to read the size from the log file
    End Function
    
    function SaveSizeOfFolderToLogFile(strFolder)
    	WScript.Echo("SaveSizeOfFolderToLogFile" & ":" & strFolder)
    
            '*************
            'replace this function with your code to read the size of the folder and save it to the log file
    End Function
    
    
    
    'CHECK OUT OF PROCESS
    Call CheckOutOfProcess
    
    'LAUNCH OUT OF PROCESS
    Call LaunchOutOfProcess
    
    '***************
    strResult = ReadSizeOfFolderFromLogFile
    WScript.Echo strResult
    Just replace the ReadSizeOfFolderFromLogFile and SaveSizeOfFolderToLogFile functions
    Last edited by mmarkwitzz; 26-10-2012, 18:31.

    Comment

    • aperezl
      Junior Member
      • Oct 2012
      • 7

      #3
      Wow,
      This is far more than expected. I will try this solution at afternoon.

      Thank you.

      Comment

      • aperezl
        Junior Member
        • Oct 2012
        • 7

        #4
        Despite my vbscript became rusty, it works like a charm!!

        Comment

        Working...