#!/bin/bash
#
# test_ping
#
# Ping-Pakete versenden an Clients, die in test_ping.conf eingetragen sind
#
if [[ $# -lt 2 ]]
 then
  set `date '+%F %T%:z'`
fi
#
DT="$1 $2"
TZ="$3"
#
TMPDAT=/tmp/pingtest.$$.tmp
#
if [[ -f /etc/uls/test_ping.conf ]]
 then
  grep -v '^ *#' /etc/uls/test_ping.conf | while read H U D T S
   do
    if [[ "$U" = "." ]]
     then
      U=`hostname`
    fi
    if ping -c 1 -w 5 $H >$TMPDAT 2>&1
     then
      send_test_value -h ${U:-$H} ${S:-System} ${T:-Ping} ${D:-$H} $DT `fgrep 'time=' $TMPDAT | sed 's/.*time=//'`
    fi
  done
fi
rm -f $TMPDAT
