Ad Widget

Collapse

Windows custom script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oliverm
    Senior Member
    • May 2006
    • 155

    #1

    Windows custom script

    Hi chaps.

    I'm still tinkering with a custom script i am created to monitor elements of my Windows servers.

    If I setup zabbix agent to run the script as an item, is it enough that the script 'echo's the output on online when run as a test ?

    I guess my real question is, how best to get the info gathered by the script in windows to the zabbix agent so that it can be returned to the zabbix server.

    Has anyone got an example windows based WSH/VBS script of any type I can look at to see how they do it ?

    Olly
  • mpeide
    Junior Member
    • Jul 2005
    • 21

    #2
    Oliverm,

    You can simply do a echo with vbs. Make sure that you use "cscript //nologo" when you call it. It works fabulous.

    Here is a vbs I use to have Zabbix monitor if virus definitions are current on my servers.

    Later,

    Matt

    ----------------------------------------------------------------

    Option Explicit
    Dim srcFile



    srcFile = "C:\Program Files\Common Files\Symantec Shared\VirusDefs\definfo.dat"
    'Wscript.echo srcFile
    DateDifference srcFile, "CurDefs"




    Function DateDifference(sFile, sFindString)

    Dim oFso, hReadFile, s, sReadLine, tmpArray, tmpstr
    Set oFso = CreateObject("Scripting.FileSystemObject")
    DateDifference = False

    Const iFORREADING = 1
    Const iFORWRITING = 2
    Const iTEMPFOLDER = 2





    Set hReadFile = oFSO.OpenTextFile(sFile, iFORREADING, True)

    'Set hWriteFile = oFSO.OpenTextFile(sFile, iFORWRITING, True)

    Do Until hReadFile.AtEndofStream

    sReadLine = Trim(hReadFile.ReadLine)

    If InStr(LCase(sReadLine), LCase(sFindString)) AND sReadLine <> "" then
    'Wscript.echo sReadLine
    tmpArray = Split(sReadLine,"=")
    s = left(tmpArray(1), 8)
    tmpstr = CDate(Left(S, 4) & "/" & Mid(S, 5, 2) & "/" & Right(S, 2))

    wscript.echo Datediff("d", tmpstr, date)

    End If

    Loop

    hReadFile.Close


    Set hReadFile = Nothing


    DateDifference = True

    End Function

    Comment

    Working...