-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script for converting \
nvidia-smi\
output into CSV
- Loading branch information
mclang
committed
Aug 29, 2022
1 parent
0e663cf
commit 0c535a3
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# Converts logs created with this `nvidia-smi` command: | ||
# ``` | ||
# $ nvidia-smi dmon -s puc -d 1 -o DT | tee -a ~/Documents/Dell-XPS15-logs/nvidia-smi_(date +"%F").log | ||
# ``` | ||
# Into proper CSV files WITHOUT unnecessary headers in the middle | ||
# | ||
# NOTE: Square brackets in `tr` command must be escaped! | ||
# TODO: Remove unnecessary semicolon from the beginning of the line | ||
set -e | ||
set -u | ||
shopt -s nullglob | ||
|
||
for LOG in *.log; do | ||
CSV="$(basename $LOG .log).csv" | ||
if [[ -e "$CSV" ]]; then | ||
echo "Skipping '$LOG' b/c '$CSV' exists..." | ||
continue | ||
fi | ||
echo "Converting '$LOG' -> '$CSV'" | ||
head -n 2 "$LOG" | tr -s \[#\[:blank:\]\] ';' > "$CSV" | ||
grep -Ev '^#' "$LOG" | tr -s \[#\[:blank:\]\] ';' >> "$CSV" | ||
done | ||
|