Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

How can I monitor and log internet connectivity?

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
100questions
Asked:
100questions
  • 8
  • 5
  • 2
  • +2
1 Solution
 
KimputerCommented:
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
 
Dan CraciunIT ConsultantCommented:
For some years now I've replaced ping with hrping for 2 simple reasons: included timestamps and a graphical view.

HTH,
Dan
0
 
100questionsAuthor Commented:
@Kimputer - thanks.  Is there a way to include a time stamp?
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
KimputerCommented:
Easiest, is to use the tip above.

hrping -T -t server_ip > pinglog.txt
0
 
oBdACommented:
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
 
100questionsAuthor Commented:
@obda - thanks however it seems that the system requirements for the download are Windows Server 2003 and XP, none of which is available.
0
 
oBdACommented:
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
 
100questionsAuthor Commented:
@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
 
100questionsAuthor Commented:
@oBdA - Thanks.  I am concerned with licencing.  Windows Server 2003 or XP are not being used.
0
 
oBdACommented:
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
 
Dan CraciunIT ConsultantCommented:
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
 
100questionsAuthor Commented:
@oBDA- Thanks.  Is this batch or vbs?
0
 
100questionsAuthor Commented:
@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
 
oBdACommented:
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
 
100questionsAuthor Commented:
@oBdA - Thanks.   Ok, and does it keep a log when there are disconnects in the internet then, the Down times?
0
 
oBdACommented:
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
 
Steve KnightIT ConsultancyCommented:
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
 
100questionsAuthor Commented:
Thanks.
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

  • 8
  • 5
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now