From d81c4195b5084418b79012d745b8eeba76cd3b55 Mon Sep 17 00:00:00 2001 From: floh1111 Date: Thu, 26 May 2011 17:12:29 +0000 Subject: [PATCH] Multiple client interfaces now possible in nodewatcher, fixed bug that nodewatcher does not send the number of clients, fixed bug that wlan0 is not added to mesh bridge on wr1043nd, prepare for firmware version 0.2 --- .../default/etc/config/nodewatcher | 2 +- root_file_system/default/etc/firmware_release | 4 +-- root_file_system/default/etc/nodewatcher.sh | 25 ++++++++++++------ .../dir300/etc/config/nodewatcher | 26 +++++++++++++++++++ .../wr1043nd/etc/config/nodewatcher | 26 +++++++++++++++++++ root_file_system/wr1043nd/etc/crontabs/root | 20 ++++++++++++++ 6 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 root_file_system/dir300/etc/config/nodewatcher create mode 100644 root_file_system/wr1043nd/etc/config/nodewatcher create mode 100644 root_file_system/wr1043nd/etc/crontabs/root diff --git a/root_file_system/default/etc/config/nodewatcher b/root_file_system/default/etc/config/nodewatcher index 46a59740..2fe1df2a 100644 --- a/root_file_system/default/etc/config/nodewatcher +++ b/root_file_system/default/etc/config/nodewatcher @@ -1,5 +1,5 @@ config 'script' - option 'version' '18' + option 'version' '19' option 'error_level' '0' option 'logfile' '/var/log/nodewatcher.log' diff --git a/root_file_system/default/etc/firmware_release b/root_file_system/default/etc/firmware_release index d172bd31..e7f21774 100644 --- a/root_file_system/default/etc/firmware_release +++ b/root_file_system/default/etc/firmware_release @@ -1,2 +1,2 @@ -FIRMWARE_VERSION="0.1" -RELEASE_DATE="15.02.2010" \ No newline at end of file +FIRMWARE_VERSION="0.2" +RELEASE_DATE="30.05.2011" \ No newline at end of file diff --git a/root_file_system/default/etc/nodewatcher.sh b/root_file_system/default/etc/nodewatcher.sh index ee3289a3..1ab8d5c4 100755 --- a/root_file_system/default/etc/nodewatcher.sh +++ b/root_file_system/default/etc/nodewatcher.sh @@ -19,6 +19,8 @@ if [ -f /etc/config/nodewatcher ];then CRAWL_NICKNAME=`uci get nodewatcher.@crawl[0].nickname` CRAWL_PASSWORD=`uci get nodewatcher.@crawl[0].password` UPDATE_AUTOUPDATE=`uci get nodewatcher.@update[0].autoupdate` + MESH_INTERFACE=`uci get nodewatcher.@network[0].mesh_interface` + CLIENT_INTERFACES=`uci get nodewatcher.@network[0].client_interfaces` else . $SCRIPT_DIR/nodewatcher_config fi @@ -30,6 +32,12 @@ fi if [ -n $API_RETRY ]; then API_RETRY="3" fi +if [ -n $MESH_INTERFACE ]; then + MESH_INTERFACE="br-mesh" +fi +if [ -n $CLIENT_INTERFACES ]; then + CLIENT_INTERFACES="ath0" +fi API_RETRY=$(($API_RETRY - 1)) @@ -102,7 +110,7 @@ update() { echo "`date`: Suche neue Version" >> $logfile fi netmon_api=`get_url` - command="wget -q -O - http://$netmon_api/api_nodewatcher.php?section=version" + command="wget -q -O - http://$netmon_api/api_nodewatcher.php?section=version&nodewatcher_version=$SCRIPT_VERSION" ergebnis=`$command&sleep $API_TIMEOUT; kill $!` return=`echo $ergebnis| cut '-d;' -f1` version=`echo $ergebnis| cut '-d;' -f2` @@ -112,7 +120,7 @@ update() { if [ $error_level -gt "1" ]; then echo "`date`: Eine neue Version ist Verfügbar, script wird geupdated" >> $logfile fi - wget -q -O $SCRIPT_DIR/nodewatcher.sh http://$netmon_api/api_nodewatcher.php?section=update + wget -q -O $SCRIPT_DIR/nodewatcher.sh http://$netmon_api/api_nodewatcher.php?section=update&nodewatcher_version=$SCRIPT_VERSION uci set nodewatcher.@script[0].version=$version uci commit else @@ -398,13 +406,14 @@ crawl() { mv /etc/bat-hosts.tmp /etc/bat-hosts #CLIENTS - MESHDEVICE='br-mesh' - CLIENTDEVICE='ath0' - SEDDEV=`brctl showstp $MESHDEVICE | egrep '\([0-9]\)' | sed -e "s/(//;s/)//" | awk '{ print "s/^ "$2"/"$1"/;" }'` - CLIENT_MACS=`brctl showmacs $MESHDEVICE | sed -e "$SEDDEV" | awk '{if ($3 != "yes" && $1 == "ath0") print $2}'` + SEDDEV=`brctl showstp $MESH_INTERFACE | egrep '\([0-9]\)' | sed -e "s/(//;s/)//" | awk '{ print "s/^ "$2"/"$1"/;" }'` + + for entry in $CLIENT_INTERFACES; do + CLIENT_MACS=$CLIENT_MACS`brctl showmacs $MESH_INTERFACE | sed -e "$SEDDEV" | awk '{if ($3 != "yes" && $1 == "'"$entry"'") print $2}'`" " + done + i=0 for client in $CLIENT_MACS; do -# clients=$clients"clients[$i][mac_addr]=$client&" i=`expr $i + 1` #Zähler um eins erhöhen done client_count=$i @@ -413,7 +422,7 @@ crawl() { SYSTEM_DATA="status=online&hostname=$hostname&description=$description&location=$location&latitude=$latitude&longitude=$longitude&luciname=$luciname&luciversion=$luciversion&distname=$distname&distversion=$distversion&chipset=$chipset&cpu=$cpu&memory_total=$memory_total&memory_caching=$memory_caching&memory_buffering=$memory_buffering&memory_free=$memory_free&loadavg=$loadavg&processes=$processes&uptime=$uptime&idletime=$idletime&local_time=$local_time&community_essid=$community_essid&community_nickname=$community_nickname&community_email=$community_email&community_prefix=$community_prefix&batman_advanced_version=$batman_adv_version&kernel_version=$kernel_version&nodewatcher_version=$nodewatcher_version&firmware_version=$firmware_version" INTERFACE_DATA="$int" BATMAN_ADV_ORIGINATORS="$batman_adv_originators" - CLIENT_DATA="$client_count" + CLIENT_DATA="client_count=$client_count" DATA="$AUTHENTIFICATION_DATA&$SYSTEM_DATA&$INTERFACE_DATA&$BATMAN_ADV_INTERFACES&$BATMAN_ADV_ORIGINATORS&$CLIENT_DATA" diff --git a/root_file_system/dir300/etc/config/nodewatcher b/root_file_system/dir300/etc/config/nodewatcher new file mode 100644 index 00000000..d4bb5bbd --- /dev/null +++ b/root_file_system/dir300/etc/config/nodewatcher @@ -0,0 +1,26 @@ +config 'script' + option 'version' '19' + option 'error_level' '0' + option 'logfile' '/var/log/nodewatcher.log' + +config 'api' + option 'ipv4_address' '1' + option 'ipv6_interface' 'br-mesh' + option 'ipv6_address' 'fe80::201:2ff:fe03:405' + option 'timeout' '3' + option 'retry' '3' + +config 'update' + option 'autoupdate' '1' + +config 'crawl' + option 'method' 'hash' + option 'nickname' '1' + option 'password' '1' + option 'router_id' '1' + option 'update_hash' '1' + option 'login_string' '1' + +config 'network' + option 'mesh_interface' 'br-mesh' + option 'client_interfaces' 'ath0 eth0.1' \ No newline at end of file diff --git a/root_file_system/wr1043nd/etc/config/nodewatcher b/root_file_system/wr1043nd/etc/config/nodewatcher new file mode 100644 index 00000000..ae85d563 --- /dev/null +++ b/root_file_system/wr1043nd/etc/config/nodewatcher @@ -0,0 +1,26 @@ +config 'script' + option 'version' '19' + option 'error_level' '0' + option 'logfile' '/var/log/nodewatcher.log' + +config 'api' + option 'ipv4_address' '1' + option 'ipv6_interface' 'br-mesh' + option 'ipv6_address' 'fe80::201:2ff:fe03:405' + option 'timeout' '3' + option 'retry' '3' + +config 'update' + option 'autoupdate' '1' + +config 'crawl' + option 'method' 'hash' + option 'nickname' '1' + option 'password' '1' + option 'router_id' '1' + option 'update_hash' '1' + option 'login_string' '1' + +config 'network' + option 'mesh_interface' 'br-mesh' + option 'client_interfaces' 'wlan0 eth0.1' \ No newline at end of file diff --git a/root_file_system/wr1043nd/etc/crontabs/root b/root_file_system/wr1043nd/etc/crontabs/root new file mode 100644 index 00000000..6a010182 --- /dev/null +++ b/root_file_system/wr1043nd/etc/crontabs/root @@ -0,0 +1,20 @@ +*/5 * * * * killall klogd +*/5 * * * * killall syslogd +*/5 * * * * killall logger + +*/5 * * * * sh /etc/tincstart.sh +*/5 * * * * sh /etc/nodewatcher.sh + +15 01 * * * rdate -s time.fu-berlin.de > /dev/null + +#Enable zapp script if you are running a gateway +#*/1 * * * * /etc/init.d/zapp + +*/5 * * * * killall -HUP dnsmasq +#* * * * * /usr/sbin/ff_olsr_test_gw +#*/5 * * * * /usr/sbin/ff_olsr_watchdog +#0 */4 * * * /usr/sbin/ff_rdate +#17 * * * * /usr/sbin/ff_mapupdate + +#Fix only for WR1043ND becuase wlan0 is not added after bootup +*/5 * * * * brctl addif br-mesh wlan0 \ No newline at end of file