Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 22dbd6d0961af8f38890321e342555e3cb684e85 1 parent 255239c
António P. P. Almeida authored

Showing 1 changed file with 5 additions and 4 deletions. Show diff stats Hide diff stats

  1. +5 4 php-relaunch
9 php-relaunch
@@ -102,9 +102,9 @@ INTERVAL=$((60 / RESPONSE_TIMEOUT))
102 102 ## Looping over the number of divisions in a minute.
103 103 for i in $(seq 1 $INTERVAL); do
104 104 ## Perform the request and check the response.
105   - TS_BEGIN_REQUEST=$(echo | $TS '%s')
  105 + TS_BEGIN_REQUEST=$(date '+ %s')
106 106 STATUS_CODE=$($CURL_PROG -I -s -m $RESPONSE_TIMEOUT $1 | sed -n '/^HTTP\/1\.1/p' | awk '{print $2}')
107   - TS_END_REQUEST=$(echo | $TS '%s')
  107 + TS_END_REQUEST=$(date '+ %s')
108 108
109 109 ## Acting on the HTTP status code returned.
110 110 case $STATUS_CODE in
@@ -121,10 +121,11 @@ for i in $(seq 1 $INTERVAL); do
121 121 relaunch_php $PHP_CGI_NAME # php-cgi
122 122 fi
123 123 ## Log the restart and send an alert.
124   - LOG_LINE="$(hostname) $STATUS_CODE PHP restarted."
  124 + FQDN_HOSTNAME=$(hostname -f)
  125 + LOG_LINE="$FQDN_HOSTNAME $STATUS_CODE PHP restarted."
125 126 echo $LOG_LINE | $TS >> $LOG_FILE
126 127 ## Send an email only if the address is a non null string.
127   - [ -n "$3" ] && (echo $LOG_LINE | $TS | $MAILX -s 'PHP restart' "$3")
  128 + [ -n "$3" ] && (echo $LOG_LINE | $TS | $MAILX -s "$FQDN_HOSTNAME PHP restart" "$3")
128 129 sleep $(max $RESPONSE_TIMEOUT 10) # give some time to normalize things
129 130 ;;
130 131 200)

0 comments on commit 22dbd6d

Please sign in to comment.
Something went wrong with that request. Please try again.