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!

Need Monitoring Process tool

Status
Not open for further replies.

lalan7

Technical User
Aug 5, 2004
11
CA
I need a monitoring process tool to check the process running on my server and if one died the tool will be restart them .?

Thanks
 
man ps

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 

You should really fix the tool so it doesn't die.

However, if the process doesn't fork into the background you can write a simple loop in a script:

Code:
#!/bin/ksh

while [ COBOL_STILL_EXISTS ]
do 
   yourTool  // Do not put it in the backgroun with 
done

Similarly, a shepherd process can be in the same sort of infinite loop, ps | grep for the process name, then if $? != 0, restart the tool in the background.

The actual script is left as an excercise.

Also, there are several tools that do just that sort of think for you, Big Brother is one of them, but is quite a setup task.




 
So many choices here but one simple script could be:

#!/bin/csh
set $logfile="/var/log/restart.log"
foreach DAEMON ( application1.pl another1.pl exim ldap_auth)
ps -e | fgrep "$DAEMON:t" | cut -c1-8 > /dev/null
if ( $status > 0 ) then
echo "Restarting $daemon at:" >> $logfile
date >> $logfile
$DAEMON &
endif
end

Not tested exact syntax and things taht require arguments on the startup will need to be added to the start script so it may need a tweak here and there.

Good Luck
Laurie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top