#!/bin/bash
#
# (c) 2007-2008 Mandriva, http://www.mandriva.com/
#
# $Id: pulse2-ping 24 2008-02-08 16:36:01Z nrueff $
#
# This file is part of Pulse 2, http://pulse2.mandriva.org
#
# Pulse 2 is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Pulse 2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Pulse 2; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

TIMEOUT=2
COUNT=1
TARGET=$1

if [ "$#" != "1" ]; then
    echo "ERROR"
    exit 3
fi

/bin/ping -w $TIMEOUT -c $COUNT -n -q $TARGET > /dev/null 2>&1

if [ "$?" -eq "0" ]; then
    echo "OK"
    exit 0
else
    echo "KO"
    exit 1
fi
