Commit 5ed21e37 authored by Luka Stanisic's avatar Luka Stanisic

adding script for capturing environment data

parent 6eeb6ce4
#!/bin/bash
# Script for to get machine information before doing the experiment
set +e # Don't fail fast since some information is maybe not available
title="BioEM experiment results"
host="$(hostname | sed 's/[0-9]*//g' | cut -d'.' -f1)"
help_script()
{
cat << EOF
Usage: $0 [options] outputfile.org
Script for to get machine information before doing the experiment
OPTIONS:
-h Show this message
-t Title of the output file
EOF
}
# Parsing options
while getopts "t:h" opt; do
case $opt in
t)
title="$OPTARG"
;;
h)
help_script
exit 4
;;
\?)
echo "Invalid option: -$OPTARG"
help_script
exit 3
;;
esac
done
shift $((OPTIND - 1))
filedat=$1
if [[ $# != 1 ]]; then
echo 'ERROR!'
help_script
exit 2
fi
##################################################
# Preambule of the output file
echo "#+TITLE: $title" >> $filedat
echo "#+DATE: $(eval date)" >> $filedat
echo "#+AUTHOR: $(eval whoami)" >> $filedat
echo "#+MACHINE: $(eval hostname)" >> $filedat
echo "#+FILE: $(eval basename $filedat)" >> $filedat
echo " " >> $filedat
##################################################
# Collecting metadata
echo "* MACHINE INFO:" >> $filedat
echo "** PEOPLE LOGGED WHEN EXPERIMENT STARTED:" >> $filedat
who >> $filedat
echo "############################################" >> $filedat
echo "** ENVIRONMENT VARIABLES:" >> $filedat
env >> $filedat
echo "############################################" >> $filedat
echo "** HOSTNAME:" >> $filedat
hostname >> $filedat
echo "############################################" >> $filedat
if [ -f /proc/cpuinfo ];
then
echo "** CPU INFO:" >> $filedat
cat /proc/cpuinfo >> $filedat
echo "############################################" >> $filedat
fi
if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ];
then
echo "** CPU GOVERNOR:" >> $filedat
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor >> $filedat
echo "############################################" >> $filedat
fi
if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ];
then
echo "** CPU FREQUENCY:" >> $filedat
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq >> $filedat
echo "############################################" >> $filedat
fi
if [[ -n $(command -v nvidia-smi) ]];
then
echo "** GPU INFO FROM NVIDIA-SMI:" >> $filedat
nvidia-smi -q >> $filedat
echo "############################################" >> $filedat
fi
if [ -f /proc/version ];
then
echo "** LINUX AND GCC VERSIONS:" >> $filedat
cat /proc/version >> $filedat
echo "############################################" >> $filedat
fi
if [[ -n $(command -v module) ]];
then
echo "** MODULES:" >> $filedat
module list 2>> $filedat
echo "############################################" >> $filedat
fi
##################################################
# Collecting revisions info
echo "* CODE REVISIONS:" >> $filedat
git_exists=`git rev-parse --is-inside-work-tree`
if [ "${git_exists}" ]
then
echo "** GIT REVISION OF REPOSITORY:" >> $filedat
git log -1 >> $filedat
echo "############################################" >> $filedat
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment