Skip to content

Instantly share code, notes, and snippets.

@reard3n
Created July 6, 2020 17:26
Show Gist options
  • Save reard3n/15816bbdb2d98da957b67c8c68a47b35 to your computer and use it in GitHub Desktop.
Save reard3n/15816bbdb2d98da957b67c8c68a47b35 to your computer and use it in GitHub Desktop.
#!/bin/bash
while true
do
touch /tmp/csv.output
top -b -n1 | grep -A3 PID | grep -v PID | awk '{print $9","$10","$12}' > /tmp/procs
while read line
do
CSV=`hostname`
DATE=`date +%s`
CSV="$CSV,$DATE"
CSV="$CSV,$line"
echo $CSV >> /tmp/csv.output
done < /tmp/procs
rm /tmp/procs
sleep .3
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment