Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

monitoring bogus(invalid) processes

Status
Not open for further replies.

icu812

MIS
Sep 10, 2001
52
US
I have an intermittent problem whereby a process respawns itself and causes the system to lock up. Can someone please tell me how to monitor this process in a ksh script. I'm thinking I could use ps -ef|grep <processname>|wc -l. If the number returned by this command exceeds 175 I want to be paged. How can I write a korn shell script to accomplish this?????? Thanks in advance
 
num=`ps -ef | grep [processname]|grep -v grep |wc -l|awk {'print $1'}`
if [ &quot;$num&quot; -ge &quot;175&quot; ] ; then
page you however you do that
fi
 
hmmm
why do you awk the wc -l ?
and btw its awk '{ ....}' not awk {' ... '}

no ?

 
The &quot;awk&quot; removes the leading spaces, and the {''} combination works either way under 4.3.3.

/home/OPERATOR/bin> ls -la |wc -l|awk {'print $1'}
19
/home/OPERATOR/bin> ls -la |wc -l|awk '{print $1}'
19

Bill :)
 
Instead of using this:
num=`ps -ef | grep sendmail|grep -v grep |wc -l|awk {'print $1'}

I found this would do the same for me:

num=`ps -ef | grep endmail|wc -l`


Or am I missing something else here?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top