mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
Temperature graphing scripts that start specified connections for a duration
Signed-off-by: Jed Reynolds <jreynolds@candelatech.com>
This commit is contained in:
160
Sensordata_loop.bash
Executable file
160
Sensordata_loop.bash
Executable file
@@ -0,0 +1,160 @@
|
||||
#!/bin/bash
|
||||
# set -veux
|
||||
q="'"
|
||||
Q='"'
|
||||
cxname=${1:-}
|
||||
if [[ x$cxname == x ]] ; then
|
||||
echo "$0: please specify CX to start and monitor"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
quit_now=0
|
||||
tagname="$cxname"
|
||||
temps_flag=/tmp/monitor_temps
|
||||
chart_flag=/tmp/monitor_chart
|
||||
run_flag=/tmp/monitor_run
|
||||
begintime=`date "+%Y-%m-%d %H:%M"`
|
||||
|
||||
checkon() {
|
||||
local interval=$1
|
||||
local flag=$2
|
||||
if [[ x$1 == x ]]; then
|
||||
echo "checkon: no interval, bye"
|
||||
ctrl_c
|
||||
exit 1
|
||||
fi
|
||||
if [[ x$2 == x ]]; then
|
||||
echo "checkon: no flag file name, bye"
|
||||
ctrl_c
|
||||
exit 1
|
||||
fi
|
||||
while (( interval >= 0 )); do
|
||||
sleep 1
|
||||
[ ! -f $flag ] && return
|
||||
[ ! -f $run_flag ] && return
|
||||
interval=$((interval- 1))
|
||||
done
|
||||
}
|
||||
|
||||
countdown() {
|
||||
local left=$1
|
||||
while (( left >= 0 )); do
|
||||
if (( quit_now == 1 )) || [ ! -f $run_flag ]; then
|
||||
break
|
||||
fi
|
||||
printf "\r%d..." $left
|
||||
sleep 1
|
||||
left=$((left - 1))
|
||||
done
|
||||
}
|
||||
|
||||
start_cx() {
|
||||
if [[ x$1 == x ]]; then
|
||||
echo "start_cx: no CX name, bye"
|
||||
ctrl_c
|
||||
exit 1
|
||||
fi
|
||||
for cx in "$@"; do
|
||||
echo "Starting $cx..."
|
||||
/home/lanforge/scripts/lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \
|
||||
"set_cx_state default_tm $cx RUNNING"
|
||||
done
|
||||
}
|
||||
|
||||
stop_cx() {
|
||||
/home/lanforge/scripts/lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \
|
||||
"set_cx_state ALL ALL STOPPED"
|
||||
}
|
||||
|
||||
ctrl_c () {
|
||||
quit_now=1
|
||||
[ ! -f $run_flag ] && return
|
||||
echo -n "cleaning up..."
|
||||
stop_cx
|
||||
rm -f $temps_flag
|
||||
rm -f $chart_flag
|
||||
rm -f $run_flag
|
||||
echo "done"
|
||||
}
|
||||
trap ctrl_c INT
|
||||
|
||||
monitor_temps() {
|
||||
if [[ x$1 == x ]]; then
|
||||
echo "monitoring_temps: no monitoring duration"
|
||||
exit 1
|
||||
fi
|
||||
echo "monitoring temps every $1"
|
||||
if [ ! -x /home/lanforge/scripts/sensorz.pl ]; then
|
||||
echo "no sensorz.pl, bye"
|
||||
ctrl_c
|
||||
exit 1
|
||||
fi
|
||||
touch $temps_flag
|
||||
while [ -f $temps_flag ] && [ -f $run_flag ]; do
|
||||
if (( quit_now == 1 )); then
|
||||
echo "monitoring_temps ending"
|
||||
break;
|
||||
fi
|
||||
/home/lanforge/scripts/sensorz.pl | logger -t "$tagname"
|
||||
checkon $1 $temps_flag
|
||||
done
|
||||
echo "done monitoring temps"
|
||||
}
|
||||
|
||||
monitoring_chart() {
|
||||
if [[ x$1 == x ]]; then
|
||||
echo "monitoring_chart: no monitoring duration"
|
||||
ctrl_c
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -x /home/lanforge/sensor_chart.bash ]; then
|
||||
echo "no sensor_chart.bash, bye"
|
||||
ctrl_c
|
||||
exit 1
|
||||
fi
|
||||
echo "charting temps every $1"
|
||||
touch $chart_flag
|
||||
while [ -f $chart_flag ] && [ -f $run_flag ]; do
|
||||
checkon $1 $chart_flag
|
||||
if (( quit_now == 1 )) || [ ! -f $run_flag ]; then
|
||||
echo "monitoring_chart ending"
|
||||
break
|
||||
fi
|
||||
echo " sensor_chart.bash $tagname $q${begintime}$q"
|
||||
/home/lanforge/sensor_chart.bash "$tagname" "${begintime}" || {
|
||||
echo "FAILED TO GENERATE CHART"
|
||||
ctrl_c
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
now=`date +%Y-%m-%d_%H.%M.%S`
|
||||
mv ~/Documents/sensordata.${tagname}.png ~/Documents/sensordata.${tagname}.${now}.png
|
||||
echo "done charting temps see `pwd`/sensordata.${tagname}.${now}.png"
|
||||
}
|
||||
|
||||
cd ~/Documents/
|
||||
# stop all existing connections
|
||||
stop_cx
|
||||
touch $run_flag
|
||||
monitor_temps ${SENS_INTERVAL_SEC:-30} & # usually 30s
|
||||
# countdown $(( 60 * 1 )) # realistic cooldown time is about 10m
|
||||
countdown ${PRECOOL_SEC:-60} # realistic cooldown time is about 10m
|
||||
|
||||
start_cx $@
|
||||
|
||||
default_chart_interval_sec=$((60 * 2))
|
||||
monitoring_chart ${CHART_INTERVAL_SEC:-$default_chart_interval_sec} & # usually 2m
|
||||
default_dur_sec=$(( 60 * 60 * 45 ))
|
||||
countdown ${TEST_DUR_SEC:-$default_dur_sec} # usually 45m
|
||||
|
||||
stop_cx
|
||||
|
||||
echo "cooling off..."
|
||||
countdown ${CHART_INTERVAL_SEC:-$default_chart_interval_sec} # needs to be as long as charting interval
|
||||
echo "stopping monitoring..."
|
||||
rm -f $temps_flag $chart_flag $run_flag
|
||||
#countdown ${CHART_INTERVAL_SEC:-$default_chart_interval_sec} # needs to be as long as charting interval
|
||||
|
||||
echo done
|
||||
|
||||
#
|
||||
86
sensor_chart.bash
Executable file
86
sensor_chart.bash
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
tagname=
|
||||
if [[ x$1 == x ]]; then
|
||||
echo "$0: want a tagname, bye"
|
||||
exit 1
|
||||
else
|
||||
tagname="$1"
|
||||
fi
|
||||
|
||||
if [[ x$2 == x ]]; then
|
||||
echo "No lower duration, when do you want to collect from? Use 'yyyy-mm-dd ii:mm'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
conf="sensorplot.${tagname}.conf"
|
||||
data="sensordata.${tagname}.data"
|
||||
ceesv="sensordata.${tagname}.csv"
|
||||
peeng="sensordata.${tagname}.png"
|
||||
|
||||
[ -f $conf ] && rm -f $conf
|
||||
[ -f $data ] && rm -f $data
|
||||
[ -f $ceesv ] && rm -f $ceesv
|
||||
[ -f $peeng ] && rm -f $peeng
|
||||
|
||||
#journalctl -t "$tagname" --since "$2" | head
|
||||
|
||||
journalctl -t "$tagname" --output short-unix --since "$2" > "$data"
|
||||
|
||||
if [ ! -s $data ]; then
|
||||
echo "Unable to collect data"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
perl -n \
|
||||
-e 'next if(/mt/); if (/^(\d+)\.[^:]+: ([0-9.]+), ([0-9.]+), ([0-9.]+)/) { print "$1 $2 $3 $4\n"}' \
|
||||
< $data \
|
||||
| tee $ceesv \
|
||||
| tail -1
|
||||
|
||||
if [ ! -s $ceesv ]; then
|
||||
echo "Unable to produce data"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#echo "journalctl -t $Q$tagname$Q --output short-unix --since $Q$2$Q"
|
||||
#while IFS= read -r line; do
|
||||
# hunks=($line)
|
||||
# echo -n ${hunks[0]}
|
||||
# date +' %Y-%m-%d %H:%M' --date @${hunks[0]}
|
||||
#done < $ceesv | head
|
||||
|
||||
# create gnuplot config file
|
||||
BS='\'
|
||||
cat > ${conf} <<EOF
|
||||
set title "${tagname}: TX 100Mbps multi 10 from $2"
|
||||
set output "${peeng}"
|
||||
set term png
|
||||
set datafile separator " "
|
||||
set xlabel "Time"
|
||||
set timefmt "%s"
|
||||
set format x "%H:%M"
|
||||
set xdata time
|
||||
set ylabel "DegC"
|
||||
set grid
|
||||
set key left
|
||||
|
||||
plot \
|
||||
"${ceesv}" using 1:3 title "coretemp", $BS
|
||||
"${ceesv}" using 1:2 title "mtk 1", $BS
|
||||
"${ceesv}" using 1:4 title "mtk 2"
|
||||
EOF
|
||||
|
||||
if [ ! -s $conf ]; then
|
||||
echo "BAD CONF FILE $conf"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -s $ceesv ]; then
|
||||
echo "BAD CSV FILE $ceesv"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -n "creating [$peeng] using (gnuplot -c $conf $ceesv)"
|
||||
gnuplot -c $conf $ceesv
|
||||
echo " created $peeng"
|
||||
|
||||
#
|
||||
Reference in New Issue
Block a user