* [Bismark-commits] rev 321 - trunk/device/OpenWrt_common/scripts
@ 2011-04-14 20:06 walter
0 siblings, 0 replies; only message in thread
From: walter @ 2011-04-14 20:06 UTC (permalink / raw)
To: bismark-commits
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) <url> <up|dw> <duration> <kbps>" ; 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) <alive|boot|reboot|modem|uplink|trouble> [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) <alive|boot|reboot|modem|uplink|trouble> [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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-04-15 0:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-14 20:06 [Bismark-commits] rev 321 - trunk/device/OpenWrt_common/scripts walter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox