#!/bin/bash
#
# (c) Lorenzo Canovi (KUBiC Labs, CH) <packager@kubiclabs.com>
# for copyright see /usr/share/doc/kuwatcher/copyright
#
# probe (ping) host, using one packet probe, and 3 seconds
# timeout; you can change the timeout using PING_TIMEOUT env
#
# returns 0 if ping ok
# returns 1 if ping is not ok, or host is not resolved, or
#		args not passed to command
#
CMD=${CMD:-"$0"}
DEBUG=${DEBUG:-"false"}
PING_TIMEOUT=${PING_TIMEOUT:-"3"}

[ $# == 0 ] && exit 127

host=$1; shift

[ "X$host" == "X" ] && exit 1

exec ping -c 1 -w $PING_TIMEOUT $host "$@"
