Skip to content

Commit

Permalink
Add wifi_syslog readme
Browse files Browse the repository at this point in the history
  • Loading branch information
caesar0301 committed Dec 10, 2015
1 parent a3e091a commit 0da83ba
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package cn.edu.sjtu.omnilab.odh.spark


case class CleanWIFILog(MAC: String, time: Long, code: Int, payload: String) // payload as AP or IP
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package cn.edu.sjtu.omnilab.odh.spark
import cn.edu.sjtu.omnilab.odh.rawfilter.{WIFILogFilter}
import org.apache.spark.{SparkConf, SparkContext}

case class CleanWIFILog(MAC: String, time: Long, code: Int, payload: String) // payload as AP or IP


/**
* Cleanse raw WIFI syslog into movement data.
Expand Down
29 changes: 29 additions & 0 deletions porters/wifi_syslog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# WifiSyslog

This repo contains cleansed data for Aruba Wifi Syslog, at SJTU.

## Data format

Four fields are contained in the cleansed data:

* `User ID`: string, recorded as device MAC address.

* `Timestamp`: long, recorded as the time (in milliseconds) when the logging action is triggered by Aruba system.

* `Action code number`: int, the formated code for different actions triggered by Aruba system.

- 0: AuthRequest
- 1: Deauth
- 2: AssocRequest
- 3: Disassoc
- 4: UserAuth
- 5: IPAllocation
- 6: IPRecycle

* `Payload`: string, contains three types of payloads for different actions:

- `Associated AP name`: action 0-3, when the logging action is triggered. AP name format: `BuildName`-`BuildNum`-`Floor`-`APNum`, where the BuildNum may be absent for small buildings.

- `User account name`: action 4, the identify of JAccount.

- `Allocated IP address`: action 5-6, the allocated IP address for current user. IP addresses are reused by Aruba systems. The same IP address MIGHT be reallocated to another user when that address is unused for about 30 mins to a hour.
35 changes: 26 additions & 9 deletions porters/wifi_syslog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ function die () {
exit 1
}

# Check permission
if [ `whoami` != 'omnilab' ]; then
die "Need permission of OMNILAB to run. Try user omnilab."
fi

# Global vars
BASEDIR=$(dirname $0)/..
source $BASEDIR/global_config.sh
Expand All @@ -17,6 +22,17 @@ source $BASEDIR/global_config.sh
BINJAR=$BASEDIR/etlers/ArubaSyslog/target/scala-2.10/ArubaSyslog-assembly-1.0.jar
CLSNAME="cn.edu.sjtu.omnilab.odh.spark.CleanseWifiLogs"

# Check root path for raw data
if [ ! -d $WIFI_SYSLOG_PATH ]; then
die "Cann't find path for raw syslog: $WIFI_SYSLOG_PATH"
fi

# Check root path for this repo
if ! hadoop fs -test -d $HDFS_WIFI_SYSLOG; then
hadoop fs -mkdir -p $HDFS_WIFI_SYSLOG
fi

# Clear temporary folder
TEMPWP=$HDFS_WIFI_SYSLOG/_temp
hadoop fs -rm -r $TEMPWP
hadoop fs -mkdir -p $TEMPWP
Expand All @@ -32,18 +48,19 @@ for rawfile in `ls $WIFI_SYSLOG_PATH`; do

if [ $year$month$day == $(date -d "yesterday" '+%Y%m%d') ]; then

if ! hadoop fs -test -e $HDFS_WIFI_SYSLOG/$rfname/_SUCCESS; then
if ! hadoop fs -test -e $HDFS_WIFI_SYSLOG/$rfname/_SUCCESS; then

# Decompress file
if ! hadoop fs -test -e $TEMPWP/$rfname; then
gunzip -c $WIFI_SYSLOG_PATH/$rawfile | hadoop fs -put - $TEMPWP/$rfname
fi
# Decompress file
if ! hadoop fs -test -e $TEMPWP/$rfname; then
gunzip -c $WIFI_SYSLOG_PATH/$rawfile | hadoop fs -put - $TEMPWP/$rfname
fi

# Cleanse wifilog
hadoop fs -rm -r $HDFS_WIFI_SYSLOG/$rfname
spark-submit2 --class $CLSNAME $BINJAR $TEMPWP/$rfname $HDFS_WIFI_SYSLOG/$rfname
# Cleanse wifilog
hadoop fs -rm -r $HDFS_WIFI_SYSLOG/$rfname
spark-submit2 --class $CLSNAME $BINJAR $TEMPWP/$rfname $HDFS_WIFI_SYSLOG/$rfname
hadoop fs -rm -r $TEMPWP/$rfname
fi

fi
fi

done
Expand Down

0 comments on commit 0da83ba

Please sign in to comment.