Skip to content

Commit 4d55519

Browse files
committed
Add error message when system's ping fail
1 parent 970c63f commit 4d55519

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

display.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ func (d *Display) Update() {
5151
for _, wrapper := range d.pwh.ping_wrappers {
5252
sb.WriteString(fmt.Sprintf(d.host_format_string, wrapper.Host()))
5353
stats := wrapper.CalcStats(2 * 1e9)
54-
if stats.last_seen_nano > 2*1e9 {
54+
if stats.error_message != "" {
55+
sb.WriteString(bold_red.Sprintf("❌ %v", stats.error_message))
56+
} else if stats.last_seen_nano > 2*1e9 {
5557
if stats.lastrecv == 0 {
5658
sb.WriteString(bold_red.Sprintf("❌ never had reply"))
5759
} else {

pinger_system.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func (w *SystemPingWrapper) Start() {
5656
w.stats.lastrtt_as_string = extracted[0][1] + extracted[0][2]
5757
}
5858
}
59+
w.stats.error_message = fmt.Sprintf("%v exited code %v", w.cmd.String(), w.cmd.ProcessState.ExitCode())
5960
}()
6061
w.cmd.Start()
6162
}

pwstats.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type PWStats struct {
1919
has_ever_received bool
2020
startup_time int64
2121
transition_writer *TransitionWriter
22+
error_message string
2223
hrepr string
2324
iprepr string
2425
}

0 commit comments

Comments
 (0)