What is the easiest way to discover some server downtime in seconds?
Im not sure, but there is one script that can help to discover that
please kindly share Your experience or other better ways to get seconds downtime of an server, thx
# ssh access key should be setup in order to connect without password prompts...
# empty countfile
This script will be connecting $serverip each second. Each successfull connection = 1 line in file named $pwd/count. You can run this script in "screen" and durng the runtime, see number of lines (1 second successfull connections) by command: wc -l $pwd/count"
while true ;do
echo "$(ssh -p $sshport $remoteserverip hostname)" >> count;sleep 1
# this script connects to remote server each second and add remote server hostname to local file named "count".
# this way we get hostnames one per second, if host is unconnectable, no hostnames will be added
# run this script like this: timeout 3600s /path/to/script
# so we run it for one hour and then it is automatically killed
# then we count number of lines in file "count", so we have rough number of seconds server was connectable
# the rest number of seconds in 3600 is the approximate downtime. Example after script is interupted after hour, we have 3500 lines in file, that means that approximate downtime during that hour was 100 seconds..
# need to check downtime of server, in bigger time range like 72 hours? 3600x72=259200s (timeout 259200s)