Portál AbcLinuxu, 10. května 2025 08:21
while true do ping neco -n 1 -w x || play neco sleep 30 done
#!/bin/bash
laststate=-1
timeout=5
sleeptime=5s
echo "Watchdog for $1"
while true
do
ping $1 -i $timeout -w $timeout -c 1 > /dev/null 2> /dev/null
result=$?
if [ $laststate != $result ]; then
date=`date`
case "$result" in
0)
echo "$date : Host $1 is up"
playwave /usr/share/sounds/KDE_Beep_Connect.wav >/dev/null 2>/dev/null
;;
1) echo "$date : Host $1 is down"
playwave /usr/share/sounds/KDE_Glass_Break.ogg >/dev/null 2>/dev/null
;;
esac
fi
laststate=$result
sleep $sleeptime
done
... jak se tomu pingu da rict ze odezvu treba 5000ms uz nema pocitat? Stavaj se tu i 13s pingy... v maualu sem se pokousel hleddat ale asi sem slepej.Pomohlo by tohle?
-w deadline
Specify a timeout, in seconds, before ping exits regardless of how many packets have
been sent or received. In this case ping does not stop after count packet are sent, it
waits either for deadline expire or until count probes are answered or for some error
notification from network.
-W timeout
Time to wait for a response, in seconds. The option affects only timeout in absense of
any responses, otherwise ping waits for two RTTs.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.