From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-22-ewr.dyndns.com (mxout-092-ewr.mailhop.org [216.146.33.92]) by lists.bufferbloat.net (Postfix) with ESMTP id 17F752E06E4 for ; Thu, 14 Apr 2011 17:52:01 -0700 (PDT) Received: from scan-22-ewr.mailhop.org (scan-22-ewr.local [10.0.141.244]) by mail-22-ewr.dyndns.com (Postfix) with ESMTP id 3958E2E24B for ; Thu, 14 Apr 2011 20:03:13 +0000 (UTC) X-Spam-Score: 0.1 () X-Mail-Handler: MailHop by DynDNS X-Originating-IP: 143.225.229.147 Received: from svn.comics.unina.it (unknown [143.225.229.147]) by mail-22-ewr.dyndns.com (Postfix) with ESMTP id F19AE30A1C for ; Thu, 14 Apr 2011 20:03:07 +0000 (UTC) Received: from www-data by svn.comics.unina.it with local (Exim 4.69) (envelope-from ) id 1QASoP-0001yx-DO for bismark-commits@lists.bufferbloat.net; Thu, 14 Apr 2011 22:06:45 +0200 To: bismark-commits@lists.bufferbloat.net From: walter@svn.comics.unina.it Message-Id: Date: Thu, 14 Apr 2011 22:06:45 +0200 X-Mailman-Approved-At: Thu, 14 Apr 2011 21:25:17 -0700 Subject: [Bismark-commits] rev 321 - trunk/device/OpenWrt_common/scripts X-BeenThere: bismark-commits@lists.bufferbloat.net X-Mailman-Version: 2.1.13 Precedence: list List-Id: Commit log for the bismark source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Apr 2011 00:52:02 -0000 Author: walter Date: 2011-04-14 22:06:45 +0200 (Thu, 14 Apr 2011) New Revision: 321 Added: trunk/device/OpenWrt_common/scripts/bismark-airodump trunk/device/OpenWrt_common/scripts/bismark-arp trunk/device/OpenWrt_common/scripts/bismark-event trunk/device/OpenWrt_common/scripts/bismark-upload Removed: trunk/device/OpenWrt_common/scripts/barp trunk/device/OpenWrt_common/scripts/bcurl trunk/device/OpenWrt_common/scripts/bdhcp trunk/device/OpenWrt_common/scripts/bwdump trunk/device/OpenWrt_common/scripts/event trunk/device/OpenWrt_common/scripts/upload Log: other scripts renamed Deleted: trunk/device/OpenWrt_common/scripts/barp =================================================================== --- trunk/device/OpenWrt_common/scripts/barp 2011-04-14 16:35:33 UTC (rev 320) +++ trunk/device/OpenWrt_common/scripts/barp 2011-04-14 20:06:45 UTC (rev 321) @@ -1,10 +0,0 @@ -#!/bin/bash -# Bismark arp wrapper -# -# author: walter.dedonato@unina.it - -# Load configuration files -. ~/conf/dev.conf - -# Dump arp table -arp -n | awk '(NR > 1 && /ether/){ print '$(date +%s)' "\t" $1 "\t" $3}' >> /tmp/measure/${DEVICE_ID}.arp Deleted: trunk/device/OpenWrt_common/scripts/bcurl =================================================================== --- trunk/device/OpenWrt_common/scripts/bcurl 2011-04-14 16:35:33 UTC (rev 320) +++ trunk/device/OpenWrt_common/scripts/bcurl 2011-04-14 20:06:45 UTC (rev 321) @@ -1,73 +0,0 @@ -#!/bin/bash -# Bismark curl wrapper (output in Kbps) -# -# author: walter.dedonato@unina.it - -# Load configuration file -. ~/conf/dev.conf - -# Help screen -[ $4 ] || { echo "usage: $(basename $0) " ; exit ; } - -# Bitrate parser (kbps) -# $1 = duration -parse_kbps () { - gawk -v "RS=[\r\n]" '(NR > 4){ - if ($12 ~ /k/) print $12 * 8; - else if ($12 ~ /M/) print $12 * 8000; - else print $12 / 125; - split($10, t, ":"); - if ((t[1]*3600 + t[2]*60 + t[3]) >= '$1') exit - }' -} - -# Ausiliary files -f_time="/tmp/curl/time" -f_rates="/tmp/curl/rates" -f_bytes="/tmp/curl/bytes" -mkdir -p /tmp/curl - -# Select direction -length=$(( $3 * ($4 / 8) * 1000 )) -case $2 in -up) - chunk_size=1460 - chunks=$(( (length / chunk_size) + 1 )) - - # Take wan iface TX bytes before - b_before=$(awk -F '[ \t:]+' '/'$WAN_IF':/{ print $11 }' /proc/net/dev) - - # Start transfer - plgen $length 2> $f_bytes |\ - ~/bin/time -f %e -o $f_time curl -X PUT -H "Expect:" -H "Content-length: $length" -T - $1 -o /dev/null --stderr - |\ - parse_kbps $3 - - # Take wan iface TX bytes after - b_after=$(awk -F '[ \t:]+' '/'$WAN_IF':/{ print $11 }' /proc/net/dev) -;; -dw) - # Take wan iface RX bytes before - b_before=$(awk -F '[ \t:]+' '/'$WAN_IF':/{ print $3 }' /proc/net/dev) - - # Start transfer - ~/bin/time -f %e -o $f_time curl "$1?duration=$3&kbps=$4" -o /dev/null --stderr - | parse_kbps $3 - echo $length > $f_bytes # TODO - - # Take wan iface RX bytes after - b_after=$(awk -F '[ \t:]+' '/'$WAN_IF':/{ print $3 }' /proc/net/dev) -;; -esac - -duration=$(grep '^[0-9]' $f_time) -bytes=$(cat $f_bytes) - -# Compute aggregate and file bitrate -if [ $b_before -le $b_after ]; then - abytes=$(( b_after - b_before )) -else - abytes=$(( b_after + (2 << 32) - b_before )) -fi -agg_kbps=$(awk "BEGIN{ print (($abytes/125)/$duration) }") -file_kbps=$(awk "BEGIN{ print (($bytes/125)/$duration) }") -echo -e "$agg_kbps\t$file_kbps" > $f_rates - Deleted: trunk/device/OpenWrt_common/scripts/bdhcp =================================================================== --- trunk/device/OpenWrt_common/scripts/bdhcp 2011-04-14 16:35:33 UTC (rev 320) +++ trunk/device/OpenWrt_common/scripts/bdhcp 2011-04-14 20:06:45 UTC (rev 321) @@ -1,10 +0,0 @@ -#!/bin/bash -# Records DHCP events -# -# author: walter.dedonato@unina.it - -# Load configuration file -. ~/conf/dev.conf - -IFS=$'\t' -echo -e "$(date +%s)\t$*" >> /tmp/measure/$DEVICE_ID.dhcp Copied: trunk/device/OpenWrt_common/scripts/bismark-airodump (from rev 317, trunk/device/OpenWrt_common/scripts/bwdump) =================================================================== --- trunk/device/OpenWrt_common/scripts/bismark-airodump (rev 0) +++ trunk/device/OpenWrt_common/scripts/bismark-airodump 2011-04-14 20:06:45 UTC (rev 321) @@ -0,0 +1,25 @@ +#!/bin/ash +# Bismark airodump wrapper +# +# author: walter.dedonato@unina.it + +# Load configuration files +. /etc/bismrak/bismark.conf + +# Enable monitor interface +if ! (/sbin/ifconfig | grep -q ath1) ; then + /sbin/wlanconfig ath1 create wlandev wifi0 wlanmode monitor + /sbin/ifconfig ath1 up +fi + +# Start/Restart airodump and stop after 5 minutes +if [ $(pgrep -n airodump-ng) ]; then + killall airodump-ng + mv /tmp/${DEVICE_ID}*.csv /tmp/measure +fi + +if [ "$1" == all ]; then + ( openvt -w airodump-ng -w /tmp/${DEVICE_ID}_$(date +%s)_all --output-format csv --berlin 500 ath1 & ) +else + ( openvt -w airodump-ng -w /tmp/${DEVICE_ID}_$(date +%s) --channel $WIFI_CHANNEL --output-format csv --berlin 500 ath1 & ) +fi Copied: trunk/device/OpenWrt_common/scripts/bismark-arp (from rev 317, trunk/device/OpenWrt_common/scripts/barp) =================================================================== --- trunk/device/OpenWrt_common/scripts/bismark-arp (rev 0) +++ trunk/device/OpenWrt_common/scripts/bismark-arp 2011-04-14 20:06:45 UTC (rev 321) @@ -0,0 +1,10 @@ +#!/bin/ash +# Bismark arp wrapper +# +# author: walter.dedonato@unina.it + +# Load configuration files +. /etc/bismark/bismark.conf + +# Dump arp table +arp -n | awk '(NR > 1 && /ether/){ print '$(date +%s)' "\t" $1 "\t" $3}' >> /tmp/bismark/data/${DEVICE_ID}.arp Copied: trunk/device/OpenWrt_common/scripts/bismark-event (from rev 317, trunk/device/OpenWrt_common/scripts/event) =================================================================== --- trunk/device/OpenWrt_common/scripts/bismark-event (rev 0) +++ trunk/device/OpenWrt_common/scripts/bismark-event 2011-04-14 20:06:45 UTC (rev 321) @@ -0,0 +1,59 @@ +#!/bin/ash +# Bismark events logger +# What will it take to convert these to ash? +# author: walter.dedonato@unina.it + +# Load configuration files +. /etc/bismark/bismark.conf + +# Help screen +[ $1 ] || { echo "usage: $(basename $0) [options]" ; exit ; } + +mkdir -p ~/cache +event_log=~/cache/${DEVICE_ID}.events + +case $1 in +boot) # To be called during boot + # Set POWER_OFF event if not rebooted + if [ -e $event_log -a -e ~/cache/power ]; then + tail -n1 $event_log | grep -q REBOOT || echo -e "$(cat ~/cache/power)\tPOWER_OFF" >> $event_log + fi + + # Get boot timestamp + boot_ts=$(( $(date +%s) - $(cut -f1 -d"." /proc/uptime) )) + echo -e "$boot_ts\tPOWER_ON" >> $event_log +;; +reboot) # To be called just before reboot + echo -e "$(date +%s)\tREBOOT" >> $event_log +;; +alive) # To be called every 5 minutes + date +%s > ~/cache/power +;; +modem) # To be called after boot and upload + [ $(pgrep -n mii-tool) ] && killall mii-tool + ( mii-tool -w eth0 2>/dev/null | gawk '{ printf "%s", systime() } ; /no link/{ print "\tMODEM_DOWN" } ; /link ok/{ print "\tMODEM_UP" }' >> $event_log 2>/dev/null & ) +;; +uplink) # To be called after probe reply + [ -e /tmp/uplink ] || echo down > /tmp/uplink + + case $2 in + up) + if [ $(cat /tmp/uplink) == "down" ]; then + echo -e "$(date +%s)\tUPLINK_UP" >> $event_log + echo up > /tmp/uplink + fi + ;; + down) + if [ $(cat /tmp/uplink) == "up" ]; then + echo -e "$(date +%s)\tUPLINK_DOWN" >> $event_log + echo down > /tmp/uplink + fi + ;; + esac +;; +trouble) + shift + echo -e "$(date +%s)\tTROUBLE\t$*" >> $event_log +;; +esac + Copied: trunk/device/OpenWrt_common/scripts/bismark-upload (from rev 317, trunk/device/OpenWrt_common/scripts/upload) =================================================================== --- trunk/device/OpenWrt_common/scripts/bismark-upload (rev 0) +++ trunk/device/OpenWrt_common/scripts/bismark-upload 2011-04-14 20:06:45 UTC (rev 321) @@ -0,0 +1,31 @@ +#!/bin/ash +# Upload measurements to the bismark server +# +# author: walter.dedonato@unina.it + +# Load configuration file +. /etc/bismark/bismark.conf +. /usr/lib/bismark/functions.inc.sh + +# Copy active measurements files +scp -i $SSH_KEY /tmp/measure/*.xml $USER@$SERVER:~/var/data && rm /tmp/measure/*.xml + +# Copy passive measurements files +scp -i $SSH_KEY /tmp/measure/*.arp $USER@$SERVER:~/var/data/${DEVICE_ID}_$(date +%s).arp && rm /tmp/measure/*.arp +if [ ${DEVICE_ID:0:2} == NB ]; then + [ $PRIVACY_MODE ] && t2_filter + scp -i $SSH_KEY /tmp/measure/*.t2 $USER@$SERVER:~/var/data && rm /tmp/measure/*.t2 + wifi_filter + scp -i $SSH_KEY /tmp/measure/*.csv $USER@$SERVER:~/var/data && rm /tmp/measure/*.csv + scp -i $SSH_KEY /tmp/measure/*.dhcp $USER@$SERVER:~/var/data/${DEVICE_ID}_$(date +%s).dhcp && rm /tmp/measure/*.dhcp + scp -i $SSH_KEY ~/cache/*.events $USER@$SERVER:~/var/data/${DEVICE_ID}_$(date +%s).events && rm ~/cache/*.events + + rename_dump + scp -i $SSH_KEY /tmp/measure/*.dump $USER@$SERVER:~/var/data && rm /tmp/measure/*.dump + + # Restart modem event watcher + event modem +fi + +# Copy cached files +scp -i $SSH_KEY ~/cache/*.tgz $USER@$SERVER:~/var/data && rm ~/cache/*.tgz Deleted: trunk/device/OpenWrt_common/scripts/bwdump =================================================================== --- trunk/device/OpenWrt_common/scripts/bwdump 2011-04-14 16:35:33 UTC (rev 320) +++ trunk/device/OpenWrt_common/scripts/bwdump 2011-04-14 20:06:45 UTC (rev 321) @@ -1,25 +0,0 @@ -#!/bin/bash -# Bismark airodump wrapper -# -# author: walter.dedonato@unina.it - -# Load configuration files -. ~/conf/dev.conf - -# Enable monitor interface -if ! (/sbin/ifconfig | grep -q ath1) ; then - /sbin/wlanconfig ath1 create wlandev wifi0 wlanmode monitor - /sbin/ifconfig ath1 up -fi - -# Start/Restart airodump and stop after 5 minutes -if [ $(pgrep -n airodump-ng) ]; then - killall airodump-ng - mv /tmp/${DEVICE_ID}*.csv /tmp/measure -fi - -if [ "$1" == all ]; then - ( openvt -w airodump-ng -w /tmp/${DEVICE_ID}_$(date +%s)_all --output-format csv --berlin 500 ath1 & ) -else - ( openvt -w airodump-ng -w /tmp/${DEVICE_ID}_$(date +%s) --channel $WIFI_CHANNEL --output-format csv --berlin 500 ath1 & ) -fi Deleted: trunk/device/OpenWrt_common/scripts/event =================================================================== --- trunk/device/OpenWrt_common/scripts/event 2011-04-14 16:35:33 UTC (rev 320) +++ trunk/device/OpenWrt_common/scripts/event 2011-04-14 20:06:45 UTC (rev 321) @@ -1,58 +0,0 @@ -#!/bin/bash -# Bismark events logger -# What will it take to convert these to ash? -# author: walter.dedonato@unina.it - -# Load configuration files -. ~/conf/dev.conf - -# Help screen -[ $1 ] || { echo "usage: $(basename $0) [options]" ; exit ; } - -mkdir -p ~/cache -event_log=~/cache/${DEVICE_ID}.events - -case $1 in -boot) # To be called during boot - # Set POWER_OFF event if not rebooted - if [ -e $event_log -a -e ~/cache/power ]; then - tail -n1 $event_log | grep -q REBOOT || echo -e "$(cat ~/cache/power)\tPOWER_OFF" >> $event_log - fi - - # Get boot timestamp - boot_ts=$(( $(date +%s) - $(cut -f1 -d"." /proc/uptime) )) - echo -e "$boot_ts\tPOWER_ON" >> $event_log -;; -reboot) # To be called just before reboot - echo -e "$(date +%s)\tREBOOT" >> $event_log -;; -alive) # To be called every 5 minutes - date +%s > ~/cache/power -;; -modem) # To be called after boot and upload - [ $(pgrep -n mii-tool) ] && killall mii-tool - ( mii-tool -w eth0 2>/dev/null | gawk '{ printf "%s", systime() } ; /no link/{ print "\tMODEM_DOWN" } ; /link ok/{ print "\tMODEM_UP" }' >> $event_log 2>/dev/null & ) -;; -uplink) # To be called after probe reply - [ -e /tmp/uplink ] || echo down > /tmp/uplink - - case $2 in - up) - if [ $(cat /tmp/uplink) == "down" ]; then - echo -e "$(date +%s)\tUPLINK_UP" >> $event_log - echo up > /tmp/uplink - fi - ;; - down) - if [ $(cat /tmp/uplink) == "up" ]; then - echo -e "$(date +%s)\tUPLINK_DOWN" >> $event_log - echo down > /tmp/uplink - fi - ;; - esac -;; -trouble) - shift - echo -e "$(date +%s)\tTROUBLE\t$*" >> $event_log -;; -esac Deleted: trunk/device/OpenWrt_common/scripts/upload =================================================================== --- trunk/device/OpenWrt_common/scripts/upload 2011-04-14 16:35:33 UTC (rev 320) +++ trunk/device/OpenWrt_common/scripts/upload 2011-04-14 20:06:45 UTC (rev 321) @@ -1,31 +0,0 @@ -#!/bin/bash -# Upload measurements to the bismark server -# -# author: walter.dedonato@unina.it - -# Load configuration file -. ~/conf/dev.conf -. ~/scripts/functions - -# Copy active measurements files -scp -i $SSH_KEY /tmp/measure/*.xml $USER@$SERVER:~/var/data && rm /tmp/measure/*.xml - -# Copy passive measurements files -scp -i $SSH_KEY /tmp/measure/*.arp $USER@$SERVER:~/var/data/${DEVICE_ID}_$(date +%s).arp && rm /tmp/measure/*.arp -if [ ${DEVICE_ID:0:2} == NB ]; then - [ $PRIVACY_MODE ] && t2_filter - scp -i $SSH_KEY /tmp/measure/*.t2 $USER@$SERVER:~/var/data && rm /tmp/measure/*.t2 - wifi_filter - scp -i $SSH_KEY /tmp/measure/*.csv $USER@$SERVER:~/var/data && rm /tmp/measure/*.csv - scp -i $SSH_KEY /tmp/measure/*.dhcp $USER@$SERVER:~/var/data/${DEVICE_ID}_$(date +%s).dhcp && rm /tmp/measure/*.dhcp - scp -i $SSH_KEY ~/cache/*.events $USER@$SERVER:~/var/data/${DEVICE_ID}_$(date +%s).events && rm ~/cache/*.events - - rename_dump - scp -i $SSH_KEY /tmp/measure/*.dump $USER@$SERVER:~/var/data && rm /tmp/measure/*.dump - - # Restart modem event watcher - event modem -fi - -# Copy cached files -scp -i $SSH_KEY ~/cache/*.tgz $USER@$SERVER:~/var/data && rm ~/cache/*.tgz