Browse code

Support rsyslog and RELP protocol

Configure rsyslog and services if SYSLOG=True in localrc.
Support logging to head node if SYSLOG_HOST has head note IP.
Use RELP for remote logging to prevent dropped records.

Change-Id: I960a1b4d2a24cbd9a900e68c758f362ec3d8c78e

Dean Troyer authored on 2011/11/23 08:48:10
Showing 1 changed files
... ...
@@ -80,9 +80,6 @@ source ./stackrc
80 80
 # Destination path for installation ``DEST``
81 81
 DEST=${DEST:-/opt/stack}
82 82
 
83
-# Configure services to syslog instead of writing to individual log files
84
-SYSLOG=${SYSLOG:-False}
85
-
86 83
 # apt-get wrapper to just get arguments set correctly
87 84
 function apt_get() {
88 85
     local sudo="sudo"
... ...
@@ -186,6 +183,23 @@ if [ ! -n "$HOST_IP" ]; then
186 186
     fi
187 187
 fi
188 188
 
189
+# Normalize config values to True or False
190
+# VAR=`trueorfalse default-value test-value`
191
+function trueorfalse() {
192
+    local default=$1
193
+    local testval=$2
194
+
195
+    [[ -z "$testval" ]] && { echo "$default"; return; }
196
+    [[ "0 no false" =~ "$testval" ]] && { echo "False"; return; }
197
+    [[ "1 yes true" =~ "$testval" ]] && { echo "True"; return; }
198
+    echo "$default"
199
+}
200
+
201
+# Configure services to syslog instead of writing to individual log files
202
+SYSLOG=`trueorfalse False $SYSLOG`
203
+SYSLOG_HOST=${SYSLOG_HOST:-$HOST_IP}
204
+SYSLOG_PORT=${SYSLOG_PORT:-516}
205
+
189 206
 # Service startup timeout
190 207
 SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
191 208
 
... ...
@@ -548,6 +562,28 @@ fi
548 548
 # it since we are going to run the services in screen for simple
549 549
 cp $FILES/screenrc ~/.screenrc
550 550
 
551
+# Syslog
552
+# ---------
553
+
554
+if [[ $SYSLOG != "False" ]]; then
555
+    apt_get install -y rsyslog-relp
556
+    if [[ "$SYSLOG_HOST" = "$HOST_IP" ]]; then
557
+        # Configure the master host to receive
558
+        cat <<EOF >/tmp/90-stack-m.conf
559
+\$ModLoad imrelp
560
+\$InputRELPServerRun $SYSLOG_PORT
561
+EOF
562
+        sudo mv /tmp/90-stack-m.conf /etc/rsyslog.d
563
+    else
564
+        # Set rsyslog to send to remote host
565
+        cat <<EOF >/tmp/90-stack-s.conf
566
+*.*		:omrelp:$SYSLOG_HOST:$SYSLOG_PORT
567
+EOF
568
+        sudo mv /tmp/90-stack-s.conf /etc/rsyslog.d
569
+    fi
570
+    sudo /usr/sbin/service rsyslog restart
571
+fi
572
+
551 573
 # Rabbit
552 574
 # ---------
553 575
 
... ...
@@ -1032,6 +1068,16 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
1032 1032
     sudo sed -e "s,%ADMIN_PASSWORD%,$ADMIN_PASSWORD,g" -i $KEYSTONE_DATA
1033 1033
     # initialize keystone with default users/endpoints
1034 1034
     ENABLED_SERVICES=$ENABLED_SERVICES BIN_DIR=$KEYSTONE_DIR/bin bash $KEYSTONE_DATA
1035
+
1036
+    if [ "$SYSLOG" != "False" ]; then
1037
+        sed -i -e '/^handlers=devel$/s/=devel/=production/' \
1038
+            $KEYSTONE_DIR/etc/logging.cnf
1039
+        sed -i -e "
1040
+            /^log_file/s/log_file/\#log_file/; \
1041
+            /^log_config/d;/^\[DEFAULT\]/a\
1042
+            log_config=$KEYSTONE_DIR/etc/logging.cnf" \
1043
+            $KEYSTONE_DIR/etc/keystone.conf
1044
+    fi
1035 1045
 fi
1036 1046
 
1037 1047