Also, here is a little script which would dump all system stats as well as stats for processes owned by user -
#!/bin/sh
TERM=vt100
export TERM
LOGDIR=./
time=$(date)
min=${time:14:2}
today="`date +%m%d%y`"
FNAME=$LOGDIR/$today
# echo $FNAME
# exit 0
touch $FNAME
echo "______________________________________________________" >> $FNAME
echo " $time" >> $FNAME
echo "______________________________________________________" >> $FNAME
echo "**************** TOP *******************************" >> $FNAME
top -b -n 1 >> $FNAME
#
# Get every socket out there, resolve IP addresses, and print which
# process has that socket open
#
echo "**************** NETSAT *******************************" >> $FNAME
netstat -ap >> $FNAME
echo "**************** Process Status *******************************" >> $FNAME
ps -auxww >> $FNAME
#
# How much memory are the processes using? This will be a percentage
# of the total.
#
echo "**************** Process MEMORY Consumption ************" >> $FNAME
ps aux | awk '{sum +=$4}; END {print sum}' >> $FNAME
#
# A busy system will have the kernel use up a lot of memory. But, the
# +/- buffers/cache entry should show free buffers if not, then we have
# memory issues.
#
echo "**************** FREEMEM *******************************" >> $FNAME
free >> $FNAME
echo "****************************************************" >> $FNAME
#
# Get all theprocesses and then find their open sockets.
#
#
echo "****************OPEN SOCKETS ***************" >> $FNAME
/usr/sbin/lsof -p `ps -u root -opid | grep -v PID | awk 'sub(/^[ \t]+/, "")' | awk '{ str1=str1 $0 "," }END{ print str1 }'` >> $FNAME
echo "****************************************************" >> $FNAME
echo " $time" >> $FNAME
echo "**************** END *******************************" >> $FNAME
echo "****************************************************" >> $FNAME
exit 0
No comments:
Post a Comment