[RndTbl] Tips for isolating causes of system load

John Lange john.lange at open-it.ca
Sat Feb 12 17:21:49 CST 2005


Thanks Sean.

Based on that tip (I hadn't realized that "apachectl fullstatus" outputs
to stdout) I have come up with just about the ugliest bash script every
written! But it works...

This takes the top 5 most CPU intensive processes and looks for the ones
owned by the "www" user. It then re-greps for that process id so it can
spit out the entire line from "ps". Then it also greps "apachectrl
fullstatus" for the same PID so we can see what that process is actually
doing.

If this doesn't make you bash scripters out there cringe I don't think
anything will... ;)

---
for PID in `ps -weo pid,%cpu,user,args --sort %cpu |tail -n5|grep
www|cut -f1 -d " "`; do ps -weo pid,%cpu,user,args --sort %cpu |grep -v
grep|grep $PID ; apachectl fullstatus |grep -A1 $PID; done
---

The obvious problems with this are:

- It invokes way to many processes (some of them more than once)
- loops through "fullstatus" every time.

The only other problem is that lynx truncates the longer request lines
at 80 columns so you are missing part of what the client is requesting
that is causing the load.

If anyone has some suggestions for how to clean that up please feel free
to suggest them.

I'm actually a bit dismayed that Apache doesn't have better command line
tools for querying the status of the server.

John

On Sat, 2005-02-12 at 13:47, Sean Cody wrote:
> > Anyone have any suggestions for a little bash script that could do this
> > auto-magically?
> 
> 'apachectl fullstatus' seems to work alright for me.  Not immediately 
> as intuitive but it does work.




More information about the Roundtable mailing list