Ad Widget

Collapse

directory size in windows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flexguy
    Junior Member
    • Sep 2008
    • 19

    #1

    directory size in windows

    This is how I monitor the size of a directory on a windows machine:

    1. fill in the correct zabbix-server-IP and de correct hostname of the windows system
    in the commandstring in the vb-script (see below)
    2. save the vb-script as c:\zabbix\dir_size.vbs on the windows system to be monitored.
    3. add userparameter in the zabbix_agentd.conf:
    UserParameter=dir_size[*],cscript.exe c:\zabbix\dir_size.vbs $1
    4. restart zabbix agent
    5. create 2 items in zabbix:

    first one:
    description: whatever
    type: zabbix trapper
    key: tr_dir_size
    type: numeric

    second one:
    description: tr_dir_size
    type: zabbix agent
    key: dir_size[c:\root\sub]
    type: text
    interval: 300

    explanation: the second one makes the zabbix agent execute the script every 300 seconds, while the first one catches the output of the script. The output is the size of directory c:\root\sub in bytes

    The script itself:

    Dim oF, oFS, dirsize
    directory = WScript.Arguments(0)
    Set objFS = CreateObject("Scripting.FileSystemObject")
    set oF = oFS.GetFolder(directory)
    dirsize = oF.Size
    Set WshShell = CreateObject("wscript.Shell")
    commandstring="c:\zabbix\zabbix_sender.exe -z ZBX_IP -s HOST_NAME -k tr_dir_size -o " & dirsize
    WshShell.Run commandstring,0
    WScript.Quit

    Good luck,
Working...