dyn annouce mehere BATMAN Interfaces

Mister Crumble MisterCrumble at web.de
So Jul 31 19:08:50 CEST 2016


Hallo, ich verwende diese script hier:

#!/bin/bash

BATMAN_INTERFACES=("bat0" "bat1" "bat2")

declare -A WEIGHT
declare -A IPRANGE
declare -A MAX_LEASES
WEIGHT[bat0]="1"
IPRANGE[bat0]="IP 10.50.72"
MAX_LEASES[bat0]="250"

WEIGHT[bat1]="0.5"
IPRANGE[bat1]="IP 10.50.96"
MAX_LEASES[bat1]="250"

WEIGHT[bat2]="0.7"
IPRANGE[bat2]="IP 10.50.240"
MAX_LEASES[bat2]="250"

LEASEFILE="/var/lib/dhcp/dhcpd.leases"

if [ -z "$1" ]; then
        echo
        echo "usage: $0 <network-interface> <update_interval [sec]>
<total BW up [Mbit/sec]> <total BW down [Mbit/sec]>"
        echo
        echo "e.g. $0 eth0 60 10 10"
        echo
        exit
fi

R1=$(cat "/sys/class/net/$1/statistics/rx_bytes")
T1=$(cat "/sys/class/net/$1/statistics/tx_bytes")
sleep "$2"

while true
do
        # Bandwidth currently used (time averaged)
        R2=$(cat "/sys/class/net/"${1}"/statistics/rx_bytes")
        T2=$(cat "/sys/class/net/"${1}"/statistics/tx_bytes")
        TkbitPS=$(echo "scale=0; ($T2 - $T1) / 1024 * 8 / $2" | bc -l)
        RkbitPS=$(echo "scale=0; ($R2 - $R1) / 1024 * 8 / $2" | bc -l)
#        echo "BW used      -- up $1: $TkbitPS kBit/s; down $1: $RkbitPS kBit/s"

        # Remaining bandwidth available; cut-off negative values
        Tavail_kbitPS=$(echo "scale=0; if (($3 * 1024 - $TkbitPS) >0)
($3 * 1024 - $TkbitPS) else 0" | bc -l)
        Ravail_kbitPS=$(echo "scale=0; if (($4 * 1024 - $RkbitPS) >0)
($4 * 1024 - $RkbitPS) else 0" | bc -l)
#        echo "BW available -- up $1: $Tavail_kbitPS kBit/s; down $1:
$Ravail_kbitPS kBit/s"

        # Pass calculated figures to B.A.T.M.A.N Gateway Selection
#        echo "batctl gw_mode server ${Ravail_kbitPS}kbit/${Tavail_kbitPS}kbit"
        for interface in ${BATMAN_INTERFACES[@]} ; do

                LEASES=$(cat "${LEASEFILE}" | grep -c "${IPRANGE[$interface]}")
                if [[ ${LEASES} -gt  ${MAX_LEASES[$interface]} ]] ; then
                        logger dyn_gwl_sel: ${interface} gw_mode off
                        echo batctl -m "$interface" gw_mode off
                        batctl -m "$interface" gw_mode off
                else
                        THIS_AVAILRX=$(echo ${Ravail_kbitPS} \*
${WEIGHT[$interface]} | bc -l | cut -d. -f1)
                        THIS_AVAILTX=$(echo ${Tavail_kbitPS} \*
${WEIGHT[$interface]} | bc -l | cut -d. -f1)
                        batctl -m "$interface" gw_mode server
${THIS_AVAILRX}kbit/${THIS_AVAILTX}kbit"

                        echo  batctl -m "$interface" gw_mode server
"${THIS_AVAILRX}kbit/${THIS_AVAILTX}kbit"
                fi
        done
        R1=$(cat "/sys/class/net/"${1}"/statistics/rx_bytes")
        T1=$(cat "/sys/class/net/"${1}"/statistics/tx_bytes")

        sleep "$2"
done

bzw habe verwendet weil es folgenden Fehler auswirft:
root at fff-gw-wue2:/usr/local/bin# ./dyn_announce_2.sh: line 69:
unexpected EOF while looking for matching `"'
./dyn_announce_2.sh: line 71: syntax error: unexpected end of file
^C
[1]+  Exit 2                  ./dyn_announce_2.sh eth0 30 30 30

als ich den wert zum reannounce auf 30 sek gestellt habe hat sich das
script nach 30 sek beendet.  kann mir da jemand helfen?

MisterCrumble


Mehr Informationen über die Mailingliste franken-dev