Announcement

Collapse
No announcement yet.

[SCRIPT] Search your logs for errors and then email a summary to you

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SCRIPT] Search your logs for errors and then email a summary to you

    William,

    nice idea for a script!
    I had a bit of a problem though...
    "Script error in file: log_check.txt: 9:Subscript out of range: '[number: 0]' in line 28"
    so altered it a bit. I also put the search terms in an array.

    Should you want to update your script in the script library, my revised code is below.

    sub main()
    '=========================================================== ====
    'Credit for the log reading part to the author of Visitor_IP.txt
    '=========================================================== ====

    hs.waitevents

    Dim log_line , error_list , todays_date , line_date , MyDate, SearchFor

    SearchFor = Array ("error","alarm","InFo","WhAtEVeR") 'Add as many strings as you like

    Path = hs.GetAppPath & "\ah.log"
    todays_date = CStr(Date)
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.OpenTextFile(Path, 1)


    Do Until file.AtEndOfStream

    log_line = file.ReadLine

    MyDate = Mid(log_line, 1, 10)


    If todays_date = MyDate Then

    For i = 0 to UBound(SearchFor)

    if instr(lcase(log_line),lcase(SearchFor(i))) then
    error_list = error_list & log_line & vbcrlf & " " & vbcrlf
    End If

    Next

    end if


    loop

    if error_list = "" then error_list = "No errors found in this log"

    hs.SendEmail "to@address.net","from@address.net","HomeSeer Error Summary as of " & date() & " " & time(), error_list

    file.Close

    Set file = Nothing
    Set fso = Nothing

    end sub

  • #2
    This looks like a very useful script. I know it won't run under HS3/Latest VB.net. How far is it from being "repaired?"
    HomeSeer Version: HS3 Pro Edition 3.0.0.500
    Operating System: Microsoft Windows 10 Pro - Work Station

    Enabled Plug-Ins:
    2.1.0.119: AmbientWeather | 3.0.21.0: BLLock | 2.0.24.0: BLUPS | 1.3.6.0: Device History | 3.0.0.56: EasyTrigger | 3.1.0.7: MeiHarmonyHub | 3.0.6681.34300: UltraCID3 | 3.0.6644.26753: UltraLog3 | 3.0.6554.33094: UltraMon3 | 3.0.0.91: weatherXML | 3.0.1.245: Z-Wave | 3.0.51: HS Touch Designer | 3.0.0.40 Z-Seer+

    Comment

    Working...
    X