Need help using Monit and monitoring a process

General support questions including new installations
Post Reply
AJ800
Posts: 3
Joined: 2014/03/18 18:05:45

Need help using Monit and monitoring a process

Post by AJ800 » 2014/03/18 18:43:33

We're using Avaya IP Office and our Voicemail server is installed on a CentOS machine with no GUI. I'm a Linux newbie so bear with me here. There is a service which is part of Voicemail Pro that is basically responsible for the proper operation our entire phone system (it is our answering system). For some reason, this service stops randomly - sometimes once every few days, sometimes a few times a day. I have a feeling it is because we were told to record all calls because this started happening when we set this to do so. The software has a web interface which shows that service and one other running or not. It has a button you can click to start or stop the service, so when it stops, it's as simple as logging in and clicking it to restart it. It does NOT explain why it stopped nor does it start itself once it stops, which it is supposed to do. The system resources appear to be normal, where the CPU does not seem to go above 15% and the memory of that process only hits an average of less that 30MB, while the other service runs at 600+MB and never stops.

Since this system has been delicate, and support is very difficult, if I can't find the root cause of this (which may simply be a program bug) all I want to do is install a program that monitors processes and starts them automatically if they've stopped for whatever reason. I looked up a few things and a program called 'Monit' was at the top of the list. I was able to install it in a Virtual Machine for testing, but the problem is, in CentOS on the actual machine, when I run the following command:

Code: Select all

services --status-all
I get a list a processes, some which show in parenthesis a pid number "[process] (pid 2344) is running", some which only show "[process] is running" which seems to be the case with the one I am looking for - HOWEVER - the process name has a space in it. It appears as follows:

Code: Select all

VoiceMail Pro is running
and is followed by another line below it that gives info about the CPU/Uptime, etc.

Monit seems to require a PID file to monitor processes. Here is the syntax of the configuration file it is using for checking that a process is running:

Code: Select all

check process [process-name] with pidfile /usr/local/folder/process.pid
         start program = "/etc/init.d/processname start" with timeout 60 seconds
         stop program = "/etc/init.d/processname stop"
Apparently, you need 2 things: a PID file and the associated service/process name. So here are my questions:

1. Is that command i used above to find processes running ('service --status-all') the right one to use to find the process name I need? If so, why does it have a space, and will that be a problem? If not, how do I find the actual system name for the process I want to monitor?
2. How can I find the PID file associated with this process? Does it even exist? What if it doesn't? Can I make one for this purpose?
3. When I do a listing of the init.d directory, it shows a file named 'vmpro'. Should this be the 'process-name' or the 'processname' (as used in the code above)?
4. There does not seem to be any associated file to this program inside the /var/run directory where other pid files are. Is this normal?

drk
Posts: 405
Joined: 2014/01/30 20:38:28

Re: Need help using Monit and monitoring a process

Post by drk » 2014/03/18 19:27:09

AJ800 wrote:1. Is that command i used above to find processes running ('service --status-all') the right one to use to find the process name I need? If so, why does it have a space, and will that be a problem? If not, how do I find the actual system name for the process I want to monitor?
'ps' and 'top' may help you out some. As for finding a PID of a program you can use 'pgrep'
2. How can I find the PID file associated with this process? Does it even exist? What if it doesn't? Can I make one for this purpose?
There may or may not be a PID file depending on how the app was made.
3. When I do a listing of the init.d directory, it shows a file named 'vmpro'. Should this be the 'process-name' or the 'processname' (as used in the code above)?
It won't necessarily be the process name but you can look at it (it is just a script) to find out what is actually being run.
4. There does not seem to be any associated file to this program inside the /var/run directory where other pid files are. Is this normal?
See #2

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Need help using Monit and monitoring a process

Post by gerald_clark » 2014/03/18 19:33:55

Neither Voicemail Pro nor monit are CentOS programs.
You may be able to get some help from The Avaya Users Group http://www.iaug.org/p/fo/et/thread=39060

AJ800
Posts: 3
Joined: 2014/03/18 18:05:45

Re: Need help using Monit and monitoring a process

Post by AJ800 » 2014/03/20 20:14:56

Actually there is a version of MONIT for CentOS and I have it running successfully when testing another process.

That last obstacle I've run into is for VoiceMail Pro: So far, I've found the process name and location I need to restart but the program does not have a PID file which is required for reference. Other processes have PID files in /var/run which contain the current PID number of the corresponding process. Is there a script I can use to output a PID file for this process? One that will change with the start/stop of that process? (I need it to change dynamically with reboots and stoppage of that process - it creates a new PID number if the process has stopped and is restarted again)

AJ800
Posts: 3
Joined: 2014/03/18 18:05:45

Re: Need help using Monit and monitoring a process

Post by AJ800 » 2014/03/21 20:08:42

To update, and for future reference for anyone who may encounter this, a partner and I came up with a method to get it working using a script to create the PID file needed for MONIT to monitor this service. While not a perfect setup, it works. Here is what we did:

Inside the /bin directory, a script file was created as follows:

Code: Select all

#!/bin/sh
PID_PATH_NAME=/var/run/myprocess.pid
PATH_TO_myprocessname=/etc/init.d
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0
case $1 in
  start)
   sh $PATH_TO_myprocessname/myprocess start
    echo $$ > $PID_PATH_NAME
  ;;
  stop)
   sh $PATH_TO_myprocess/myprocess stop
    PID=$(cat $PID_PATH_NAME);
    kill $PID;
  ;;
  restart)
   sh $PATH_TO_myprocessname/myprocess stop
   sh $PATH_TO_myprocessname/myprocess start
    echo $$ > $PID_PATH_NAME
  ;;
 esac
exit 0

In the configuration file for MONIT, this is the syntax for that service to be monitored:

Code: Select all

check process myprocess with pidfile /var/run/myprocess.pid
  start program = "/bin/myprocessscript start" with timeout 60 seconds
  stop program = "/etc/init.d/myprocess stop"
This was enough to get the program to be monitored and restarted automatically, but in MONIT's web interface where it displays the programs it is monitoring, it showed "Execution failed" as its status rather than "running" which it should show, although it was working, and since we tested by manually stopping the process. The process did restart but I haven't yet figured out how it is actually monitoring the process to produce the "running" status. The software itself has a feature that shows it's status elsewhere and it running/uptime, so we're ok with that for now. Any suggestions on that matter are appreciated.

Post Reply