Skip to content

Commit

Permalink
WARNING: latest handshake: never
Browse files Browse the repository at this point in the history
Return WARNING if some peer never handshake yet.
  • Loading branch information
dsh2dsh committed Mar 29, 2024
1 parent 1c1176d commit b3e87b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ CRITICAL: latest handshake is outside of CRITICAL threshold
peer: 10.0.0.4/32
latest handshake: 188016s ago
threshold: 180000s | 'latest handshake'=188016s;300;180000;;
$ check_wg handshake wg show wg0 dump
WARNING: latest handshake: never
peer: 10.0.0.4/32
```

```
Expand Down
12 changes: 12 additions & 0 deletions cmd/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func handshakeResponse(dump *wg.Dump, resp *monitoringplugin.Response) error {
peer := dump.OldestHandshake()
if peer == nil {
return errors.New("no valid peer found")
} else if checkNeverHandshake(peer, resp) {
return nil
}

d := time.Since(peer.LatestHandshake).Truncate(time.Second)
Expand Down Expand Up @@ -68,3 +70,13 @@ func handshakeResponse(dump *wg.Dump, resp *monitoringplugin.Response) error {
}
return nil
}

func checkNeverHandshake(peer *wg.DumpPeer, resp *monitoringplugin.Response,
) bool {
if !peer.LatestHandshake.IsZero() {
return false
}
resp.UpdateStatus(monitoringplugin.WARNING, "latest handshake: never")
resp.UpdateStatus(monitoringplugin.WARNING, "peer="+peer.Name())
return true
}

0 comments on commit b3e87b4

Please sign in to comment.