A really hackish way of detecting significant clock skew between hosts.
If you find this useful, I feel bad for you.
Requires agent based ssh access to all hosts.
go get github.com/lytics/skewer
skewer -hosts=host1,host2,host3,hostn
If you're running this from a server you're ssh'd into, you need to enable agent forwarding with either:
ssh -A remotehost
...or in your ~/.ssh/config
:
Host remotehost
ForwardAgent yes
Use the -alert
option to set a command to run (should be a shell script or
single binary) if clock skew is detected.
skewer -hosts=... -alert=/path/to/alert.sh
The $MAXSKEW
environment variable will be set to the maximum skew detected.
- Stores start time
- Runs date on each host via ssh concurrently
- Calculates elapsed time to run
- If
max(date)-min(date) > elapsed
output per host times and skews - Sleeps
-sleep
amount and runs again
Everything is in seconds resolution, so only skews of 2 seconds or greater will be reported.
If you want subsecond skew detection you need a more sophisticated tool.
Probably a lot of ways. Consider this a toy.
There's a lot of log.Fatalf
instead of more sophisticated error handling.