| Server IP : 199.250.200.62 / Your IP : 216.73.217.1 Web Server : Apache System : Linux vps37394.inmotionhosting.com 3.10.0-1160.119.1.vz7.224.4 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : jasonp18 ( 1000) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/dedrads/ |
Upload File : |
#!/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;