premier commit
This commit is contained in:
20
bin/pf-gw
Normal file
20
bin/pf-gw
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$1" == "discovery" ]; then
|
||||
sockets=`ls /var/run/dpinger_*.sock`
|
||||
result=`echo -n '{"data": ['`
|
||||
for i in $sockets ; do
|
||||
data=`echo $i | cut -c 18- | cut -d "~" -f 1`
|
||||
result=`echo -n $result'{"{#GWNAME}": "'`
|
||||
result=`echo -n $result"$data"`
|
||||
result=`echo -n $result'"},'`
|
||||
done
|
||||
result=`echo $result | sed 's/.$//'`
|
||||
result=`echo -n $result']}'`
|
||||
elif [ "$1" == "latency" ]; then
|
||||
result=`cat /var/run/dpinger_${2}~*.sock 2> /dev/null | awk '{print $2 / 1000}' | bc | sed 's/^\./0./'`
|
||||
elif [ "$1" == "packetloss" ]; then
|
||||
result=`cat /var/run/dpinger_${2}~*.sock 2> /dev/null | awk '{print $4}'`
|
||||
fi
|
||||
|
||||
echo $result
|
Reference in New Issue
Block a user