Permalink
Browse files

* The request timing is done using date. Mail subject line has the fqdn.

  • Loading branch information...
1 parent 255239c commit 22dbd6d0961af8f38890321e342555e3cb684e85 @perusio committed Dec 7, 2011
Showing with 5 additions and 4 deletions.
  1. +5 −4 php-relaunch
View
@@ -102,9 +102,9 @@ INTERVAL=$((60 / RESPONSE_TIMEOUT))
## Looping over the number of divisions in a minute.
for i in $(seq 1 $INTERVAL); do
## Perform the request and check the response.
- TS_BEGIN_REQUEST=$(echo | $TS '%s')
+ TS_BEGIN_REQUEST=$(date '+ %s')
STATUS_CODE=$($CURL_PROG -I -s -m $RESPONSE_TIMEOUT $1 | sed -n '/^HTTP\/1\.1/p' | awk '{print $2}')
- TS_END_REQUEST=$(echo | $TS '%s')
+ TS_END_REQUEST=$(date '+ %s')
## Acting on the HTTP status code returned.
case $STATUS_CODE in
@@ -121,10 +121,11 @@ for i in $(seq 1 $INTERVAL); do
relaunch_php $PHP_CGI_NAME # php-cgi
fi
## Log the restart and send an alert.
- LOG_LINE="$(hostname) $STATUS_CODE PHP restarted."
+ FQDN_HOSTNAME=$(hostname -f)
+ LOG_LINE="$FQDN_HOSTNAME $STATUS_CODE PHP restarted."
echo $LOG_LINE | $TS >> $LOG_FILE
## Send an email only if the address is a non null string.
- [ -n "$3" ] && (echo $LOG_LINE | $TS | $MAILX -s 'PHP restart' "$3")
+ [ -n "$3" ] && (echo $LOG_LINE | $TS | $MAILX -s "$FQDN_HOSTNAME PHP restart" "$3")
sleep $(max $RESPONSE_TIMEOUT 10) # give some time to normalize things
;;
200)

0 comments on commit 22dbd6d

Please sign in to comment.