• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 52
  • Last Modified:

Test connectivity over a 24 hour period

Possible network problem.  I want to run a ping for 12 hours or so that will export the output of the results into a text file or analyzing.  I also want each line item of the ping to have the time on it when it was run.  I have seen some examples online but they are not working for me.  would like to use cmd prompt but am open to powershell if that is a better option.
could someone show me an example of this?
3 Solutions
Dave BaldwinFixer of ProblemsCommented:
You should know that 'ping' doesn't tell you that any other protocols like HTTP are working.  It does tell you that you have the basic connection working.  I've had a server that had nothing but 'ping' working.  No website, no email.
jamesmetcalf74Author Commented:
we think the network is dropping but can't pinpoint the times... I think the ping might be a good first step to knowing
Dave BaldwinFixer of ProblemsCommented:
It well could be if you are actually losing the connection.  I always feel a need to point out that ping doesn't check anything else.
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.

Dean ChafeeIT/InfoSec ManagerCommented:
Here is a .BAT that I use for this purpose:

@echo off
REM syntax:   pinglog hostip > pinglog.log
REM host ping log
echo %date% %time%
ping %1 -n 300
goto step1


it posts the date and time every 5 mins in the log file.
jamesmetcalf74Author Commented:
when I run that .bat logic... I get a ton of line items popping up saying.
the process cannot access the file because it is being used by another process
nociSoftware EngineerCommented:
try a different path.....:

ssh to a remote system, be sure to have a short keep-alive time. (ssh_config setting).
and to have some (low level) activity over the line (expect can help there).

The link will disconnect if broken for too long.. that can be logged, also reconnect immediately and log the connection failures....
absense of failures is a working connection.  (or at least a connection succeeded during the last 2 minutes).
If needed you can build a simple program that does exactly this...

The nagios tcp check might be of some help... (it doesn;t do keep alive so you may need a short loop run this more or less continously:

while  true
  /usr/lib/nagios/plugins/check_tcp -H yourHost -p 443 -m 100000 -S -D 10 -t 60 -d 60 -e "BLAH"

and analyze the output...
(No need to get whole nagio up & running, all plugins / sentinels can run separately., nagios just analyzes all output's of their sentinels).
Dr. KlahnPrincipal Software EngineerCommented:
If you have access to a linux machine (or a C compiler on the Windows system), try the code in this discussion.

Sajen JoseCommented:
You may want to use the below PowerShell Script

$StartTime = Get-Date
$EndTime = $StartTime.AddHours(12)

Write-Host "Start Time: $StartTime"
Write-Host "EndTime: $EndTime"

    $connection = Test-Connection -ComputerName localhost 
    foreach ($entry in $connection)
        $timestamp = $(Get-Date).ToString()
        $connection | Select-Object $timestamp, Address, ProtocolAddress, IPV4Address, IPV6Address, ResponseTime, ResponseTimeToLive, StatusCode  | Out-File TrackingFile.txt -Append
while ($(Get-Date) -le $EndTime)

Open in new window

Note: You will have to change the ComputerName param from LocalHost to the IP Address that you want to ping
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now