User Tools

Site Tools


tips:beep-when-host-starts-pinging

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tips:beep-when-host-starts-pinging [31.08.2011 00:22] (current)
vergo created
Line 1: Line 1:
 +====== Beep when host starts pinging ======
  
 +This script will make the PC start beeping with the PC speaker when the selected host becomes pingable. It's useful for example when you are waiting for some server to come online and don't want to keep looking a terminal full of ping timeouts. Remember to check first that the //beep// command actually causes some noise.
 +
 +<code bash>
 +#!/bin/bash
 +
 +if [ $# -eq "1" ]; then
 +        beep -f 3000 -l 50
 +        for (( ; ; )) ; do
 +                pin=`ping -c 1 -w 1 "$1" | grep -c "bytes from"`
 +                if [ $pin -eq 1 ]; then
 +                        beep -f 3000 -l 50
 +                        echo "* `date +%H:%M:%S` online!"
 +                else
 +                        echo "`date +%H:%M:%S` timeout"
 +                fi
 +                sleep 2
 +        done
 +else
 +        echo "Target parameter missing!"
 +fi
 +</code>
tips/beep-when-host-starts-pinging.txt ยท Last modified: 31.08.2011 00:22 by vergo