Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#!/bin/ksh
echo "\n\nPlease wait..."
if [ ! -f /tmp/ps.before ] ; then
ps -e -o pid,vsz,ruser,etime,args | awk '!/defunct/{print $1","$2","$3","$4","$5,$6,$7}' > /tmp/ps.before
fi
ps -e -o pid,vsz,ruser,etime,args | awk '!/defunct/{print $1","$2","$3","$4","$5,$6,$7}' > /tmp/ps.after
cat /tmp/ps.before /tmp/ps.after > /tmp/ps.total
awk -F, '! /PID/{print $1,$2,$3,$4,$5,$6,$7}' /tmp/ps.before | while read pid vsz ruser etime command a b
do
num_procs=`grep -c "^${pid}," /tmp/ps.total`
if [ "${num_procs}" -eq 2 ] ; then
after_vsz=`awk -F, '/'"^${pid},"'/{print $2}' /tmp/ps.before`
((delta=vsz-after_vsz))
echo "${pid}\t${vsz}\t\t${after_vsz}\t\t${delta}\t${ruser}\t${etime}\t${command} $a $b"
fi
done > /tmp/ps.after.tmp
#clear
echo "PID\tVSZ SIZE BEFORE\tVSZ SIZE AFTER\tDELTA\tUSER\tELAPSED TIME\tCOMMAND"
echo "---\t---------------\t--------------\t-----\t----\t------------\t-------"
sort +3 /tmp/ps.after.tmp
VSB=`awk '{ sum += $2 } END { print "Total VSZ Before: ", sum }' /tmp/ps.after.tmp`
VSA=`awk '{ sum += $3 } END { print "Total VSZ After: ", sum }' /tmp/ps.after.tmp`
DELTA=`awk '{ sum += $4 } END { print "Total Delta: ", sum }' /tmp/ps.after.tmp`
rm /tmp/ps.after*
rm /tmp/ps.total
start_date=`ls -la /tmp/ps.before | awk '{print $6,$7}'`
echo "\n\nRunning against ps.before file with date of: ${start_date}"
echo "\n\n${VSB}"
echo "${VSA}"
echo "${DELTA}"
echo "Total Defunct Processes Found: `ps -ef | grep -c [d]efunct`"