Solved

How can I monitor and log internet connectivity?

Posted on 2014-12-03
18
130 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
  • 8
  • 5
  • 2
  • +2
18 Comments
 
LVL 35

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 34

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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 35

Expert Comment

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

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

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 83

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 83

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 34

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 83

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 83

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now