trademaid Posted February 17, 2010 Posted February 17, 2010 ; please feel free to use and or improve this. ; it monitors two ip address's expandcollapse popup#include <Math.au3> #include <Process.au3> #include <Inet.au3> #comments-start this is to log internet connectivity. It works but need more work ie wont find Request timed out or "Ping request could not find" file p1.txt contains typcailly we extract the time = xyz MS and alerm if this figure gets over 99 we play alarm file Pinging sip.vic.iinet.com.au [203.55.229.194] with 1 bytes of data: Reply from 203.55.229.194: bytes=1 time=14ms TTL=61 Reply from 203.55.229.194: bytes=1 time=13ms TTL=61 Ping statistics for 203.55.229.194: Packets: Sent = 2, Received = 2, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 13ms, Maximum = 14ms, Average = 13ms fileout contains log ie 20100216:234554 203.217.23.28:: 27ms 20100216:234554 203.55.229.194: 14ms #comments-end DirCreate("c:\1") While 1 $rc2 = _RunDOS("ping sip.vic.iinet.com.au -n 2 -l 1 >c:\1\p1.txt") $rc = _RunDOS("ping google.com -n 2 -l 1 >c:\1\p2.txt") ;Sleep(1150) $fin = "c:\1\p2.txt" $file = FileOpen($fin, 0) $fileout = "c:\1\pingout2.txt" $line = FileReadLine($file, 7); $location2 = StringInStr($line, " ", 0, 2); look for 2 th space $location3 = StringInStr($line, " ", 0, 3); look for 3 th space ;ConsoleWrite($location3 - $location2 & @CRLF) If $location3 - $location2 = 15 Then $line = StringReplace($line, ":", "::") ; pad the line so lengthis the same regardless of ip address $result = StringInStr($line, "Request timed out") ;ConsoleWrite($result & @CRLF) $result = StringInStr($line, "Ping request could not find") ; line one only. not coded yet. its on the first line ? if it occurs ;ConsoleWrite($result & @CRLF) $numreplacements = @extended ; MsgBox(0, "New string is", $text) ;MsgBox(0, "The number of replacements done was", $numreplacements) EndIf; $location0 = StringInStr($line, "=", 0, 2) + 1; look for 2 th space $location = StringInStr($line, " ", 0, 5) - 2; look for 5 th space ;consolewrite($location0 & @crlf) ; mid = number of millsec in ping if > 99 then alarm $mid = StringMid($line, $location0, $location - $location0) ConsoleWrite($line & @CRLF) $line = StringReplace($line, "Reply from", "") ; remove Reply from ConsoleWrite($line & @CRLF) $line = StringReplace($line, "bytes=1 time=", "") ; remove bytes=1 time= $line = StringLeft($line, StringLen($line) - 6) ;remove right side to remove ttl=xy ConsoleWrite($line & @CRLF) FileWriteLine($fileout, @YEAR & @MON & @MDAY & ":" & @HOUR & @MIN & @SEC & " " & $line); & " _ " & $mid) FileClose($fileout) If $mid > 99 Then ConsoleWrite("mic:" & $mid & @CRLF) SoundPlay("c:\alertmon\ahooga-ideal.wav") MsgBox(1, $line, $mid, 1) EndIf ;$fileclose("c:\1\pingout1.txt") $fin2 = "c:\1\p1.txt" $file2 = FileOpen($fin2, 0) $line2 = FileReadLine($file2, 9); ConsoleWrite($line2 & @CRLF) $location2 = StringInStr($line2, " ", 0, 2); look for 2 th space $location3 = StringInStr($line2, " ", 0, 3); look for 3 th space ;ConsoleWrite($location3 - $location2 & @CRLF) $location0 = StringInStr($line2, "=", 0, 2) + 1; look for 2 th space $location = StringInStr($line2, " ", 0, 5) - 2; look for 5 th space $location = StringInStr($line2, " ", 0, 5) - 2; look for 5 th space $mid = StringMid($line2, $location0, $location - $location0) $line2 = StringReplace($line2, "Reply from", "") ; remove Reply from ConsoleWrite($line2 & @CRLF) $line2 = StringReplace($line2, "bytes=1 time=", "") ; remove bytes=1 time= ConsoleWrite($line2 & @CRLF) $line2 = StringLeft($line2, StringLen($line2) - 6) ;remove right side to remove ttl=xy FileWriteLine($fileout, @YEAR & @MON & @MDAY & ":" & @HOUR & @MIN & @SEC & " " & $line2 );& " + " & $mid) FileClose($fileout) If $mid > 99 Then SoundPlay("c:\alertmon\ahooga-ideal.wav") MsgBox(1, $line, $mid, 1) EndIf WEnd
MrMitchell Posted February 19, 2010 Posted February 19, 2010 There is a built-in Ping() function, why not use it? ; please feel free to use and or improve this. ; it monitors two ip address's expandcollapse popup#include <Math.au3> #include <Process.au3> #include <Inet.au3> #comments-start this is to log internet connectivity. It works but need more work ie wont find Request timed out or "Ping request could not find" file p1.txt contains typcailly we extract the time = xyz MS and alerm if this figure gets over 99 we play alarm file Pinging sip.vic.iinet.com.au [203.55.229.194] with 1 bytes of data: Reply from 203.55.229.194: bytes=1 time=14ms TTL=61 Reply from 203.55.229.194: bytes=1 time=13ms TTL=61 Ping statistics for 203.55.229.194: Packets: Sent = 2, Received = 2, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 13ms, Maximum = 14ms, Average = 13ms fileout contains log ie 20100216:234554 203.217.23.28:: 27ms 20100216:234554 203.55.229.194: 14ms #comments-end DirCreate("c:\1") While 1 $rc2 = _RunDOS("ping sip.vic.iinet.com.au -n 2 -l 1 >c:\1\p1.txt") $rc = _RunDOS("ping google.com -n 2 -l 1 >c:\1\p2.txt") ;Sleep(1150) $fin = "c:\1\p2.txt" $file = FileOpen($fin, 0) $fileout = "c:\1\pingout2.txt" $line = FileReadLine($file, 7); $location2 = StringInStr($line, " ", 0, 2); look for 2 th space $location3 = StringInStr($line, " ", 0, 3); look for 3 th space ;ConsoleWrite($location3 - $location2 & @CRLF) If $location3 - $location2 = 15 Then $line = StringReplace($line, ":", "::") ; pad the line so lengthis the same regardless of ip address $result = StringInStr($line, "Request timed out") ;ConsoleWrite($result & @CRLF) $result = StringInStr($line, "Ping request could not find") ; line one only. not coded yet. its on the first line ? if it occurs ;ConsoleWrite($result & @CRLF) $numreplacements = @extended ; MsgBox(0, "New string is", $text) ;MsgBox(0, "The number of replacements done was", $numreplacements) EndIf; $location0 = StringInStr($line, "=", 0, 2) + 1; look for 2 th space $location = StringInStr($line, " ", 0, 5) - 2; look for 5 th space ;consolewrite($location0 & @crlf) ; mid = number of millsec in ping if > 99 then alarm $mid = StringMid($line, $location0, $location - $location0) ConsoleWrite($line & @CRLF) $line = StringReplace($line, "Reply from", "") ; remove Reply from ConsoleWrite($line & @CRLF) $line = StringReplace($line, "bytes=1 time=", "") ; remove bytes=1 time= $line = StringLeft($line, StringLen($line) - 6) ;remove right side to remove ttl=xy ConsoleWrite($line & @CRLF) FileWriteLine($fileout, @YEAR & @MON & @MDAY & ":" & @HOUR & @MIN & @SEC & " " & $line); & " _ " & $mid) FileClose($fileout) If $mid > 99 Then ConsoleWrite("mic:" & $mid & @CRLF) SoundPlay("c:\alertmon\ahooga-ideal.wav") MsgBox(1, $line, $mid, 1) EndIf ;$fileclose("c:\1\pingout1.txt") $fin2 = "c:\1\p1.txt" $file2 = FileOpen($fin2, 0) $line2 = FileReadLine($file2, 9); ConsoleWrite($line2 & @CRLF) $location2 = StringInStr($line2, " ", 0, 2); look for 2 th space $location3 = StringInStr($line2, " ", 0, 3); look for 3 th space ;ConsoleWrite($location3 - $location2 & @CRLF) $location0 = StringInStr($line2, "=", 0, 2) + 1; look for 2 th space $location = StringInStr($line2, " ", 0, 5) - 2; look for 5 th space $location = StringInStr($line2, " ", 0, 5) - 2; look for 5 th space $mid = StringMid($line2, $location0, $location - $location0) $line2 = StringReplace($line2, "Reply from", "") ; remove Reply from ConsoleWrite($line2 & @CRLF) $line2 = StringReplace($line2, "bytes=1 time=", "") ; remove bytes=1 time= ConsoleWrite($line2 & @CRLF) $line2 = StringLeft($line2, StringLen($line2) - 6) ;remove right side to remove ttl=xy FileWriteLine($fileout, @YEAR & @MON & @MDAY & ":" & @HOUR & @MIN & @SEC & " " & $line2 );& " + " & $mid) FileClose($fileout) If $mid > 99 Then SoundPlay("c:\alertmon\ahooga-ideal.wav") MsgBox(1, $line, $mid, 1) EndIf WEnd
trademaid Posted February 21, 2010 Author Posted February 21, 2010 There is a built-in Ping() function, why not use it?that would have saved me a lot of work.one thing is i dont know how many bytes the autout ping fuction uses.Does anyone know?I set my dos ping to 1 byte, as I want to use minimal bandwidth.
Fire Posted February 21, 2010 Posted February 21, 2010 May be i`m wrong. But it seems Ping() uses default packets byte size eq 32 byte. [size="5"] [/size]
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