#!/bin/sh

PID=$1
UPTIME_FILE=/proc/uptime

# first line of csv output
printf "uptime;vsz;cpu\\n"

while [ -e ${STATUS_FILE} ]
do
  set -- $(cat ${UPTIME_FILE})
  UPTIME=${1}
  set -- $(top -b -n1 | grep ${PID} | grep -v grep)
  VSZ=${6}
  CPU=${7}
  COMMAND=${8}
  printf "%s;%s;%s\\n" "${UPTIME}" "${VSZ}" "${CPU}"
  sleep 1
done
