Solved

How can I monitor and log internet connectivity?

Posted on 2014-12-03
18
150 Views
Last Modified: 2014-12-10
I would like to monitor internet connectivity, since I suspect that the internet is cutting out thus causing online backup jobs to fail.
Apart from checking server logs etc, is there a script or a free program which would allow me to check for continuous internet connectivity, and log it, so I can look back to see if there was an interruption of some sort?
A log is necessary to look back on, and perhaps any other information the log can provide me which could help me determine if there was an interruption.
0
Comment
Question by:100questions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 2
  • +2
18 Comments
 
LVL 36

Expert Comment

by:Kimputer
ID: 40478779
Simplest for now, is just use this:

ping server -t > pinglog.txt

This is the most basic thing to check, and checks if internet connectivity stays up and running.
You could make a more fancy one (with date/time stamp) if necessary.

Of course this might not be enough, as many things can fail (maybe the server stays online, but only the service goes down). But that's for later. First try this.

No time-outs > service was down, not the internet
time-outs > somewhere, connectivity was interrupted, Question is of course, where ? Local server, switch, router, internet provider, or remote server. Therefore, more pings are required, to every single node I just mentioned.

As you can see, a lot more work is waiting.
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 40478799
For some years now I've replaced ping with hrping for 2 simple reasons: included timestamps and a graphical view.

HTH,
Dan
0
 

Author Comment

by:100questions
ID: 40478811
@Kimputer - thanks.  Is there a way to include a time stamp?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 36

Expert Comment

by:Kimputer
ID: 40478829
Easiest, is to use the tip above.

hrping -T -t server_ip > pinglog.txt
0
 
LVL 85

Expert Comment

by:oBdA
ID: 40478868
Here's a small batch I use for continuous ping; it uses sleep.exe from http://www.microsoft.com/en-us/download/details.aspx?id=17657 (no need to install the ResKit if you have 7-Zip - just unpack rktools.msi, then unpack sleep.exe from rktools.msi and put it into the script's folder). An alternative is to replace line 28 with "ping.exe -n 2 localhost >NUL".
The script only logs status changes, so only the times when the connection drops and when it comes back.
@echo off
setlocal
mode con cols=40 lines=25
if "%~1"=="" (
	set /p IP=Name oder IP: 
) else (
	set IP=%~1
)
title Ping %IP%
set LogFile=%~dpn0-%IP%.log
set Lost=X
:loop
ping.exe -n 1 %IP% | find /i "TTL" >NUL
if errorlevel 1 (
	if not %Lost%==1 (
		color 4F
		echo - Down: %Date% %Time: =0%
		>>"%LogFile%" echo - %Date% %Time%
		set Lost=1
	) 
) else (
	if not %Lost%==0 (
		color 2F
		echo + Up: %Date% %Time: =0%
		>>"%LogFile%" echo + %Date% %Time%
		set Lost=0
	)
	"%~dp0sleep.exe" -m 1000
)
goto :loop

Open in new window

0
 

Author Comment

by:100questions
ID: 40478932
@obda - thanks however it seems that the system requirements for the download are Windows Server 2003 and XP, none of which is available.
0
 
LVL 85

Expert Comment

by:oBdA
ID: 40478951
As I said, you have two options:
* You can download it (download is possible just fine on Windows 7), then extract the first the msi from the exe, then sleep.exe from the msi using 7-Zip. You could even install it anyway on a test machine (I have it installed on Windows 7), it mainly unpacks a bunch of tools into C:\Program Files (x86)\Windows Resource Kits\Tools) and then copy sleep.exe into the script's folder.
Or you can replace line 28 in the script (where currently sleep.exe is called) with "ping.exe -n 2 localhost >NUL" (minus the quotes, of course).
0
 

Author Comment

by:100questions
ID: 40478952
@kimputer - when I try using hrping and clicking on it nothing happens, no graphical interface.. it creates a log file but I have no idea if it's running..
0
 

Author Comment

by:100questions
ID: 40478956
@oBdA - Thanks.  I am concerned with licencing.  Windows Server 2003 or XP are not being used.
0
 
LVL 85

Accepted Solution

by:
oBdA earned 500 total points
ID: 40478961
Then use this version:
@echo off
setlocal
mode con cols=40 lines=25
if "%~1"=="" (
	set /p IP=Name oder IP: 
) else (
	set IP=%~1
)
title Ping %IP%
set LogFile=%~dpn0-%IP%.log
set Lost=X
:loop
ping.exe -n 1 %IP% | find /i "TTL" >NUL
if errorlevel 1 (
	if not %Lost%==1 (
		color 4F
		echo - Down: %Date% %Time: =0%
		>>"%LogFile%" echo - %Date% %Time%
		set Lost=1
	) 
) else (
	if not %Lost%==0 (
		color 2F
		echo + Up: %Date% %Time: =0%
		>>"%LogFile%" echo + %Date% %Time%
		set Lost=0
	)
	ping.exe -n 2 localhost >nul
)
goto :loop

Open in new window

0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 40478962
hrping behaves exactly like ping. You don't double click on it, you open a command prompt, then type the name and options, then press enter.
grping is the graphic view, and you invoke it from command line with the -g option, if I'm not mistaken.

You'll find a hrping.txt file in the archive you downloaded, which is basically the manual for the utility.
0
 

Author Comment

by:100questions
ID: 40478969
@oBDA- Thanks.  Is this batch or vbs?
0
 

Author Comment

by:100questions
ID: 40478980
@oBDA - thanks it works as a batch file.  How will I know if the connection is cut for some reason, will it log it.  When I started it it says Up..  does that mean it's working fine, and there are no connectivity issues?
0
 
LVL 85

Expert Comment

by:oBdA
ID: 40478992
The script will create a log file as <script name><target name>.log in its folder, so if the script is called Whatever.cmd and you ping google.com, the log file will be "Whatever-google.com.log".
"Up" and the green background (in the log file, it's a simple "+") means that it currently pings successfully; "Down" and the red background (a "-" in the log file) means the ping is currently lost.
0
 

Author Comment

by:100questions
ID: 40479007
@oBdA - Thanks.   Ok, and does it keep a log when there are disconnects in the internet then, the Down times?
0
 
LVL 85

Expert Comment

by:oBdA
ID: 40479031
Yes, as I said; it will log (only) the times when a connection changes status, that is, a ping is lost after a successful ping, or a ping is successful after a failed ping. So a log like this
+  12/1/2014 01:02:03
-  12/1/2014 02:03:04
+  12/1/2014 03:04:05

Open in new window

means that the connection was established at 01:02:03, was successful until 02:03:04 when it dropped, and it stayed dropped until 03:04:05 when it was established again.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40482454
I've got a few scripts of mine for monitoring here if you want to play, though I like oBdA's logging of a change in status only.

http://scripts.dragon-it.co.uk/links/batch-ping-list-of-hosts-3

If you search for "ping" there are 4-5 similar but different including emailing faults - what I tend to do is keep a log of faults then perioidcally it checks for that log and emails it:

http://scripts.dragon-it.co.uk/links/batch-monitor-ping-email

Steve
0
 

Author Closing Comment

by:100questions
ID: 40492369
Thanks.
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Synchronize a new Active Directory domain with an existing Office 365 tenant
A procedure for exporting installed hotfix details of remote computers using powershell
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question