31 lines
657 B
Bash
31 lines
657 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -uoe pipefail
|
||
|
|
||
|
if (( $# != 3 )); then
|
||
|
echo "usage: $(basename $0) <nvidia-smi dmon log> <database file> <table>" 1>&2
|
||
|
exit 1
|
||
|
fi
|
||
|
log=$1
|
||
|
db=$2
|
||
|
table=$3
|
||
|
|
||
|
sqlite3 -batch ${db} << EOF
|
||
|
DROP TABLE IF EXISTS ${table};
|
||
|
CREATE TABLE ${table} (
|
||
|
sample INTEGER PRIMARY KEY,
|
||
|
timestamp TEXT,
|
||
|
gpu INTEGER,
|
||
|
power INTEGER,
|
||
|
temp_gpu INTEGER,
|
||
|
temp_mem INTEGER,
|
||
|
activity INTEGER,
|
||
|
memory INTEGER,
|
||
|
clock_mem INTEGER,
|
||
|
clock_gpu INTEGER
|
||
|
);
|
||
|
EOF
|
||
|
tmp=$(mktemp)
|
||
|
awk 'BEGIN{n=0} !/^#/{print n"|"$1" "$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$11"|"$12;n++}' ${log} > ${tmp}
|
||
|
sqlite3 -batch ${db} ".import ${tmp} ${table}"
|