Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dcd6806e72 | |||
| 8f7fe4f016 | |||
| 114a194758 | |||
| 08acce525b |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,6 @@
|
||||
*.log
|
||||
*.bak
|
||||
*.png
|
||||
bin/minimal_test.sh
|
||||
|
||||
|
||||
|
||||
@@ -1,43 +1,126 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="1.00"
|
||||
usage() {
|
||||
local name=${0##*/}
|
||||
|
||||
cat <<-EOF
|
||||
Usage: ${name} [-h || --help] <logfile> <outfile> <title>
|
||||
Version: ${VERSION}
|
||||
Usage: ${name}
|
||||
-h, --help display this help
|
||||
-l, --logfile <logfile> logfile with temperature data to be plotted
|
||||
-o, --output <output.png> output file the plotted chart should be written to
|
||||
-c, --color <colorname> color in which the ghraph should be plotted ('red','blue'dtc.) defaults to 'red'
|
||||
-t, --title <title> title of the graph
|
||||
-v, --verbose verbose mode (not implemented yet)
|
||||
|
||||
Plots the graph of the <logfile> and writes it to <outfile>
|
||||
<logfile> must contain
|
||||
timestamp temperature
|
||||
in seperate lines
|
||||
|
||||
Generates graph of the <logfile> and writes it to <outfile>
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
check() {
|
||||
if ! command -v gnuplot >/dev/null 2>&1; then
|
||||
echo "gnuplot is not installed."
|
||||
echo "Please use"
|
||||
echo " sudo apt install -y gnuplot"
|
||||
echo "and try again"
|
||||
exit 5
|
||||
fi
|
||||
}
|
||||
|
||||
verbose=false
|
||||
COLOR='red'
|
||||
PADDING=5
|
||||
|
||||
VALID_ARGS=$(getopt -o vho:c:t:l: --long verbose,help,output,color:,title:,logfile: -- "$@")
|
||||
if [[ $? -ne 0 ]]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Eingabeparameter
|
||||
LOGFILE="${1}"
|
||||
eval set -- "$VALID_ARGS"
|
||||
while [ : ]; do
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
shift
|
||||
;;
|
||||
-l | --logfile)
|
||||
LOGFILE="${2}"
|
||||
echo "LOGFILE=${LOGFILE}"
|
||||
shift 2
|
||||
;;
|
||||
-o | --output)
|
||||
OUTFILE="${2}"
|
||||
TITLE="${3}"
|
||||
shift 2
|
||||
;;
|
||||
-c | --color)
|
||||
COLOR="${2}"
|
||||
shift 2
|
||||
;;
|
||||
-t | --title)
|
||||
TITLE="${2}"
|
||||
shift 2
|
||||
;;
|
||||
-v | --verbose)
|
||||
verbose=true
|
||||
shift
|
||||
;;
|
||||
--) shift;
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
check
|
||||
#determine max and min values
|
||||
read YMIN YMAX < <(
|
||||
awk '
|
||||
NR==1 { min=$2; max=$2 }
|
||||
$2 < min { min=$2 }
|
||||
$2 > max { max=$2 }
|
||||
END { printf "%.1f %.1f\n", min, max }
|
||||
' "${LOGFILE}"
|
||||
)
|
||||
|
||||
echo "YMIN=${YMIN} YMAX=${YMAX}"
|
||||
|
||||
|
||||
|
||||
echo "Parameter geparsed."
|
||||
|
||||
# Eingabeparameter
|
||||
if [ -z "$LOGFILE" ] || [ -z "$OUTFILE" ] || [ -z "$TITLE" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gnuplot <<EOF
|
||||
set terminal pngcairo size 1600,900
|
||||
set output "$OUTFILE"
|
||||
echo "generating plot from ${LOGFILE}"
|
||||
gnuplot \
|
||||
-e "OUTFILE='${OUTFILE}'" \
|
||||
-e "LOGFILE='${LOGFILE}'" \
|
||||
-e "TITLE='${TITLE}'" \
|
||||
-e "COLOR='${COLOR}'" \
|
||||
-e "YMAX=${YMAX}" \
|
||||
-e "PADDING=${PADDING}" \
|
||||
-e "YMIN=${YMIN}" \
|
||||
-e "
|
||||
set terminal pngcairo size 1800,800;
|
||||
set output OUTFILE;
|
||||
set title TITLE;
|
||||
set xlabel 'Zeit (s)';
|
||||
set ylabel 'Temperatur (°C)';
|
||||
set grid;
|
||||
set key top left;
|
||||
|
||||
set title "$TITLE"
|
||||
set xlabel "Zeit (s)"
|
||||
set ylabel "Temperatur (°C)"
|
||||
set grid
|
||||
set key top left
|
||||
set label sprintf('Tmax: %.1f°C', YMAX-PADDING) at graph 0.98,0.02 right;
|
||||
|
||||
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"
|
||||
exit 0
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
temp_data.sh > temp.log &
|
||||
measure_temp.sh > ${1} &
|
||||
TPID=$!
|
||||
fio fio/fio_cpu
|
||||
kill $TPID
|
||||
fio ~/git/pistress/fio/fio_cpu
|
||||
kill $TPID > /dev/null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user