Skip to content

Instantly share code, notes, and snippets.

@apwiggins
Created September 16, 2020 17:01
Show Gist options
  • Save apwiggins/02bbce445f58d9ab82573f583db698b6 to your computer and use it in GitHub Desktop.
Save apwiggins/02bbce445f58d9ab82573f583db698b6 to your computer and use it in GitHub Desktop.
#!/bin/bash
# session hook script; write commands here to execute on the host at the
# specified state
# Framework script for automation of log collection
# CORE enters the DATACOLLECT state following the completion of a CORE session
# Logs, packet captures, configuration files, etc are still available within
# CORE nodes (LXC containers) in a persistent state. A datacollect_hook script
# can be used to capture experiment results for post-processing and analysis.
# 1. Each session is logged in the datacollect.log
# 2. The script collects experiment results by session PID and records data about
# experiment run that has completed.
# 3. Script goes node by node and collects logs and packet captures in the
# destination experiment results directory.
# 4. Following completion of the script, all LXC containers and data are
# torn down and discarded.
# Define timestamp function
timestamp() {
date +"%T"
}
#echo "`hostname`:`pwd`" > /tmp/datacollect.log
#customize the host directory where scenarios are run from
scriptDir=/home/$USER/src/my_experiment
timeStr=$(date --rfc-3339=seconds)
#resultsDir=$scriptDir/log/$timeStr
#resultsDir=$scriptDir/log/$timeStr/$k/$mob/$SESSION
session=${SESSION}
resultsDir=$scriptDir/log/$session
scenario=${SESSION_FILENAME}
expDir=$(pwd)
# Following details are appended to the datacollect.log file for each experiment
# run in simulation. Time of run, scenario file used, and location of logged
# results are recorded
echo $expDir >> $scriptDir/datacollect.log
echo $scriptDir >> $scriptDir/datacollect.log
echo $timeStr >> $scriptDir/datacollect.log
echo $resultsDir >> $scriptDir/datacollect.log
echo $scenario >> $scriptDir/datacollect.log
echo "##########" >> $scriptDir/datacollect.log
mkdir -p $resultsDir
# Copy all log and packet capture files to results dir
for d in n*.conf
do
cp $d/var.log/*.log $resultsDir
cp $d/var.log/*.pcap $resultsDir
done
cd $scriptDir
# Add post-processing scripts / applications here
#./gen_core_results.py --expDir log/$timeStr
#./gen_core_results.py --expDir $resultsDir
# cleanup
chmod -R go+rw $resultsDir
cd $expDir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment