Server monitoring using shell script

I want to write a shell script which is used in cron job and it runs every 4 hours to check whether tomcat servers are running or not . If servers are not running , one email should be triggered like alert notification. if servers are Running then no need to print anything.

This is what i want to achieve through shell script

Can you please guide me how to write these or better approach to write this. Thanks in advance.

Hi,

What have you tried so far?

Gull04

So far I tried using by command "netstat" and grep.
But alternatively I need script for cron job is should run for every 4 hours and send email when server is down

Hi,

I'm not sure how you would achieve your goal using netstat , you should read this thread for some help with this matter.

Regards

Gull04

Sure gull04.

I will go through this link.

Well, you can write a script that will execute something like 'service tomcat status', parse output with grep and start it if they didn't run.

It's a common job actually.

You can use a supervisord instead, which can run any service or program and immediately restart if it.

Or you can use Munin for the same goal: monitor the service or process and start if it's fail. You can look for some examples here.

I'd suggest you to invest some time to learn a well known and supported tool instead of making a your own script.