Last active
November 14, 2019 08:24
-
-
Save benwei/3a3eb2c58e9b076b07120aeaba52ea40 to your computer and use it in GitHub Desktop.
Logging CPU load by top command per minute with BusyBox command environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## if you want to run toplog_per_minute.sh in background | |
## you have to use leading script to put it into backgroud without | |
## issue of "Stopped (tty output)" Error Message of script that | |
## stucked on busybox top command | |
## tested in BusyBox v1.20.2 | |
################################################################## | |
/bin/sh /mnt/nand/toplog_per_minute.sh & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TARGET_PREFIX=/mnt/mmc0/toplog | |
LOG_INTERVAL=60 | |
run_top_once() | |
{ | |
DATESTR="`date +'%Y%m%d-%H:%M:%S'`" | |
DATEONLY="${DATESTR:0:8}" | |
if [ "$DATEONLY" = "19700101" ]; then | |
return | |
fi | |
top_logname="${TARGET_PREFIX}${DATEONLY}.txt" | |
echo "D$DATESTR" >> $top_logname | |
top -b -n 1 >> $top_logname | |
## if you also want to log memory, please uncomment the next line | |
# free >> $top_logname | |
} | |
while [ 1 ] ; do | |
run_top_once ; sleep $LOG_INTERVAL; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment