Mini Shell

Direktori : /proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/sharedrads/
Upload File :
Current File : //proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/sharedrads/procscrape

#!/bin/sh
#Process Scrape
#written by Brad Markle, thrown in a file by Tyler
# Tyler modified the script to pull only user data.

#todo
#* add a yes/no+trap to ask about saving/deleting the log on exit
#* now scrapes user processes before cutting only php

#original
#watch -n .1 "uptime;echo;top -b -c -n 1|head -13|tail -6|grep php >> top.log;echo \"Longest running php proccess:\";cat top.log|sort -k 11|tail -10;echo \" \";echo \"Highes CPU using php processes\";cat top.log|sort -nk 9|tail -10;"

TEMPLOG="top.log.${RANDOM}.${RANDOM}"
# awk '\$2 \\~ /[a-z]+[0-9]/{print}' - this doesn't work in watch due to shell quoting, would be nice tho.
#grep php >> $TEMPLOG;
function scrape () {

if  ! grep " 5" /etc/redhat-release;then
rm -f top.log;watch -n .1 "uptime;echo;top -b -c -n 1|head -13|tail -6|grep php >> top.log;echo \"Longest running php proccess:\";cat top.log|sort -k 11|tail -10;echo \" \";echo \"Highes CPU using php processes\";cat top.log|sort -nk 9|tail -10;"
rm top.log
else
	watch -n .1 "uptime; top -b -c -n 1|grep php  >>$TEMPLOG;echo \"===Longest running php proccess===\";echo \"  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND\"; sort -rk 11 $TEMPLOG|head -13;	echo;echo \"===PHP Processes - Using High CPU===\";echo \"  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND\"; sort -rnk 9 $TEMPLOG|head -13;echo;echo \"===PHP Processes - High Memory===\";echo \"  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND\";sort -rnk 10 $TEMPLOG|head -13;"
fi

}
if [ $# -gt 0 ];
then
	case $1 in
	--help)
		echo "$0 - running processscrape.sh by itself will scrape top for active php processes "
		echo "and generate a list of the longest running and those using the most CPU time."
		;;
	*)
		echo "This program doesn't really take options right now."
	;;
	esac
fi

scrape


rm -f $TEMPLOG;

Zerion Mini Shell 1.0