1762264845

This commit is contained in:
2025-11-04 07:00:45 -07:00
parent 4c3289bd2f
commit d65878ff93
2 changed files with 3 additions and 58 deletions
+3 -19
View File
@@ -16,16 +16,7 @@ if [ -z "$1" ]; then
exit 1
fi
echo "testing your gay little command $cmd at $(date '+%H:%M:%S %Z')" | tr [a-z] [A-Z]
# kill loeg for suretain
if [ -f "$logfile" ]; then
echo "$logfile found, deleting it"
rm -f "$logfile"
fi
# csv headers
# measurements_csv_fields="TIMESTAMP,PID,CPU USAGE %,MEMORY USAGE (KIBIBYTES),MEMORY USAGE %,READ VOLUME PER SECOND (KIBIBYTES),WRITE SIZE PER SECOND (KIBIBYTES)"
echo "testing your gay little command $cmd"
# start times
start_unixmicroseconds=$(date +"%s%6N") # get start microseconds fast as possible before run
# run the command with pidstat monitoring it, using eval to handle strings and args methods
@@ -39,16 +30,9 @@ duration_microseconds=$(($end_unixmicroseconds - $start_unixmicroseconds))
## seconds
duration_seconds=$(($duration_microseconds / 1000000)) # seconds = microseconds / 1,000,000
cat "$logfile"
# remove lines starting with # (comments), empty lines, and those starting with Linux so its a pure csv
# then squash spaces and replace with commas
# them awk by delimiter comma to output
# and replace da original file with tha fixed one
# echo $measurements_csv_fields
echo "AVERAGES: CPU% | MEMORY USAGE (KiB) | MEMORY % | READ SIZE PER SECOND (KiB) | WRITE SIZE PER SECOND (KiB)"
cat "$logfile" | sed '/^#\|^$\|^Linux/d' | tr -s ' ' ',' | awk -F, '{ cpup += $8; memk += $13; memp += $14; rkbs += $15; wkbs += $15 } END { print "%CPU: ",cpup / NR,"Memory Usage (KiB): ",memk / NR, "Memory Usage %: ",memp / NR,"\nKiB Read Per Second: ",rkbs / NR,"\nKiB Written Per Second: ",wkbs / NR }' #$1,$3,$8,$13,$14,$15,$16,$17 }'
cat "$logfile" | sed '/^#\|^$\|^Linux/d' | tr -s ' ' ',' | awk -F, '{ cpup += $8; memk += $13; memp += $14; rkbs += $15; wkbs += $15 } END { print "\nCPU:",cpup/NR,"\nMemory Usage (KiB):",memk/NR,"\nMemory Usage %:",memp/NR,"\nKiB Read Per Second:",rkbs/NR,"\nKiB Written Per Second:",wkbs/NR }' #$1,$3,$8,$13,$14,$15,$16,$17 }'
# add footer
info_csv_fields_data="Duration Seconds: $duration_seconds Duration Microseconds: $duration_microseconds Return Code: $ret"
echo $info_csv_fields_data
# cat "$logfile" | sed '/^#\|^$\|^Linux/d' | tr -s ' ' ',' | awk -F, '{ cpup += $3 } END { print "sunn:",cpup / NR }'
echo -e "Duration Seconds: $duration_seconds\nDuration Microseconds: $duration_microseconds\nReturn Code: $ret"