1#!/bin/sh
2
3if [ $# -lt 2 ]
4then
5    echo "usage: $0 rrdname targetip [dpinger options]"
6    exit 1
7fi
8name="$1"
9targetip="$2"
10shift 2
11options=$*
12
13# Where the dpinger executable is located
14dpinger=/usr/local/bin/dpinger
15
16
17rrdfile="${name}.rrd"
18if [ \! -w ${rrdfile} ]
19then
20    echo "$0: file \"${rrdfile}\" does not exist or is not writable"
21    exit 1
22fi
23
24${dpinger} -f ${options} -s 500m -t 60s -r 60s ${targetip} |
25while read -r latency stddev loss; do
26    rrdtool update "${rrdfile}" -t latency:stddev:loss "N:$latency:$stddev:$loss"
27done
28