Skip to content

Commit 2884131

Browse files
committed
Add timestamp to each ping result line
1 parent 6025e7a commit 2884131

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

Example1.png

-4.34 KB
Loading

Example2.png

17.1 KB
Loading

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ WinNetPulse is a lightweight **Windows network diagnostic CLI tool** written in
99

1010
It provides fast **Ping and Traceroute diagnostics** with real-time statistics and interactive controls.
1111

12-
Latest Version:1.2.1
12+
Latest Version:1.3
1313

1414
\## Features
1515

@@ -25,6 +25,8 @@ Latest Version:1.2.1
2525

2626
\- Real-time statistics
2727

28+
\- Timestamp for each result line
29+
2830
  - Min latency
2931

3032
  - Max latency
Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
<#
2-
#>
3-
4-
param()
1+
param()
52

63
function Show-Header {
74
Clear-Host
85
Write-Host "===============================" -ForegroundColor Cyan
9-
Write-Host " WinNetPulse v1.2.1" -ForegroundColor Green
6+
Write-Host " WinNetPulse v1.3" -ForegroundColor Green
107
Write-Host "===============================" -ForegroundColor Cyan
118
}
129

@@ -59,6 +56,10 @@ function Write-ColoredLatency($time, $text) {
5956
}
6057
}
6158

59+
function Get-TimeStamp {
60+
return (Get-Date).ToString("yyyy/MM/dd HH:mm:ss.ff")
61+
}
62+
6263
function Invoke-PingTest($target, $count) {
6364

6465
$min = [int]::MaxValue
@@ -81,6 +82,7 @@ function Invoke-PingTest($target, $count) {
8182
$sent++
8283

8384
$reply = Test-Connection -ComputerName $target -Count 1 -ErrorAction SilentlyContinue
85+
$ts = Get-TimeStamp
8486

8587
if ($reply) {
8688

@@ -93,13 +95,13 @@ function Invoke-PingTest($target, $count) {
9395

9496
$sum += $time
9597

96-
$text = "[$sent] ${time}ms TTL=$ttl"
98+
$text = "[$sent] ${time}ms TTL=$ttl [$ts]"
9799

98100
Write-ColoredLatency $time $text
99101
}
100102
else {
101103

102-
Write-Host "[$sent] Request timed out." -ForegroundColor Red
104+
Write-Host "[$sent] Request timed out. [$ts]" -ForegroundColor Red
103105
}
104106

105107
Start-Sleep -Seconds 1
@@ -112,6 +114,7 @@ function Invoke-PingTest($target, $count) {
112114
$sent++
113115

114116
$reply = Test-Connection -ComputerName $target -Count 1 -ErrorAction SilentlyContinue
117+
$ts = Get-TimeStamp
115118

116119
if ($reply) {
117120

@@ -124,13 +127,13 @@ function Invoke-PingTest($target, $count) {
124127

125128
$sum += $time
126129

127-
$text = "[$i/$count] ${time}ms TTL=$ttl"
130+
$text = "[$i/$count] ${time}ms TTL=$ttl [$ts]"
128131

129132
Write-ColoredLatency $time $text
130133
}
131134
else {
132135

133-
Write-Host "[$i/$count] Request timed out." -ForegroundColor Red
136+
Write-Host "[$i/$count] Request timed out. [$ts]" -ForegroundColor Red
134137
}
135138

136139
Start-Sleep -Seconds 1
@@ -178,7 +181,7 @@ function Run-PingMode {
178181

179182
$result = Invoke-PingTest $target $count
180183

181-
Write-Host "`n===== WinNetPulse Summary =====" -ForegroundColor Cyan
184+
Write-Host "`n===== NetPulse Summary =====" -ForegroundColor Cyan
182185

183186
Write-Host "Target: $($result.Target)"
184187

0 commit comments

Comments
 (0)