1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-18 12:06:08 +00:00
Sergei Trofimov 51ffd60c06 instruments: add proc_stat
Add an instrument that monitors CPU load using data from /proc/stat
2020-02-07 14:11:31 +00:00

24 lines
592 B
Bash
Executable File

#!/bin/sh
BUSYBOX=$1
OUTFILE=$2
PERIOD=$3
STOP_SIGNAL_FILE=$4
if [ "$#" != "4" ]; then
echo "USAGE: gather-load.sh BUSYBOX OUTFILE PERIOD STOP_SIGNAL_FILE"
exit 1
fi
echo "timestamp,user,nice,system,idle,iowait,irq,softirq,steal,guest,guest_nice" > $OUTFILE
while true; do
echo -n $(${BUSYBOX} date -Iseconds) >> $OUTFILE
${BUSYBOX} cat /proc/stat | ${BUSYBOX} head -n 1 | \
${BUSYBOX} cut -d ' ' -f 2- | ${BUSYBOX} sed 's/ /,/g' >> $OUTFILE
if [ -f $STOP_SIGNAL_FILE ]; then
rm $STOP_SIGNAL_FILE
break
else
sleep $PERIOD
fi
done