Monitoring custom services in the Service Monitor

djcronos

Verified User
Joined
Mar 21, 2006
Messages
76
Hello all,

I have a few custom services I wrote and would like to monitor them using the Service Monitor. Is this possible?

Thanks to everyone in advance.
 
Interesting articles.
But how could I if I would like to force a restart
of a particular service, that has been detected as being down.
 
Check the page linked to by hehachris.

Once they've been added DA should automatically try to restart them (approximately once a minute) but you should also be able to force a restart yourself.

Jeff
 
jlassman,

I followed your indications, however I still don´t realize how DA will know which script run to start a particular service

The other problem is that certain services need certain services to start themselves successfully.
 
Last edited:
BTW I tried the other monitor script. the one recommended as an alternative, that uses the grep and ps commands.

However while trying to using it, I keep receiving this error (related to ps command) about which there is not too much info

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ
3
 
Script Re-Written

Code:
#!/bin/sh

# User editable settings
service_name="spamd" # Set to name of the running service.
start_command=$(/usr/bin/spamd -d -c -m 5) # Set to the start command of the service your monitoring.
mail_command=$(/usr/bin/exim) # Set to the path of your email program. Shouldnt need editing.
email="[email protected]" # Change to your email address.

################ DONT TOUCH ##################

COUNT=$(ps xua | grep -v grep | grep -c $service_name)

if [ "$COUNT" -eq "0" ]; then
     # The command used to start the service.
     $start_command

     sleep 3

     COUNT=$(ps xua | grep -v grep | grep -c $service_name)
     if [ "$COUNT" -eq "0" ]; then
         echo -e "Subject: $service_name is down.\n\n$service_name is down.\n\n" | $mail_command $email
     fi
fi
exit 0

You can use this script inplace of the one listed at:

http://help.directadmin.com/item.php?id=64

It was just rewritten to make it easier. You can set the settings under user editable and you should be all set.

Thanks
 
Hi chatwizrd ...

Although your script seems to work fine on my box (CentOS 4.2), restarting the clamd service dropped intentionally ...

When the service is running fine, I get this error message that seems to be related to Exim... the question now is why does it try to be executed if clamd is up?
 
Well what the script does is uses the ps command to see if clamd is running. It will search for the keyword you set as service_name.

It will come back with a number to see how many of that process are running. If the number is 0 then it will attempt a restart.

So you must make sure that service_name is exactly the name of the running process.

I can help you fix this script if it is buggy for some reason or another. It was originally designed by Directadmin staff.
 
Monitoring Tomcat

Dear Users,
Hello,

I was going through this link http://www.directadmin.com/features.php?id=487 and added tomcatd=ON in /usr/local/directadmin/data/admin/services.status but when i see service status in Direct Admin it will show tomcat there but its not running. However in background Tomcat is running.

Best Regards.
 
albatroz said:
jlassman,

I followed your indications, however I still don´t realize how DA will know which script run to start a particular service

The other problem is that certain services need certain services to start themselves successfully.

This is a very valid point. How on earth does the service know which script to run? I dont see how it knows.
 
Back
Top