Good Day All,
I have gone through the forums on how to setup a multiple pinging devices and if one of the ip`s fails a mail needs to be sent out ........ I have gone through these samples to see what was going on. I can`t even just get one of them to run to see how it looks like .......
1. http://www.autoitscript.com/forum/topic/83246-server-ping-responce-time-out/#entry595364
Please remember that I am still a newb at all of this and on programming itself so please try and put it in "layman`s terms"......... I have tried to update two of the above posts but to no sucess ....... Please I some can just explain to me where I need to do the changes to make it work, It will be mostly appreciated .......
#include <file.au3> #include <INet.au3> #include <Array.au3> Dim $Pulltxtfilelist, $num, $CurrentOffline, $RunForever, $Body[1] $INIFULLPATH = @WindowsDir & "\Settings.ini" $TMPDATSTORE = @WindowsDir & "\temp.dat" FileDelete($TMPDATSTORE) IniWrite($TMPDATSTORE, "Offline", "","") IniWrite($TMPDATSTORE, "Online", "","") $SmtpServer = IniRead($INIFULLPATH, "Email Setup", "SMTPServer", "Default") $FromName = IniRead($INIFULLPATH, "Email Setup", "EmailFromName", "Default") $FromAddress = IniRead($INIFULLPATH, "Email Setup", "EmailFromAddress", "Default") $ToAddress = IniRead($INIFULLPATH, "Email Setup", "EmailToAddress", "Default") $Subject = IniRead($INIFULLPATH, "Email Setup", "EmailSubject", "Default") $Delay = IniRead($INIFULLPATH, "Setup", "EmailOutDelaySeconds", "30") If Not _FileReadToArray(@WindowsDir & "\ServerList.txt", $Pulltxtfilelist) Then MsgBox(4096, "Error", "ServersList.txt is not found please create and restart service. error:" & @error) Exit EndIf For $x = 1 To $Pulltxtfilelist[0] $num = $num + 1 $pingerror = Ping($Pulltxtfilelist[$x]) If $pingerror Then IniWrite($TMPDATSTORE, "Online", $num, $Pulltxtfilelist[$x]) EndIf If $pingerror = 0 Then IniWrite($TMPDATSTORE, "Offline", $num, $Pulltxtfilelist[$x]) Dim $Body[1] $Body[0] = $Pulltxtfilelist[$x] & " Server has not responded on last Ping. Please note that this is Just a test." $Response = _INetSmtpMail($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, "", -1) EndIf Next Do Sleep($Delay) $OfflineCheck = IniReadSection($TMPDATSTORE, "Offline") If @error Then Else For $i = 1 To $OfflineCheck[0][0] $pingerror = Ping($OfflineCheck[$i][1]) If $pingerror = 0 Then Else IniDelete($TMPDATSTORE, "Offline", $OfflineCheck[$i][0]) IniWrite($TMPDATSTORE, "Online", $OfflineCheck[$i][0], $OfflineCheck[$i][1]) $Body[0] = $OfflineCheck[$i][1] & " Server is responding to Pings once again." $Response = _INetSmtpMail($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, "", -1) EndIf Next EndIf $CurrentOffline = "" For $i = 1 To $OfflineCheck[0][0] $CurrentOffline = $CurrentOffline & @CRLF & $OfflineCheck[$i][1] Next $OnlineCheck = IniReadSection($TMPDATSTORE, "Online") If @error Then Else For $i = 1 To $OnlineCheck[0][0] $pingerror = Ping($OnlineCheck[$i][1]) If $pingerror = 0 Then Sleep(1000) $pingerror2 = Ping($OnlineCheck[$i][1]) ; msgbox(4096, "", $pingerror2) If $pingerror2 = 0 Then IniDelete($TMPDATSTORE, "Online", $OnlineCheck[$i][0]) IniWrite($TMPDATSTORE, "Offline", $OnlineCheck[$i][0], $OnlineCheck[$i][1]) Dim $Body[3] $Body[0] = $OnlineCheck[$i][1] & " Server has not responded on last Ping. Please note that this is Just a test." $CurrentOffline = $CurrentOffline & @CRLF & $OnlineCheck[$i][1] $Body[1] = @CRLF $Body[2] = "Server Outage List:" & @CRLF & $CurrentOffline $Response = _INetSmtpMail($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, "", -1) EndIf EndIf Next EndIf Until $RunForever = 100
I get the following error .......
(63) : ==> Subscript used with non-Array variable.:
For $i = 1 To $OfflineCheck[0][0]
For $i = 1 To $OfflineCheck^ ERROR
->14:04:14 AutoIT3.exe ended.rc:1
>Exit code: 1 Time: 2.145
Please if someone can just show me how to fix it ........
Regards,
Chovie