Gene Posted February 25, 2007 Posted February 25, 2007 (edited) I have had a problem of up and down connection and sometimes hundreds of IP changes in a day. I saw that others had similar problems and decided to post my solution to the problem. This script is not polished, but it seems to be working fine. It is also not simple, I wanted an output document I could beat my ISP with.It still has some research code in it that tracks the time to process a whole cycle minus the Sleep() time and the time taken to process the cycles that are involved when there is no obvious downtime and just the IP address is changed. There is also some remnants of code to track process flow, but it is remarked out.I'm still trying to figure out how to determine the average length of the interuption when the IP address changes. A lot of the time my connection is uninterupted for days or weeks. At other times the IP address may change from a high of more than once a second to 2 or 3 times an hour. In the "good" times the IP only changes once every 30 to 45 days.It has 2 FileInstalls, they are included in the ZIP file. I'd appreciate any comment, rocks or otherwise.{EDIT 2/28/07} I should have put this in here to begin with In addition to tracking up/down time, it also produces an HTML log file with the latest data at the top of the list, so you don't have to spend a lot of time scrolling down to see what has been happening lately. It inserts column headers every X number of rows (you can change X in the INI) MaxRows=20 is the default. For each day/week/month that IP Address changes occur it inserts a Total Row for the appropriate time unit.That row shows the current date, thenumber of IP Address changes including downtime changes, thenumber of times the connection went down, theamount of downtime in seconds and theaverage number of seconds per time down.If you have a gmail account and configure Jdeb's Send Mail UDF, you can run it on another PC or Server on your network and each time MaxRows is reached, it will send you an email. No email = nothing serious going on with your connection. If you have an easy to read record of you up/down experience Your ISP wil probably take you seriously, mine did. Mine did note that they liked that I had let it run during the good times as well. {EDIT 2/27/07c} I don't know why, but all the backslashes have disappeared from the code below. So don't copy and paste, download the ZIP.{EDIT 2/27/07b} There are edits in the text above due to the post having been moved from its original location.{EDIT 2/27/07a} @SmOke_N pointed out below, that as long as FileInstalls are in the script folder, full paths are not necessary. I updated the code below and the .ZIP.expandcollapse popup#compiler_aut2exe=C:Program FilesAutoIt3betaAut2ExeAut2Exe.exe #compiler_icon= #compiler_outfile=K:My Documents_Dev_ProjectsInternetConnectionMonitorInternetConnectionMonitorInternetConnectionMonitor(shared 1.104).au3.exe #compiler_Compression=4 #compiler_PassPhrase= #compiler_Allow_Decompile=4 ;[Res] #compiler_res_comment=Tracks Internet uptime based on the external IP Address. #compiler_res_description=Tracks Internet uptime based on the external IP Address. #compiler_res_fileversion=0.0.1.104 #compiler_res_fileversion_autoincrement=n #compiler_res_legalcopyright=Eugene T. Sears 2007 gtsears@yahoo.com #compiler_res_field1name=Version #compiler_res_field1value=0.0.1.104 ;[Other] #compiler_Run_AU3Check=1 #compiler_Run_Before= #compiler_Run_After= #include <Date.au3> #include <Inet.au3> #include <File.au3> #include <String.au3> Global $PublicIP, $sIpConn, $iInterval, $sLastIP, $sLastIpAddr, $dLastChgDate, $dLastCycleDate, $iChgCntFromStart Global $iCycleCount, $iChgCount, $iShortInterval, $iLongInterval, $dLogStarted, $sTrakHtm, $dNow, $iCycleCntFromStart Global $dDateTimeNow, $iDateDiff, $iMaxRows, $iEmail, $iRetry, $iHours, $iMins, $iSecs, $dLastYrMoDa, $iMonDownChgs Global $iMonDownSecs, $iTodayDownChgs, $iTodayDownSecs, $iWeekDownChgs, $iWeekDownSecs, $iMonChgs, $iTodayChgs, $iWeekChgs Global $iMediumInterval, $iPush, $iDownSec, $sVarContent, $iScriptLine, $iResponse, $iError, $dYrMoDa, $dStartTime Global $iCycleTimeCnt, $dif, $iCycleTime, $sLogMsg, $begin, $iPrintProcessLog, $iChgTime, $iIPchgCycleTimeCnt, $iChgCycleFlg Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $iInterval = 0 If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 $dStartTime = _NowCalc() If FileExists(@WorkingDir & "InConMon.INI") Then _ReadINI() Else _Chek4HTMfile() _CreateINI() EndIf If Not FileExists(@WorkingDir & "Trak.HTM") Then _Chek4HTMfile() EndIf While 1 $dDateTimeNow = _NowCalc() $dYrMoDa = @YEAR & "-" & @MON & "-" & @MDAY _NextCycle() WEnd Exit Func OnAutoItExit() $sLogMsg = " Cumulative Cycle Time (" & Round($iCycleTime, 4) & ") Divided by " & $iCycleTimeCnt & " Cycles = " & Round(($iCycleTime / $iCycleTimeCnt), 4) & " Seconds per Cycle. " _FileWriteLog(@WorkingDir & "TimingLog.log", $sLogMsg & " Data flushed on shutdownn. ") _FileWriteLog(@WorkingDir & "ChgCycleTime.log", $iChgTime & @TAB & $iIPchgCycleTimeCnt & @TAB & " Data flushed on shutdownn. ") EndFunc ;==>OnAutoItExit Func _VarContent($iScriptLine, $sMessage) ;If $iPrintProcessLog = 1 Then If $iPrintProcessLog = 3 Then $sVarContent = $iScriptLine & "|" & $sMessage & "|" & $PublicIP & "|" & $sLastIpAddr & "|" & $dLastChgDate & "|" & $dDateTimeNow & "|" & $iDownSec & "|" & $dLastYrMoDa & "|" & $dYrMoDa & "|" & $iChgCount & "|" & $iDateDiff & "|" & $iDownSec & "|" & $iMonChgs & "|" & $iMonDownChgs & "|" & $iMonDownSecs & "|" & $iTodayChgs & "|" & $iTodayDownChgs & "|" & $iTodayDownSecs & "|" & $iWeekChgs & "|" & $iWeekDownChgs & "|" & $iWeekDownSecs & @CRLF _FileWriteLog(@WorkingDir & "ProcessPath.log", $sVarContent) EndIf If $iPrintProcessLog = 0 Then _FileWriteLog(@WorkingDir & "ProcessPath.log", @CRLF & @CRLF & @CRLF) $iPrintProcessLog = 2 EndIf EndFunc ;==>_VarContent Func _AddressChanged() If $sLastIpAddr = "Startup" Then $iDateDiff = 0 $sTrakHtm = $sTrakHtm & "<tr>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $dDateTimeNow & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $sLastIpAddr & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $iDateDiff & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $PublicIP & "</td>" & @CR $sTrakHtm = $sTrakHtm & "</tr>" & @CR _WriteToLog() If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 $sTrakHtm = "" $iChgCount = 0 IniWrite(@WorkingDir & "InConMon.INI", "Last", "ChgCount", $iChgCount) $iMonDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownChgs", $iMonDownChgs) $iMonDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownSecs", $iMonDownSecs) $iTodayDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownChgs", $iTodayDownChgs) $iTodayDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownSecs", $iTodayDownSecs) $iWeekDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownChgs", $iWeekDownChgs) $iWeekDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownSecs", $iWeekDownSecs) $iMonChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonChgs", $iMonChgs) $iTodayChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayChgs", $iTodayChgs) $iWeekChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekChgs", $iWeekChgs) Else $iPrintProcessLog = 1 If $sLastIpAddr <> "Startup" And $sLastIpAddr <> "None" Then $iChgCycleFlg = 1 EndIf Select ;Case _DateDiff("M", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 1 ; $iDateDiff = _DateDiff("M", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Months " Case _DateDiff("w", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 1 $iDateDiff = _DateDiff("w", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Weeks " Case _DateDiff("D", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 1 $iDateDiff = _DateDiff("D", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Days " Case _DateDiff("h", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 1 $iDateDiff = _DateDiff("h", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Hours " Case _DateDiff("n", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 1 $iDateDiff = _DateDiff("n", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Minutes " Case _DateDiff("S", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 0 $iDateDiff = _DateDiff("S", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Seconds " EndSelect $dLastChgDate = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", "") $iDownSec = _DateDiff("S", $dLastChgDate, $dDateTimeNow) If $iChgCount > $iMaxRows Then $iEmail = 1 $iChgCount = 0 $sTrakHtm = $sTrakHtm & "<tr>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center"><b><font size="4">Date & Time</font></b></td>' & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center"><b><font size="4">Last Ip Address</font></b></td>' & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center"><b><font size="4">Duration</font></b></td>' & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center"><b><font size="4">New Ip Address</font></b></td>' & @CR $sTrakHtm = $sTrakHtm & "</tr>" & @CR EndIf ; $iChgCount = $iMaxRows $sTrakHtm = $sTrakHtm & "<tr>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $dDateTimeNow & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $sLastIpAddr & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $iDateDiff & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $PublicIP & "</td>" & @CR $sTrakHtm = $sTrakHtm & "</tr>" & @CR _WriteToLog() If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 $sTrakHtm = "" If $sLastIpAddr = "None" Then $iMonDownChgs = $iMonDownChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownChgs", $iMonDownChgs) $iMonDownSecs = $iMonDownSecs + $iDownSec IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownSecs", $iMonDownSecs) $iTodayDownChgs = $iTodayDownChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownChgs", $iTodayDownChgs) $iTodayDownSecs = $iTodayDownSecs + $iDownSec IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownSecs", $iTodayDownSecs) $iWeekDownChgs = $iWeekDownChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownChgs", $iWeekDownChgs) $iWeekDownSecs = $iWeekDownSecs + $iDownSec IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownSecs", $iWeekDownSecs) EndIf ; $sLastIpAddr = "None" $iMonChgs = $iMonChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonChgs", $iMonChgs) $iTodayChgs = $iTodayChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayChgs", $iTodayChgs) $iWeekChgs = $iWeekChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekChgs", $iWeekChgs) $iCycleCount = 0 IniWrite(@WorkingDir & "InConMon.INI", "Last", "CycleCount", $iCycleCount) IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", $dDateTimeNow) $iChgCount = $iChgCount + 1 IniWrite(@WorkingDir & "InConMon.INI", "Last", "ChgCount", $iChgCount) $iChgCntFromStart = $iChgCntFromStart + 1 IniWrite(@WorkingDir & "InConMon.INI", "Cumulative", "ChgCntFromStart", $iChgCntFromStart) If $sLastIpAddr <> $PublicIP Then IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastIpAddr", $PublicIP) $sLastIpAddr = $PublicIP EndIf EndIf If $sLastIpAddr = "Startup" Then If $sLastIpAddr = "Startup" Then $sLastIpAddr = $PublicIP IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastIpAddr", $PublicIP) $iError = @error If $iError > 0 Then Select Case $iError = 1 MsgBox(0, "Error Message", " Invalid $sType ") Case $iError = 2 MsgBox(0, "Error Message", " Invalid $sStartDate ") Case $iError = 3 MsgBox(0, "Error Message", " Invalid $sEndDate ") EndSelect EndIf EndIf EndFunc ;==>_AddressChanged Func _Chek4HTMfile() If Not FileExists(@WorkingDir & "Trak.HTM") Then FileInstall("Trak2.HTM", @WorkingDir & "Trak.HTM", 0) _ReplaceStringInFile(@WorkingDir & "Trak.HTM", "StartDateTime", $dStartTime, 0, 0) EndIf If Not FileExists(@WorkingDir & "InConMon.INI") Then FileInstall("InConMon2.INI", @WorkingDir & "InConMon.INI", 1) EndIf $dLastCycleDate = $dStartTime EndFunc ;==>_Chek4HTMfile Func _CompareIpAddr() $PublicIP = _GetIP() If $PublicIP = -1 Then $PublicIP = "None" $iPrintProcessLog = 1 EndIf $sLastIpAddr = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastIpAddr", "None") If $PublicIP = $sLastIpAddr Then $sIpConn = "OK" If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 Else $sIpConn = "" $iPrintProcessLog = 1 _AddressChanged() EndIf EndFunc ;==>_CompareIpAddr Func _CreateINI() IniWrite(@WorkingDir & "InConMon.INI", "Start", "LogStarted", $dLogStarted) IniWrite(@WorkingDir & "InConMon.INI", "Start", "MaxRows", "20") $dLogStarted = IniRead(@WorkingDir & "InConMon.INI", "Last", "LogStarted", "") If $dLogStarted = "" Then $dLogStarted = _NowCalc() IniWrite(@WorkingDir & "InConMon.INI", "Start", "LogStarted", $dLogStarted) EndIf $dYrMoDa = @YEAR & "-" & @MON & "-" & @MDAY IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastYrMoDa", $dYrMoDa) IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastCycleDate", $dLastCycleDate) $PublicIP = _GetIP() IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastIpAddr", "Startup") IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", $dLogStarted) IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastCycleDate", $dLastCycleDate) IniWrite(@WorkingDir & "InConMon.INI", "Last", "CycleCount", "1") IniWrite(@WorkingDir & "InConMon.INI", "Last", "ChgCount", "1") IniWrite(@WorkingDir & "InConMon.INI", "Interval", "ShortInterval", "2") IniWrite(@WorkingDir & "InConMon.INI", "Interval", "MediumInterval", "6") IniWrite(@WorkingDir & "InConMon.INI", "Interval", "LongInterval", "15") IniWrite(@WorkingDir & "InConMon.INI", "Cumulative", "ChgCntFromStart", "0") IniWrite(@WorkingDir & "InConMon.INI", "Cumulative", "CycleCntFromStart", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "MonChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownSecs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownSecs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownSecs", "0") EndFunc ;==>_CreateINI Func _DaySubTotal() $iPrintProcessLog = 1 $iTodayChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "TodayChgs", "") If $iTodayChgs = 0 Then If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 Return EndIf $sTrakHtm = "<tr>" & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#00FFCC"><font size="4"><b>Daily' & @CR $sTrakHtm = $sTrakHtm & 'Subtotal<br>' & @CR $sTrakHtm = $sTrakHtm & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & $dLastYrMoDa & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#00FFCC"><font size="4"><b>Changes Today<br>' & @CR $sTrakHtm = $sTrakHtm & "Ttl. = " & $iTodayChgs & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & " Down = " & $iTodayDownChgs & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#00FFCC"><font size="4"><b>Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(seconds)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma($iTodayDownSecs) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#00FFCC"><font size="4"><b>Average Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(down secs/down chgs)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma(Round(($iTodayDownSecs / $iTodayDownChgs), 1)) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '</tr>' & @CR _WriteToLog() $sTrakHtm = "" $iTodayDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownChgs", $iTodayDownChgs) $iTodayDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownSecs", $iTodayDownSecs) $iTodayChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayChgs", $iTodayChgs) If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndFunc ;==>_DaySubTotal Func _WeekSubTotal() $iPrintProcessLog = 1 $iWeekChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "WeekChgs", "") If $iWeekChgs = 0 Then If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 Return EndIf $sTrakHtm = "<tr>" & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#FFCCFF"><font size="4"><b>Weekly' & @CR $sTrakHtm = $sTrakHtm & 'Subtotal<br>' & @CR $sTrakHtm = $sTrakHtm & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & $dLastYrMoDa & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#FFCCFF"><font size="4"><b>Changes Week<br>' & @CR $sTrakHtm = $sTrakHtm & " Ttl. = " & $iWeekChgs & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & " Down = " & $iWeekDownChgs & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#FFCCFF"><font size="4"><b>Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(seconds)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma($iWeekDownSecs) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#FFCCFF"><font size="4"><b>Average Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(down secs/down chgs)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma(Round(($iWeekDownSecs / $iWeekDownChgs), 1)) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '</tr>' & @CR _WriteToLog() $sTrakHtm = "" $iWeekDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownChgs", $iWeekDownChgs) $iWeekDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownSecs", $iWeekDownSecs) $iWeekChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekChgs", $iWeekChgs) If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndFunc ;==>_WeekSubTotal Func _MonSubTotal() $iPrintProcessLog = 1 $iMonChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "MonChgs", "") If $iMonChgs = 0 Then If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 Return EndIf $sTrakHtm = "<tr>" & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#CCFF33"><font size="4"><b>Monthly' & @CR $sTrakHtm = $sTrakHtm & 'Subtotal<br>' & @CR $sTrakHtm = $sTrakHtm & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & $dLastYrMoDa & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#CCFF33"><font size="4"><b>Changes Mon<br>' & @CR $sTrakHtm = $sTrakHtm & " Ttl. = " & $iMonChgs & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & " Down = " & $iMonDownChgs & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#CCFF33"><font size="4"><b>Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(seconds)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma($iMonDownSecs) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#CCFF33"><font size="4"><b>Average Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(down secs/down chgs)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma(Round(($iMonDownSecs / $iMonDownChgs), 1)) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '</tr>' & @CR _WriteToLog() $sTrakHtm = "" $iMonDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownChgs", $iMonDownChgs) $iMonDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownSecs", $iMonDownSecs) $iMonChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonChgs", $iMonChgs) If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndFunc ;==>_MonSubTotal Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) ; JdeB's code $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @LF & 'File not found to attach: ' & $S_Files2Attach[$x] SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf EndFunc ;==>_INetSmtpMailCom Func _WriteCyclTime() $sLogMsg = " Cumulative Cycle Time (" & Round($iCycleTime, 4) & ") Divided by " & $iCycleTimeCnt & " Cycles = " & Round(($iCycleTime / $iCycleTimeCnt), 4) & " Seconds per Cycle. " _FileWriteLog(@WorkingDir & "TimingLog.log", $sLogMsg) $iCycleTime = 0 $iCycleTimeCnt = 0 $dif = 0 EndFunc ;==>_WriteCyclTime Func _NextCycle() $iCycleCount = $iCycleCount + 1 IniWrite(@WorkingDir & "InConMon.INI", "Last", "CycleCount", $iCycleCount) $iCycleCntFromStart = $iCycleCntFromStart + 1 IniWrite(@WorkingDir & "InConMon.INI", "Cumulative", "CycleCntFromStart", $iCycleCntFromStart) _CompareIpAddr() If $dLastYrMoDa <> $dYrMoDa And $sLastIpAddr <> "Startup" Then ; Process subtotals... If $iTodayChgs > 0 Then ; Daily subtotal... $iPrintProcessLog = 1 _DaySubTotal() If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndIf If @WDAY = "1" And $iWeekChgs > 0 Then ; Wekly subtotal... $iPrintProcessLog = 1 _WeekSubTotal() If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndIf If @MDAY = "01" And $iMonChgs > 0 Then ; Monthly subtotal... $iPrintProcessLog = 1 _MonSubTotal() If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndIf IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastYrMoDa", $dYrMoDa) $dLastYrMoDa = $dYrMoDa EndIf ; Begin end of cycle time processing. If $iCycleTimeCnt <> 0 Then $dif = TimerDiff($begin) / 1000 If $iCycleTimeCnt <> 0 Then $iCycleTime = $iCycleTime + $dif $iCycleTimeCnt = $iCycleTimeCnt + 1 If $iChgCycleFlg = 1 Then $iIPchgCycleTimeCnt = $iIPchgCycleTimeCnt + 1 $iChgCycleFlg = 0 $iChgTime = $iChgTime + $dif If $iChgTime > 20 Then _FileWriteLog(@WorkingDir & "ChgCycleTime.log", $iChgTime & @TAB & $iIPchgCycleTimeCnt) $iChgTime = 0 $iIPchgCycleTimeCnt = 0 EndIf EndIf $iInterval = 500 If $iCycleTimeCnt > $iInterval And $iCycleTime > 0 Then _WriteCyclTime() EndIf ; End of cycle time processing. ;MsgBox(0," Begin Sleep Code", " Line " & @ScriptLineNumber & " Begin Sleep Code, CycleCount = " & $iCycleCount) Select Case $iCycleCount < 200 ;2 sec Sleep($iShortInterval * 1000) Case $iCycleCount < 400 ;6 sec Sleep($iMediumInterval * 1000) Case Else ;15 sec Sleep($iLongInterval * 1000) EndSelect ;MsgBox(0," End of Sleep Code", " Line " & @ScriptLineNumber & " End of Sleep Code", 1 ) ; Begin cycle time recording. $begin = TimerInit() If $iCycleCount = 200 Or $iEmail = 1 Then $iEmail = 0 _PrepEmail() EndIf If $iRetry = 1 And $iCycleCount = 300 Then $iRetry = 0 _PrepEmail() If $iRetry = 0 Then While FileExists(@TempDir & "icm.err.log") FileDelete(@TempDir & "icm.err.log") WEnd EndIf EndIf IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastCycleDate", $dDateTimeNow) EndFunc ;==>_NextCycle Func _PrepEmail() $as_Body = FileRead(@WorkingDir & "Trak.HTM", FileGetSize(@WorkingDir & "Trak.HTM")) Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ;################################## ; Include JdeB's code ;################################## #Include<file.au3> ;################################## ; Variables ;################################## $s_SmtpServer = "smtp.gmail.com" ; address for the smtp-server to use - REQUIRED $s_FromName = " your name here " ; name from who the email was sent $s_FromAddress = "youracctname@gmail.com" ; address from where the mail should come $s_ToAddress = "youracctname@gmail.com" ; destination address of the email - REQUIRED $s_Subject = "IP Address change" ; subject from the email - can be anything you want it to be ;$as_Body = "The IP Address changed from " & $sLastIP & " to " & $PublicIP & " at 12:35." ; the messagebody from the mail - can be left blank but then you get a blank mail $s_AttachFiles = @TempDir & "icm.err.log" ; the file you want to attach- leave blank if not needed $s_CcAddress = "" ; address for cc - leave blank if not needed $s_BccAddress = "" ; address for bcc - leave blank if not needed $s_Username = "youracctname@gmail.com" ; username for the account used from where the mail gets sent - REQUIRED $s_Password = "password" ; password for the account used from where the mail gets sent - REQUIRED ; $IPPort = 25 ; port used for sending the mail ; $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $IPPort = 465 ; GMAIL port used for sending the mail $ssl = 1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS ;################################## ; Script ;################################## $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) If @error Then FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Error sending message, Error code:" & @error & " Description:" & $rc & @CRLF) ;MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) $iRetry = 1 Else While FileExists(@TempDir & "icm.err.log") FileDelete(@TempDir & "icm.err.log") WEnd $iRetry = 0 EndIf EndFunc ;==>_PrepEmail Func _ReadINI() $iMaxRows = IniRead(@WorkingDir & "InConMon.INI", "Start", "MaxRows", "15") $dLastYrMoDa = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastYrMoDa", "0") $sLastIpAddr = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastIpAddr", "") $dLastChgDate = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", "") $dLastCycleDate = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastCycleDate", "") $iCycleCount = IniRead(@WorkingDir & "InConMon.INI", "Last", "CycleCount", "") $iChgCount = IniRead(@WorkingDir & "InConMon.INI", "Last", "ChgCount", "") $iShortInterval = IniRead(@WorkingDir & "InConMon.INI", "Interval", "ShortInterval", "") $iMediumInterval = IniRead(@WorkingDir & "InConMon.INI", "Interval", "MediumInterval", "") $iLongInterval = IniRead(@WorkingDir & "InConMon.INI", "Interval", "LongInterval", "") $dLogStarted = IniRead(@WorkingDir & "InConMon.INI", "Start", "LogStarted", "") $iChgCntFromStart = IniRead(@WorkingDir & "InConMon.INI", "Cumulative", "ChgCntFromStart", "") $iCycleCntFromStart = IniRead(@WorkingDir & "InConMon.INI", "Cumulative", "CycleCntFromStart", "") $iMonChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "MonChgs", 0) $iMonDownChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "MonDownChgs", 0) $iMonDownSecs = IniRead(@WorkingDir & "InConMon.INI", "History", "MonDownSecs", 0) $iTodayChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "TodayChgs", 0) $iTodayDownChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "TodayDownChgs", 0) $iTodayDownSecs = IniRead(@WorkingDir & "InConMon.INI", "History", "TodayDownSecs", 0) $iWeekChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "WeekChgs", 0) $iWeekDownChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "WeekDownChgs", 0) $iWeekDownSecs = IniRead(@WorkingDir & "InConMon.INI", "History", "WeekDownSecs", 0) EndFunc ;==>_ReadINI Func _WriteToLog() $iResponse = _FileWriteToLine(@WorkingDir & "Trak.HTM", 59, $sTrakHtm, 0) $iError = @error $sTrakHtm = "" Select Case $iError = 0 Case $iError = 1 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - File has too few lines. " & @CRLF) Case $iError = 2 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - Log file does not exist in working folder. " & @CRLF) Case $iError = 3 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - Error when opening the log file. " & @CRLF) Case $iError = 4 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - The location in the file where text to be added to the log is invalid. " & @CRLF) Case $iError = 5 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - The OverWrite flag is invalid. " & @CRLF) Case $iError = 6 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - The text to be added to the log is invalid. " & @CRLF) EndSelect EndFunc ;==>_WriteToLog ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc _linenums:0'>expandcollapse popup#compiler_aut2exe=C:Program FilesAutoIt3betaAut2ExeAut2Exe.exe #compiler_icon= #compiler_outfile=K:My Documents_Dev_ProjectsInternetConnectionMonitorInternetConnectionMonitorInternetConnectionMonitor(shared 1.104).au3.exe #compiler_Compression=4 #compiler_PassPhrase= #compiler_Allow_Decompile=4 ;[Res] #compiler_res_comment=Tracks Internet uptime based on the external IP Address. #compiler_res_description=Tracks Internet uptime based on the external IP Address. #compiler_res_fileversion=0.0.1.104 #compiler_res_fileversion_autoincrement=n #compiler_res_legalcopyright=Eugene T. Sears 2007 gtsears@yahoo.com #compiler_res_field1name=Version #compiler_res_field1value=0.0.1.104 ;[Other] #compiler_Run_AU3Check=1 #compiler_Run_Before= #compiler_Run_After= #include <Date.au3> #include <Inet.au3> #include <File.au3> #include <String.au3> Global $PublicIP, $sIpConn, $iInterval, $sLastIP, $sLastIpAddr, $dLastChgDate, $dLastCycleDate, $iChgCntFromStart Global $iCycleCount, $iChgCount, $iShortInterval, $iLongInterval, $dLogStarted, $sTrakHtm, $dNow, $iCycleCntFromStart Global $dDateTimeNow, $iDateDiff, $iMaxRows, $iEmail, $iRetry, $iHours, $iMins, $iSecs, $dLastYrMoDa, $iMonDownChgs Global $iMonDownSecs, $iTodayDownChgs, $iTodayDownSecs, $iWeekDownChgs, $iWeekDownSecs, $iMonChgs, $iTodayChgs, $iWeekChgs Global $iMediumInterval, $iPush, $iDownSec, $sVarContent, $iScriptLine, $iResponse, $iError, $dYrMoDa, $dStartTime Global $iCycleTimeCnt, $dif, $iCycleTime, $sLogMsg, $begin, $iPrintProcessLog, $iChgTime, $iIPchgCycleTimeCnt, $iChgCycleFlg Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $iInterval = 0 If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 $dStartTime = _NowCalc() If FileExists(@WorkingDir & "InConMon.INI") Then _ReadINI() Else _Chek4HTMfile() _CreateINI() EndIf If Not FileExists(@WorkingDir & "Trak.HTM") Then _Chek4HTMfile() EndIf While 1 $dDateTimeNow = _NowCalc() $dYrMoDa = @YEAR & "-" & @MON & "-" & @MDAY _NextCycle() WEnd Exit Func OnAutoItExit() $sLogMsg = " Cumulative Cycle Time (" & Round($iCycleTime, 4) & ") Divided by " & $iCycleTimeCnt & " Cycles = " & Round(($iCycleTime / $iCycleTimeCnt), 4) & " Seconds per Cycle. " _FileWriteLog(@WorkingDir & "TimingLog.log", $sLogMsg & " Data flushed on shutdownn. ") _FileWriteLog(@WorkingDir & "ChgCycleTime.log", $iChgTime & @TAB & $iIPchgCycleTimeCnt & @TAB & " Data flushed on shutdownn. ") EndFunc ;==>OnAutoItExit Func _VarContent($iScriptLine, $sMessage) ;If $iPrintProcessLog = 1 Then If $iPrintProcessLog = 3 Then $sVarContent = $iScriptLine & "|" & $sMessage & "|" & $PublicIP & "|" & $sLastIpAddr & "|" & $dLastChgDate & "|" & $dDateTimeNow & "|" & $iDownSec & "|" & $dLastYrMoDa & "|" & $dYrMoDa & "|" & $iChgCount & "|" & $iDateDiff & "|" & $iDownSec & "|" & $iMonChgs & "|" & $iMonDownChgs & "|" & $iMonDownSecs & "|" & $iTodayChgs & "|" & $iTodayDownChgs & "|" & $iTodayDownSecs & "|" & $iWeekChgs & "|" & $iWeekDownChgs & "|" & $iWeekDownSecs & @CRLF _FileWriteLog(@WorkingDir & "ProcessPath.log", $sVarContent) EndIf If $iPrintProcessLog = 0 Then _FileWriteLog(@WorkingDir & "ProcessPath.log", @CRLF & @CRLF & @CRLF) $iPrintProcessLog = 2 EndIf EndFunc ;==>_VarContent Func _AddressChanged() If $sLastIpAddr = "Startup" Then $iDateDiff = 0 $sTrakHtm = $sTrakHtm & "<tr>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $dDateTimeNow & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $sLastIpAddr & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $iDateDiff & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $PublicIP & "</td>" & @CR $sTrakHtm = $sTrakHtm & "</tr>" & @CR _WriteToLog() If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 $sTrakHtm = "" $iChgCount = 0 IniWrite(@WorkingDir & "InConMon.INI", "Last", "ChgCount", $iChgCount) $iMonDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownChgs", $iMonDownChgs) $iMonDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownSecs", $iMonDownSecs) $iTodayDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownChgs", $iTodayDownChgs) $iTodayDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownSecs", $iTodayDownSecs) $iWeekDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownChgs", $iWeekDownChgs) $iWeekDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownSecs", $iWeekDownSecs) $iMonChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonChgs", $iMonChgs) $iTodayChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayChgs", $iTodayChgs) $iWeekChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekChgs", $iWeekChgs) Else $iPrintProcessLog = 1 If $sLastIpAddr <> "Startup" And $sLastIpAddr <> "None" Then $iChgCycleFlg = 1 EndIf Select ;Case _DateDiff("M", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 1 ; $iDateDiff = _DateDiff("M", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Months " Case _DateDiff("w", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 1 $iDateDiff = _DateDiff("w", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Weeks " Case _DateDiff("D", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 1 $iDateDiff = _DateDiff("D", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Days " Case _DateDiff("h", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 1 $iDateDiff = _DateDiff("h", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Hours " Case _DateDiff("n", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 1 $iDateDiff = _DateDiff("n", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Minutes " Case _DateDiff("S", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) > 0 $iDateDiff = _DateDiff("S", IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", ""), $dDateTimeNow) & " Seconds " EndSelect $dLastChgDate = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", "") $iDownSec = _DateDiff("S", $dLastChgDate, $dDateTimeNow) If $iChgCount > $iMaxRows Then $iEmail = 1 $iChgCount = 0 $sTrakHtm = $sTrakHtm & "<tr>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center"><b><font size="4">Date & Time</font></b></td>' & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center"><b><font size="4">Last Ip Address</font></b></td>' & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center"><b><font size="4">Duration</font></b></td>' & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center"><b><font size="4">New Ip Address</font></b></td>' & @CR $sTrakHtm = $sTrakHtm & "</tr>" & @CR EndIf ; $iChgCount = $iMaxRows $sTrakHtm = $sTrakHtm & "<tr>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $dDateTimeNow & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $sLastIpAddr & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $iDateDiff & "</td>" & @CR $sTrakHtm = $sTrakHtm & ' <td width="20%" align="center" bgcolor="#CCFFFF">' & $PublicIP & "</td>" & @CR $sTrakHtm = $sTrakHtm & "</tr>" & @CR _WriteToLog() If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 $sTrakHtm = "" If $sLastIpAddr = "None" Then $iMonDownChgs = $iMonDownChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownChgs", $iMonDownChgs) $iMonDownSecs = $iMonDownSecs + $iDownSec IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownSecs", $iMonDownSecs) $iTodayDownChgs = $iTodayDownChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownChgs", $iTodayDownChgs) $iTodayDownSecs = $iTodayDownSecs + $iDownSec IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownSecs", $iTodayDownSecs) $iWeekDownChgs = $iWeekDownChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownChgs", $iWeekDownChgs) $iWeekDownSecs = $iWeekDownSecs + $iDownSec IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownSecs", $iWeekDownSecs) EndIf ; $sLastIpAddr = "None" $iMonChgs = $iMonChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonChgs", $iMonChgs) $iTodayChgs = $iTodayChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayChgs", $iTodayChgs) $iWeekChgs = $iWeekChgs + 1 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekChgs", $iWeekChgs) $iCycleCount = 0 IniWrite(@WorkingDir & "InConMon.INI", "Last", "CycleCount", $iCycleCount) IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", $dDateTimeNow) $iChgCount = $iChgCount + 1 IniWrite(@WorkingDir & "InConMon.INI", "Last", "ChgCount", $iChgCount) $iChgCntFromStart = $iChgCntFromStart + 1 IniWrite(@WorkingDir & "InConMon.INI", "Cumulative", "ChgCntFromStart", $iChgCntFromStart) If $sLastIpAddr <> $PublicIP Then IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastIpAddr", $PublicIP) $sLastIpAddr = $PublicIP EndIf EndIf If $sLastIpAddr = "Startup" Then If $sLastIpAddr = "Startup" Then $sLastIpAddr = $PublicIP IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastIpAddr", $PublicIP) $iError = @error If $iError > 0 Then Select Case $iError = 1 MsgBox(0, "Error Message", " Invalid $sType ") Case $iError = 2 MsgBox(0, "Error Message", " Invalid $sStartDate ") Case $iError = 3 MsgBox(0, "Error Message", " Invalid $sEndDate ") EndSelect EndIf EndIf EndFunc ;==>_AddressChanged Func _Chek4HTMfile() If Not FileExists(@WorkingDir & "Trak.HTM") Then FileInstall("Trak2.HTM", @WorkingDir & "Trak.HTM", 0) _ReplaceStringInFile(@WorkingDir & "Trak.HTM", "StartDateTime", $dStartTime, 0, 0) EndIf If Not FileExists(@WorkingDir & "InConMon.INI") Then FileInstall("InConMon2.INI", @WorkingDir & "InConMon.INI", 1) EndIf $dLastCycleDate = $dStartTime EndFunc ;==>_Chek4HTMfile Func _CompareIpAddr() $PublicIP = _GetIP() If $PublicIP = -1 Then $PublicIP = "None" $iPrintProcessLog = 1 EndIf $sLastIpAddr = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastIpAddr", "None") If $PublicIP = $sLastIpAddr Then $sIpConn = "OK" If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 Else $sIpConn = "" $iPrintProcessLog = 1 _AddressChanged() EndIf EndFunc ;==>_CompareIpAddr Func _CreateINI() IniWrite(@WorkingDir & "InConMon.INI", "Start", "LogStarted", $dLogStarted) IniWrite(@WorkingDir & "InConMon.INI", "Start", "MaxRows", "20") $dLogStarted = IniRead(@WorkingDir & "InConMon.INI", "Last", "LogStarted", "") If $dLogStarted = "" Then $dLogStarted = _NowCalc() IniWrite(@WorkingDir & "InConMon.INI", "Start", "LogStarted", $dLogStarted) EndIf $dYrMoDa = @YEAR & "-" & @MON & "-" & @MDAY IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastYrMoDa", $dYrMoDa) IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastCycleDate", $dLastCycleDate) $PublicIP = _GetIP() IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastIpAddr", "Startup") IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", $dLogStarted) IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastCycleDate", $dLastCycleDate) IniWrite(@WorkingDir & "InConMon.INI", "Last", "CycleCount", "1") IniWrite(@WorkingDir & "InConMon.INI", "Last", "ChgCount", "1") IniWrite(@WorkingDir & "InConMon.INI", "Interval", "ShortInterval", "2") IniWrite(@WorkingDir & "InConMon.INI", "Interval", "MediumInterval", "6") IniWrite(@WorkingDir & "InConMon.INI", "Interval", "LongInterval", "15") IniWrite(@WorkingDir & "InConMon.INI", "Cumulative", "ChgCntFromStart", "0") IniWrite(@WorkingDir & "InConMon.INI", "Cumulative", "CycleCntFromStart", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "MonChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownSecs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownSecs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownChgs", "0") IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownSecs", "0") EndFunc ;==>_CreateINI Func _DaySubTotal() $iPrintProcessLog = 1 $iTodayChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "TodayChgs", "") If $iTodayChgs = 0 Then If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 Return EndIf $sTrakHtm = "<tr>" & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#00FFCC"><font size="4"><b>Daily' & @CR $sTrakHtm = $sTrakHtm & 'Subtotal<br>' & @CR $sTrakHtm = $sTrakHtm & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & $dLastYrMoDa & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#00FFCC"><font size="4"><b>Changes Today<br>' & @CR $sTrakHtm = $sTrakHtm & "Ttl. = " & $iTodayChgs & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & " Down = " & $iTodayDownChgs & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#00FFCC"><font size="4"><b>Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(seconds)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma($iTodayDownSecs) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#00FFCC"><font size="4"><b>Average Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(down secs/down chgs)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma(Round(($iTodayDownSecs / $iTodayDownChgs), 1)) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '</tr>' & @CR _WriteToLog() $sTrakHtm = "" $iTodayDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownChgs", $iTodayDownChgs) $iTodayDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayDownSecs", $iTodayDownSecs) $iTodayChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "TodayChgs", $iTodayChgs) If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndFunc ;==>_DaySubTotal Func _WeekSubTotal() $iPrintProcessLog = 1 $iWeekChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "WeekChgs", "") If $iWeekChgs = 0 Then If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 Return EndIf $sTrakHtm = "<tr>" & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#FFCCFF"><font size="4"><b>Weekly' & @CR $sTrakHtm = $sTrakHtm & 'Subtotal<br>' & @CR $sTrakHtm = $sTrakHtm & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & $dLastYrMoDa & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#FFCCFF"><font size="4"><b>Changes Week<br>' & @CR $sTrakHtm = $sTrakHtm & " Ttl. = " & $iWeekChgs & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & " Down = " & $iWeekDownChgs & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#FFCCFF"><font size="4"><b>Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(seconds)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma($iWeekDownSecs) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#FFCCFF"><font size="4"><b>Average Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(down secs/down chgs)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma(Round(($iWeekDownSecs / $iWeekDownChgs), 1)) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '</tr>' & @CR _WriteToLog() $sTrakHtm = "" $iWeekDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownChgs", $iWeekDownChgs) $iWeekDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekDownSecs", $iWeekDownSecs) $iWeekChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "WeekChgs", $iWeekChgs) If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndFunc ;==>_WeekSubTotal Func _MonSubTotal() $iPrintProcessLog = 1 $iMonChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "MonChgs", "") If $iMonChgs = 0 Then If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 Return EndIf $sTrakHtm = "<tr>" & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#CCFF33"><font size="4"><b>Monthly' & @CR $sTrakHtm = $sTrakHtm & 'Subtotal<br>' & @CR $sTrakHtm = $sTrakHtm & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & $dLastYrMoDa & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#CCFF33"><font size="4"><b>Changes Mon<br>' & @CR $sTrakHtm = $sTrakHtm & " Ttl. = " & $iMonChgs & '<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & " Down = " & $iMonDownChgs & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#CCFF33"><font size="4"><b>Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(seconds)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma($iMonDownSecs) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '<td width="20%" align="center" bgcolor="#CCFF33"><font size="4"><b>Average Down Time<br>' & @CR $sTrakHtm = $sTrakHtm & '(down secs/down chgs)<br>' & @CR $sTrakHtm = $sTrakHtm & '</b>' & @CR $sTrakHtm = $sTrakHtm & _StringAddComma(Round(($iMonDownSecs / $iMonDownChgs), 1)) & '</font></td>' & @CR $sTrakHtm = $sTrakHtm & '</tr>' & @CR _WriteToLog() $sTrakHtm = "" $iMonDownChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownChgs", $iMonDownChgs) $iMonDownSecs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonDownSecs", $iMonDownSecs) $iMonChgs = 0 IniWrite(@WorkingDir & "InConMon.INI", "History", "MonChgs", $iMonChgs) If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndFunc ;==>_MonSubTotal Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) ; JdeB's code $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @LF & 'File not found to attach: ' & $S_Files2Attach[$x] SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf EndFunc ;==>_INetSmtpMailCom Func _WriteCyclTime() $sLogMsg = " Cumulative Cycle Time (" & Round($iCycleTime, 4) & ") Divided by " & $iCycleTimeCnt & " Cycles = " & Round(($iCycleTime / $iCycleTimeCnt), 4) & " Seconds per Cycle. " _FileWriteLog(@WorkingDir & "TimingLog.log", $sLogMsg) $iCycleTime = 0 $iCycleTimeCnt = 0 $dif = 0 EndFunc ;==>_WriteCyclTime Func _NextCycle() $iCycleCount = $iCycleCount + 1 IniWrite(@WorkingDir & "InConMon.INI", "Last", "CycleCount", $iCycleCount) $iCycleCntFromStart = $iCycleCntFromStart + 1 IniWrite(@WorkingDir & "InConMon.INI", "Cumulative", "CycleCntFromStart", $iCycleCntFromStart) _CompareIpAddr() If $dLastYrMoDa <> $dYrMoDa And $sLastIpAddr <> "Startup" Then ; Process subtotals... If $iTodayChgs > 0 Then ; Daily subtotal... $iPrintProcessLog = 1 _DaySubTotal() If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndIf If @WDAY = "1" And $iWeekChgs > 0 Then ; Wekly subtotal... $iPrintProcessLog = 1 _WeekSubTotal() If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndIf If @MDAY = "01" And $iMonChgs > 0 Then ; Monthly subtotal... $iPrintProcessLog = 1 _MonSubTotal() If $iPrintProcessLog = 1 Then $iPrintProcessLog = 0 EndIf IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastYrMoDa", $dYrMoDa) $dLastYrMoDa = $dYrMoDa EndIf ; Begin end of cycle time processing. If $iCycleTimeCnt <> 0 Then $dif = TimerDiff($begin) / 1000 If $iCycleTimeCnt <> 0 Then $iCycleTime = $iCycleTime + $dif $iCycleTimeCnt = $iCycleTimeCnt + 1 If $iChgCycleFlg = 1 Then $iIPchgCycleTimeCnt = $iIPchgCycleTimeCnt + 1 $iChgCycleFlg = 0 $iChgTime = $iChgTime + $dif If $iChgTime > 20 Then _FileWriteLog(@WorkingDir & "ChgCycleTime.log", $iChgTime & @TAB & $iIPchgCycleTimeCnt) $iChgTime = 0 $iIPchgCycleTimeCnt = 0 EndIf EndIf $iInterval = 500 If $iCycleTimeCnt > $iInterval And $iCycleTime > 0 Then _WriteCyclTime() EndIf ; End of cycle time processing. ;MsgBox(0," Begin Sleep Code", " Line " & @ScriptLineNumber & " Begin Sleep Code, CycleCount = " & $iCycleCount) Select Case $iCycleCount < 200 ;2 sec Sleep($iShortInterval * 1000) Case $iCycleCount < 400 ;6 sec Sleep($iMediumInterval * 1000) Case Else ;15 sec Sleep($iLongInterval * 1000) EndSelect ;MsgBox(0," End of Sleep Code", " Line " & @ScriptLineNumber & " End of Sleep Code", 1 ) ; Begin cycle time recording. $begin = TimerInit() If $iCycleCount = 200 Or $iEmail = 1 Then $iEmail = 0 _PrepEmail() EndIf If $iRetry = 1 And $iCycleCount = 300 Then $iRetry = 0 _PrepEmail() If $iRetry = 0 Then While FileExists(@TempDir & "icm.err.log") FileDelete(@TempDir & "icm.err.log") WEnd EndIf EndIf IniWrite(@WorkingDir & "InConMon.INI", "Last", "LastCycleDate", $dDateTimeNow) EndFunc ;==>_NextCycle Func _PrepEmail() $as_Body = FileRead(@WorkingDir & "Trak.HTM", FileGetSize(@WorkingDir & "Trak.HTM")) Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ;################################## ; Include JdeB's code ;################################## #Include<file.au3> ;################################## ; Variables ;################################## $s_SmtpServer = "smtp.gmail.com" ; address for the smtp-server to use - REQUIRED $s_FromName = " your name here " ; name from who the email was sent $s_FromAddress = "youracctname@gmail.com" ; address from where the mail should come $s_ToAddress = "youracctname@gmail.com" ; destination address of the email - REQUIRED $s_Subject = "IP Address change" ; subject from the email - can be anything you want it to be ;$as_Body = "The IP Address changed from " & $sLastIP & " to " & $PublicIP & " at 12:35." ; the messagebody from the mail - can be left blank but then you get a blank mail $s_AttachFiles = @TempDir & "icm.err.log" ; the file you want to attach- leave blank if not needed $s_CcAddress = "" ; address for cc - leave blank if not needed $s_BccAddress = "" ; address for bcc - leave blank if not needed $s_Username = "youracctname@gmail.com" ; username for the account used from where the mail gets sent - REQUIRED $s_Password = "password" ; password for the account used from where the mail gets sent - REQUIRED ; $IPPort = 25 ; port used for sending the mail ; $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $IPPort = 465 ; GMAIL port used for sending the mail $ssl = 1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS ;################################## ; Script ;################################## $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) If @error Then FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Error sending message, Error code:" & @error & " Description:" & $rc & @CRLF) ;MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) $iRetry = 1 Else While FileExists(@TempDir & "icm.err.log") FileDelete(@TempDir & "icm.err.log") WEnd $iRetry = 0 EndIf EndFunc ;==>_PrepEmail Func _ReadINI() $iMaxRows = IniRead(@WorkingDir & "InConMon.INI", "Start", "MaxRows", "15") $dLastYrMoDa = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastYrMoDa", "0") $sLastIpAddr = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastIpAddr", "") $dLastChgDate = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastChgDate", "") $dLastCycleDate = IniRead(@WorkingDir & "InConMon.INI", "Last", "LastCycleDate", "") $iCycleCount = IniRead(@WorkingDir & "InConMon.INI", "Last", "CycleCount", "") $iChgCount = IniRead(@WorkingDir & "InConMon.INI", "Last", "ChgCount", "") $iShortInterval = IniRead(@WorkingDir & "InConMon.INI", "Interval", "ShortInterval", "") $iMediumInterval = IniRead(@WorkingDir & "InConMon.INI", "Interval", "MediumInterval", "") $iLongInterval = IniRead(@WorkingDir & "InConMon.INI", "Interval", "LongInterval", "") $dLogStarted = IniRead(@WorkingDir & "InConMon.INI", "Start", "LogStarted", "") $iChgCntFromStart = IniRead(@WorkingDir & "InConMon.INI", "Cumulative", "ChgCntFromStart", "") $iCycleCntFromStart = IniRead(@WorkingDir & "InConMon.INI", "Cumulative", "CycleCntFromStart", "") $iMonChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "MonChgs", 0) $iMonDownChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "MonDownChgs", 0) $iMonDownSecs = IniRead(@WorkingDir & "InConMon.INI", "History", "MonDownSecs", 0) $iTodayChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "TodayChgs", 0) $iTodayDownChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "TodayDownChgs", 0) $iTodayDownSecs = IniRead(@WorkingDir & "InConMon.INI", "History", "TodayDownSecs", 0) $iWeekChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "WeekChgs", 0) $iWeekDownChgs = IniRead(@WorkingDir & "InConMon.INI", "History", "WeekDownChgs", 0) $iWeekDownSecs = IniRead(@WorkingDir & "InConMon.INI", "History", "WeekDownSecs", 0) EndFunc ;==>_ReadINI Func _WriteToLog() $iResponse = _FileWriteToLine(@WorkingDir & "Trak.HTM", 59, $sTrakHtm, 0) $iError = @error $sTrakHtm = "" Select Case $iError = 0 Case $iError = 1 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - File has too few lines. " & @CRLF) Case $iError = 2 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - Log file does not exist in working folder. " & @CRLF) Case $iError = 3 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - Error when opening the log file. " & @CRLF) Case $iError = 4 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - The location in the file where text to be added to the log is invalid. " & @CRLF) Case $iError = 5 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - The OverWrite flag is invalid. " & @CRLF) Case $iError = 6 FileWrite(@TempDir & "icm.err.log", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Log File Write Error Msg - The text to be added to the log is invalid. " & @CRLF) EndSelect EndFunc ;==>_WriteToLog ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFuncVer. 1.104 had 6 downloads. Edited February 28, 2007 by Gene [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...
Moderators SmOke_N Posted February 25, 2007 Moderators Posted February 25, 2007 (edited) How about some codebox tags there tiger? Edit: Still think you need codebox tags... but just to let you know, the above doesn't copy and paste well, you may just consider using the zip you provided... for some reason, the code is 30 lines longer with what you posted than what is in the zip (didn't really bother to look.) The code does look interesting though, kudos on that... something that jumped out at me was the fileinstall though. Since you provided the .html etc... with the script, you may want to change your fileinstalls from: Example: FileInstall("K:\My Documents\_Dev\_Projects\InternetConnectionMonitor\Trak2.HTM", @WorkingDir & "\Trak.HTM", 0)oÝ÷ Ù:ºÚ"µÍ[R[Ý[ ][ÝÕZÌI][ÝËÛÜÚ[Ñ [È ][ÝÉÌLÕZËI][ÝË, I'm sure it would error far less for people. Edited February 25, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Gene Posted February 25, 2007 Author Posted February 25, 2007 (edited) How about some codebox tags there tiger? Edit: Still think you need codebox tags... but just to let you know, the above doesn't copy and paste well, you may just consider using the zip you provided... for some reason, the code is 30 lines longer with what you posted than what is in the zip (didn't really bother to look.) Sorry about the tags, I didn't realize at first that I had used the wrong tags. I uploaded a new ZIP file. The code does look interesting though, kudos on that... something that jumped out at me was the fileinstall though. Since you provided the .html etc... with the script, you may want to change your fileinstalls from: Example: FileInstall("K:\My Documents\_Dev\_Projects\InternetConnectionMonitor\Trak2.HTM", @WorkingDir & "\Trak.HTM", 0)oÝ÷ Ù:ºÚ"µÍ[R[Ý[ ][ÝÕZÌI][ÝËÛÜÚ[Ñ [È ][ÝÉÌLÕZËI][ÝË, I'm sure it would error far less for people.It is interesting, but far longer than expected when I started it. I thought you had to give explicit paths to FileInstalls, or did you mean in uploaded scripts. H'mmmn, the Help file doesn't actually say that, I think I just assumed it from the Help file example script. I still plan to add a traymenu to it for easier configuration. In addition to the present INI file it will allow the user to set the "To:" name(s) and Address, the "From:" will continue to be hard coded. Edited February 25, 2007 by Gene [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...
Moderators SmOke_N Posted February 25, 2007 Moderators Posted February 25, 2007 Sorry about the tags, I didn't realize at first that I had used the wrong tags. I uploaded a new ZIP file. It is interesting, but far longer than expected when I started it.I didn't mean the [ AutoIt] [ /AutoIt] code tags, I meant something like: [ codebox][ AutoIt] script [ /codebox][ /AutoIt] (without spaces that is)... This will put the script in a scroll box and wrap it in AutoIt syntax. I thought you had to give explicit paths to FileInstalls, or did you mean in uploaded scripts. H'mmmn, the Help file doesn't actually say that, I think I just assumed it from the Help file example script.I was doing full path for quite some time until recently... I believe MHZ pointed it out to me that as long as it's in the same directory as the script there is no issue. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Valik Posted February 27, 2007 Posted February 27, 2007 (edited) Alright, Gene, post split from the previous topic. Edited February 27, 2007 by Valik Typo.
Gene Posted February 27, 2007 Author Posted February 27, 2007 Alright, Gene, post split from the previous topic.Thank you Valik!Gene [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...
James Posted February 27, 2007 Posted February 27, 2007 Can you make the first post text smaller please? This works well for my Dad Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Gene Posted February 27, 2007 Author Posted February 27, 2007 Can you make the first post text smaller please? This works well for my Dad I can read size 2 and above just fine. If I remember from your Valik Avatar thread correctly, I'm probably older than your Dad. My Avatar shows how old I feel. Gene [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...
WeMartiansAreFriendly Posted February 27, 2007 Posted February 27, 2007 I can read size 2 and above just fine. If I remember from your Valik Avatar thread correctly, I'm probably older than your Dad. My Avatar shows how old I feel. Geneyou know maturity doesn't always come along with age. btw nice script. Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
McGod Posted February 27, 2007 Posted February 27, 2007 So it will check to see how often your internet goes out? Looks good, my ISP sucks really bad. I need to make sure its them though:/ [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u]
Gene Posted February 27, 2007 Author Posted February 27, 2007 you know maturity doesn't always come along with age. btw nice script.I try hard to avoid too much maturity, most people wear it poorly.Thanks for the script comment.Gene [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...
Gene Posted February 27, 2007 Author Posted February 27, 2007 So it will check to see how often your internet goes out? Looks good, my ISP sucks really bad. I need to make sure its them though:/It does do that, and produces an HTML log file with the latest data at the top of the list, so you don't have to spend a lot of time scrolling down to see what has been happening lately. It puts in column headers every X number of rows (you can change X in the INI) MaxRows=20 is the default. For each day/week/month that IP Address changes occur it inserts a Total Row for the appropriate time unit.That row shows the current date, thenumber of IP Address changes including downtime changes, thenumber of times the connection went down, theamount of downtime in seconds and theaverage number of seconds per time down.If you have a gmail account and configure Jdeb's Send Mail UDF, you can run it on another PC/Server on your network and each time MaxRows is reached, it will send you an emai. No email = nothing serious going on with your connection.Gene [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...
dyerseve Posted August 20, 2013 Posted August 20, 2013 Very nice script but as it was created long ago not surprised that it isn't working perfectly. After doing some digging the problem is that _getip uses inetget in default cached mode. So when I simulate a brief outage, sometimes it works but most of the time getip continues to return a valid ip because the webpage is still cached. So for day, week, month type outages it would be ok, but it isn't quite accurate for by the second outages. I can't seem to find any documentation indicating how long the pages are cached for... I considered adjusting it to do a non-cached inetget but I'm afraid the website would block me after so many abusive retrievals so I'll have to work something else out, maybe query a server I own so I can't be considered abusing it.
James Posted August 20, 2013 Posted August 20, 2013 I considered adjusting it to do a non-cached inetget but I'm afraid the website would block me after so many abusive retrievals so I'll have to work something else out, maybe query a server I own so I can't be considered abusing it. You could setup several free Heroku instances which you could ping? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now