ArsDigita Keepalive

by Ben Adida and Philip Greenspun (web interface by Steven Pulito), part of ArsDigita Free Tools
ArsDigita Keepalive is a system that monitors your web services at regular, short intervals, and takes action to resolve problems found. If Keepalive fails to reach a page, depending on how many consecutive previous failures it has seen and the configuration parameters, it will take one of the following actions: Keepalive is built using AOLserver (free) and takes advantage of AOLserver's built-in scheduler (like Unix cron but lighter weight) and Tcl API (includes a call to HTTP GET a page from another server). However, unlike most of our AOLserver products, you don't need to install an RDBMS in order to use Keepalive. Web servers generally get stuck because of problems with the RDBMS, so a monitor that depended on an RDBMS would be self-defeating.

Although we generally use Keepalive to monitor AOLserver-based Web services, it will work fine to monitor any HTTP service on a Unix machine.

Installation

Security

In order to run a secure Keepalive installation it is very important that you run a SSL enabled server. In order to do this you will need to install one of the available nsssl modules and configure it as well as get your signed certificate/key files in place.

WARNING: If an intruder gains unauthorized access to your keepalive server they will be able to execute arbitrary commands by setting the failure action. To restrict the Keepalive pages to SSL make sure that the following line in defs.tcl is uncommented:

ns_register_filter preauth GET /keepalive/* ad_restrict_to_https

Operation

In the past in order to maintain Keepalive it was necessary to edit the configuration file by hand. This is no longer the case as there is now a web interface for editing the configuration file.

Direct your web browser to the host name specified in your AOLserver configuration. You will be redirected to the main Keepalive page. Initially there won't be any servers listed. This can be rectified by clicking on the add a service link. When adding a new service you will have to specify the following:

Also please note that many of the error pages are quite rudimentary, sometimes only displaying what went wrong. In almost all cases simply press the back button in your browser and correct the problem.

Which Shell Command?

You might well ask yourself which shell command will restart a Web server. It depends. In the case of AOLserver, we run the server by inserting a line in /etc/inittab:
nsjw:34:respawn:/home/nsadmin/bin/nsd -i -c /home/nsadmin/nsd.ini
which tells Unix to restart nsd if it should die for any reason. Thus keepalive just needs to kill the existing nsd process. The problem is that Web servers must be owned by root if they are to grab Port 80 and Keepalive can't kill a Web server unless it runs as root (a security risk). The solution at ArsDigita is to build a setuid Perl script that Keepalive can call: restart-aolserver
#!/usr/local/bin/perl

## Restarts an AOLserver. Takes as its only argument the name of the server to kill.

## This is a perl script because it needs to run setuid root, 
## and perl has fewer security gotchas than most shells.


$ENV{'PATH'} = '/sbin:/bin';

# uncomment this stuff if you're at an installation where a server 
# takes a long time to restart or keeps important state

# if (scalar(@ARGV) == 0) {
#     die "Don't run this without any arguments!";
# }

$server = shift;

$< = $>; # set realuid to effective uid (root)

sub getpids {
    ## get the PIDs of all jobdirect servers
    my $ps_output = `/usr/bin/ps -ef`;
    my @pids;
    foreach (split(/\n/, $ps_output)) {
        next unless /^\s*\S+\s+(\d+).*nsd.*$server.ini/;
        push(@pids, $1);
    }
    @pids;
}

@pids = &getpids;
print "Killing ", join(" ", @pids), "\n";
kill 'KILL', @pids;

Upgrading

If you are replacing an older version of Keepalive you avoid having to re-enter the configuration information by following the following steps:

Testing

Please perform the following tests to make sure you have a complete working installation of Keepalive:

License

This is open-source software, copyright 1998 ArsDigita, LLC and licensed under the GNU General Public License.

Support and Customization

If you want a extended version of Keepalive or support, you can hire the programmer of your choice to install, maintain, and customize keepalive. ArsDigita offers support as well, but probably not at a price that you'd be happy to pay.
stevenp@arsdigita.com

Advertisements