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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.