enhanced command line parsing.

This commit is contained in:
2026-02-01 10:21:35 +01:00
parent 34d8ba7214
commit 08acce525b
3 changed files with 65 additions and 21 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
*.log *.log
*.bak
bin/minimal_test.sh bin/minimal_test.sh

View File

@@ -10,34 +10,77 @@ usage() {
EOF EOF
} }
if [[ "$1" == "-h" || "$1" == "--help" ]]; then verbose=false
usage COLOR='red'
exit 0
VALID_ARGS=$(getopt -o vho:c:t:l: --long verbose,help,output,color:,title:,logfile: -- "$@")
if [[ $? -ne 0 ]]; then
exit 1;
fi fi
# Eingabeparameter echo "VALID_ARGS=${VALID_ARGS}"
LOGFILE="${1}" eval set -- "$VALID_ARGS"
while [ : ]; do
# echo "aktueller Parameter: ${1}"
case "$1" in
-h | --help)
usage
exit 0
shift
;;
-l | --logfile)
LOGFILE="${2}"
echo "LOGFILE=${LOGFILE}"
shift 2
;;
-o | --output)
echo "1: ${1}, 2:${2},3:${3}"
OUTFILE="${2}" OUTFILE="${2}"
TITLE="${3}" echo "OUTFILE=${OUTFILE}"
shift 2
;;
-c | --color)
COLOR="${2}"
echo "COLOR=${COLOR}"
shift 2
;;
-t | --title)
TITLE="${2}"
echo "TITLE=${TITLE}"
shift 2
;;
-v | --verbose)
verbose=true
shift
;;
--) shift;
break
;;
esac
done
echo "Parameter geparsed."
# Eingabeparameter
if [ -z "$LOGFILE" ] || [ -z "$OUTFILE" ] || [ -z "$TITLE" ]; then if [ -z "$LOGFILE" ] || [ -z "$OUTFILE" ] || [ -z "$TITLE" ]; then
usage usage
exit 1 exit 1
fi fi
gnuplot <<EOF echo "generating plot from ${LOGFILE}"
set terminal pngcairo size 1600,900 gnuplot -e "
set output "$OUTFILE" set terminal pngcairo size 1800,800;
set title "$TITLE" set output '${OUTFILE}';
set xlabel "Zeit (s)" set multiplot layout 1,2 title '${TITLE}';
set ylabel "Temperatur (°C)" set xlabel 'Zeit (s)';
set grid set ylabel 'Temperatur (°C)';
set key top left set grid;
set key top left;
set title '${TITLE}';
plot '$LOGFILE' using 1:2 with lines lc rgb '${COLOR}' lw 2 title 'CPU-Temperatur'
"
# Linie rot, Dicke 2
plot "$LOGFILE" using 1:2 with lines lc rgb "red" lw 2 title "CPU-Temperatur"
EOF
echo "Plot erzeugt: $OUTFILE" echo "Plot erzeugt: $OUTFILE"
exit 0

View File

@@ -1,5 +1,5 @@
temp_data.sh > temp.log & measure_temp.sh > ${1} &
TPID=$! TPID=$!
fio fio/fio_cpu fio ~/git/pistress/fio/fio_cpu
kill $TPID kill $TPID > /dev/null