#!/bin/bash

KEYWORD=$1
DIRECTORY=$2

[ ! -d "${DIRECTORY}" ] && mkdir -p ${DIRECTORY}

while true; do
	NOW_DATETIME=$(date +%Y-%m-%dT%H:%M:%S)
	NOW_TIMESTAMP=$(date +%s)
	NOW_DATETIME_FILENAME=$(date +%Y%m%dT%H%M%S)
	SNAPSHOT_FILENAME="${KEYWORD}.${NOW_DATETIME_FILENAME}.perf"

	echo "${NOW_DATETIME}, ${NOW_TIMESTAMP}, ${SNAPSHOT_FILENAME}"
	screen -S ${KEYWORD}.perf -X hardcopy -h ${DIRECTORY}/${SNAPSHOT_FILENAME}

	sleep 10
done
