Ad Widget

Collapse

Passing parameters in VBS script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sofinor
    Junior Member
    • Jul 2010
    • 2

    #1

    Passing parameters in VBS script

    Hi, i'm trying to monitor DFS replicated folder using wmi classes in a vbs script.
    Here is the zabbix_agent.conf line:

    UserParameter=dfs_repl_fold_state[*],cscript.exe //Nologo "C:\scripts\dfs_repl_fold_state.vbs" "$1" "$2"

    and the vbs script (which works fine):

    On Error Resume Next

    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20
    intExit = 0
    strMember = WScript.Arguments.Item(0)
    strReplFolder = WScript.Arguments.Item(1)

    Set objWMIService = GetObject("winmgmts:\\" & strMember & "\root\MicrosoftDfs")
    Set colItems = objWMIService.ExecQuery("SELECT * FROM DfsrReplicatedFolderInfo WHERE ReplicatedFolderName='" & strReplFolder & "'", "WQL", _
    wbemFlagReturnImmediately + wbemFlagForwardOnly)

    For Each objItem In colItems
    If objItem.State = 4 Then intExit = 0 Else intExit = 1 End If
    WScript.Echo objItem.State
    WScript.Quit(intExit)
    Next

    When I test it on zabbix, I get the following message:

    zabbix:~ # zabbix-get -s dc2 -k dfs_repl_fold_state[ged,test]
    zabbix:~ # ZBX_NOTSUPPORTED

    Thanks for your help,

    JBS
  • QwErTy_LoGiC
    Member
    • Feb 2010
    • 66

    #2
    Don't use " "

    Hi,

    I think you need to get rid of the quotes in the agent configuration file

    It should look like : UserParameter=dfs_repl_fold_state[*],cscript.exe //Nologo C:\scripts\dfs_repl_fold_state.vbs $1 $2

    Comment

    • QwErTy_LoGiC
      Member
      • Feb 2010
      • 66

      #3
      Oh... and get rid of the *

      Forgot about the *, it should look like

      UserParameter=dfs_repl_fold_state[],cscript.exe //Nologo "C:\scripts\dfs_repl_fold_state.vbs" "$1" "$2"

      Comment

      Working...