script for monitoring service

Hi,

I am new to shell programming,

I would like to write a script which will monitor sendmail service in linux, and if service goes down it will send the mail

can you please suggest me how to monitor the service?

Regards,

Manoj

First, check if the process is still there using ps and grep
Second, if you can, try and connect to TCP port 25 and try to get an reaction out of it.

But more fundamentally: if the mail service is down, how do you intent to send a mail telling you it's down? I'd solve that one first.

Maybe SSH to another box and issue the mail command there..?