Index: openacs-4/etc/keepalive/keepalive-cron.sh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/etc/keepalive/keepalive-cron.sh,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/etc/keepalive/keepalive-cron.sh 4 Jun 2006 00:45:19 -0000 1.3 +++ openacs-4/etc/keepalive/keepalive-cron.sh 24 Sep 2007 04:43:03 -0000 1.3.2.1 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh # # This script will attempt to request the db test page of a number of OpenACS # servers. If a server doesn't respond then a configurable restart shell command will @@ -13,7 +13,7 @@ # @author Peter Marklund # the next line restarts using tclsh, the trailing slash is intentional \ -exec /usr/bin/tclsh "$0" "$@" +exec /usr/local/aolserver/bin/tclsh8.4 "$0" "$@" set script_dir [file dirname [info script]] @@ -27,31 +27,41 @@ file delete -force $wget_file } - catch {exec /usr/bin/wget -O $wget_file --tries=5 ${server_url}/SYSTEM/dbtest} - + catch {exec /usr/bin/wget -O $wget_file --connect-timeout=3 --tries=5 ${server_url}/SYSTEM/dbtest} + if { [file exists $wget_file] } { - set wget_file_id [open $wget_file r] - set wget_file_contents [read $wget_file_id] - close $wget_file_id - if { [regexp {success} $wget_file_contents] } { - set responds_p 1 - } else { - set responds_p 0 - } - } else { - set responds_p 0 - } + set wget_file_id [open $wget_file r] + set wget_file_contents [read $wget_file_id] + close $wget_file_id + if { [regexp {success} $wget_file_contents] } { + set responds_p 1 + } else { + set responds_p 0 + } + } else { + set responds_p 0 + } + + # log it + set log_file $script_dir/keepalive.log + set log_file_id [open $log_file a] + set timestamp [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S}] - return $responds_p + puts $log_file_id "$timestamp -- $responds_p" + + return $responds_p } foreach {server_url restart_command} $servers_to_monitor { - if { ![server_responds_p $server_url] } { if { [catch {eval exec $restart_command} errmsg] } { - catch { exec /bin/mail -s "${server_url} did not respond to a monitoring check and could not be restarted" $mailto } + set message "${server_url} did not respond to a monitoring check and could not be restarted" } else { - catch { exec /bin/mail -s "${server_url} did not respond to a monitoring check so it was restarted" $mailto } + set message "${server_url} did not respond to a monitoring check so it was restarted" } + if { $mailto ne "" } { + catch { exec /bin/mail -s $message $mailto } + } + catch {exec /usr/bin/logger $message} } }