PDA

View Full Version : A Quick Tool For the Upcoming Protein Change



Dyyryath
05-26-2002, 06:36 PM
I know Brian's been working hard to get the autoupdate working correctly, and I know he's feeling confident that it's going to work this time.

However...I've been burned too many times already with clients that just die, so I whipped up a quick little script to keep an eye on things.

It's only for Linux (I'll probably write a Windows version soon, though), and it requires a couple of things be present on your system before you can use it.

It requires that you have Perl installed, and that you have a mail daemon (I'm using Postfix, but Sendmail would work just fine as well) running. It also uses a couple of other system commands (ps, hostname) but they shouldn't cause any problems on a modern Linux distro.

The script also requires you to edit a few lines to contain your own information. We'll get to that in a second or two.

So how does it work? It runs via 'cron', which is a scheduler daemon used under most flavors of Unix/Linux. I've set mine to run every 10 minutes. When cron executes the script, it checks first to see if there is a current foldtrajlite lockfile. If there isn't, it knows that the client isn't running. If there is, it attempts to determine whether the process id listed in the lockfile is actually running, or if the process died unexpectedly.

If it looks like the client is running, it just exits. This check takes only a fraction of a second.

If the client is stopped, it will email the contact address with a notification that the client is stopped, when it was discovered, and on what machine. It will also attempt to restart the client, provided it hasn't already tried to restart it more times than the 'max' setting. If it has already attempted to restart the client too many times, it says so in the email notification.

To reset the number of restarts, the user will need to access the machine and delete the 'df-linux-status.dat' file.

A possible cron entry might look like this:


*/10 * * * * /usr/local/distribfold/df-linux-status.pl

I've tested it on my boxes and it works fine for my purposes. If anyone else wants to use it, or take it and modify it to suit their specific needs, it is available below.

To use it, you'll just need to edit the first few lines of the script which are pretty self-explanatory. Here's what they look like:



# --- Set the location of our DF client
my $client_directory = "/usr/local/distribfold";

# --- Set the max number of times we'll attempt to restart the client
my $max_restarts = 5;

# --- Set the command we'll use to restart the client
my $command = "./foldtrajlite -f protein -n native -df -qt";

# --- Set the email addy of the person to be notified when a client is stopped
my $email = "dyyryath\@fayettevillenc.com";

# --- Set the name of the mail program to use
my $mailer = "/usr/lib/sendmail";


A couple of things to keep in mind:

The @ sign in the email address must be preceded with a \
The mailer /usr/lib/sendmail works with both sendmail & postfix
You may want to edit the options on the startup command
This script will restart the client in the background with no terminal


The script itself is attached below. You can also view the source here (http://www.zerothelement.com/code/df-linux-status.html) without actually downloading it.

MAD-ness
05-26-2002, 10:09 PM
Great work again Dyyryath.

I am anxiously awaiting a chance to try out the windows version whenever you get a chance to whip up one.

pointwood
05-27-2002, 07:44 AM
Very cool Dyyryath! :smoking:

I only wish I had the need for such a tool :( :D

Hopefully, this tool will not be neccesary :)