Last active
January 27, 2016 10:54
-
-
Save jhn--/519182158e3a476705ee to your computer and use it in GitHub Desktop.
Grabs a list of processes currently running and saves list into /var/log/process_snapshots
This file contains hidden or 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
#!/bin/bash | |
#set -x | |
snapshot(){ | |
now=$(date +%F_%H:%M:%S) | |
ps -e -o user,uid,pid,ppid,class,rtprio,ni,pri,psr,c,pcpu,pmem,vsz,rss,start,time,etime,stat,wchan=wwwwwwwwwwwwwwwwwwwwww,cmd --sort=user | grep -Evi 'root|bash|ssh' > $where/process_$now.log; | |
} | |
go(){ | |
where=/var/log/process_snapshots | |
if [ ! -d $where ]; then | |
/bin/mkdir $where | |
snapshot | |
else snapshot | |
fi | |
} | |
case "$1" in | |
--help) | |
printf "\nGrabs a list of processes currently running and saves list into /var/log/process_snapshots \n" | |
;; | |
*) | |
go | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment