In this article I will go through two ways which you can monitor your server processes. One of them is very quick and uses a bash script with Cron. The other one requires a little bit more time to set up but once done it will be very simple to use with a very nice web interface.
In this article I am going to go over some Linux web server script monitors and how they can be configured to watch your processes to ensure that they do not go down at critical times (you can even be informed immediately when they do). The first such application I will go through is a quick "do-it-yourself" application involving a simple mail server and a monitor in Cron.
The second application I will go through is more sophisticated and is for more critical systems and applications. It involves a piece of free software known as webmin to watch your processes closely and it is generally more reliable than using a Cron job.
You can monitor your processes in a variety of ways using cron jobs. These jobs can run scripts for you at a specific time so you can get them to check a certain process every 5 minutes for example. If you do not know what Cron is, or how to use it, please see this article first.
Once you understand what Cron is, you start to see just how powerful it can be in this situation to automate tasks. For example, you could run a script every 5 minutes that checks if apache2 is running (/etc/init.d/apache2 status) and then if it is down, email the administrators immediately.
Here is an example of a script you could run, you just put the program name and email in the variables at the top and then allow it to run every 5 minutes. You will need mailutils before you use this script in order for it to email you if you are using Ubuntu or Debian.
Webmin is a script which allows you to administer your system from a web-based environment. It does more than just monitoring processes but that is the part I am going to highlight in this article. It is not compatible with Ubuntu unless you enable the root account, which most people in the Ubuntu community consider to be a risk. However, it should be okay for other distributions which usually have an enabled root account.
Once you have installed webmin you should be able to go to: https://localhost:10000 and login as root to access the webmin environment. Then on the left you click "others" and then "System and Server Status".
From here, it should be monitoring the services you have previously set up such as apache2. You can click on a service to configure what happens when one goes down, from here you can get the server to email you, should anything happen to the process.
In this article I have shown you two ways to monitor your processes on a server. You may want to check with your host as well as they may offer a process monitor for free. If you are using Ubuntu Linux and want to use webmin you will need to enable the root account, to do that see this article.
If you have any questions or comments please feel free to post them below and I will get back to you as soon as possible.