3 # Configures the rsyslog daemon.
4 # Source functions library
5 .
/etc
/init.d
/functions
6 .
/usr
/libexec
/ovirt-functions
8 trap '__st=$?; stop_log; exit $__st' 0
9 trap 'exit $?' 1 2 13 15
11 if ! is_local_storage_configured
; then
12 printf "Local storage must be configured prior to configuring the logging system.\n"
16 RSYSLOG_FILE
="/etc/rsyslog.conf"
18 # Creates the rsyslog file based on the following inputs
19 # $1 ipaddress of remote syslog server
20 # $2 port of remote syslog server
21 # $3 protocol (tcp or udp)
22 # TODO implement and use Augeas lens
23 function ovirt_rsyslog
{
25 if [ "$3" = "tcp" ]; then
30 cat > $RSYSLOG_FILE << EOF
31 #ovirt rsyslog config file
34 \$ModLoad imuxsock.so # provides support for local system logging (e.g. via logger command)
35 \$ModLoad imklog.so # provides kernel logging support (previously done by rklogd)
37 #### GLOBAL DIRECTIVES ####
38 # Use default timestamp format
39 \$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
42 # Log anything (except mail) of level info or higher.
43 # Don't log private authentication messages!
44 *.info;mail.none;authpriv.none;cron.none /var/log/messages
46 # The authpriv file has restricted access.
47 authpriv.* /var/log/secure
49 # Log all the mail messages in one place.
50 mail.* -/var/log/maillog
55 # Everybody gets emergency messages
58 # Save news errors of level crit and higher in a special file.
59 uucp,news.crit /var/log/spooler
61 # Save boot messages also to boot.log
62 local7.* /var/log/boot.log
64 \$WorkDirectory /var/spool/rsyslog
65 \$ActionQueueFileName ovirtNode
66 \$ActionQueueMaxDiskSpace 10m
67 \$ActionQueueSaveOnShutdown on
68 \$ActionQueueType LinkedList
69 \$ActionResumeRetryCount -1
74 /sbin
/service rsyslog restart
79 printf "$1" |
grep -q -E '^[0-9]+$'
82 function prompt_user
{
90 read -p "What is the max size, in kilobytes, for local log files (def. ${max_log_size}k)? "
92 if [ -n "$REPLY" ]; then
94 if [[ $r =~ ^
[0-9]+$
]] && [[ $r -gt 0 ]]; then
96 printf "\nMaximum logging size will be ${max_log_size}k.\n"
99 printf "\nInvalid input.\n"
102 printf "\nLeaving log size as ${max_log_size}k.\n"
108 read -p "What is the IP address for the syslog server, hit Enter to skip? "
109 if [ -n "$REPLY" ]; then
110 syslog_server_ip
=$REPLY
112 read -p "Please enter the remote logging port used: "
115 if [[ $r =~ ^
[0-9]+$
]] && [[ $r -gt 0 ]]; then
116 syslog_server_port
=$REPLY
119 printf "Invalid port.\n"
126 read -p "Remote logging uses [t]cp or [u]dp? "
127 r
=$
(echo $REPLY|
tr '[[:lower:]]' '[[:upper:]]')
128 if [ "$r" == "T" ]; then syslog_server_protocol
="tcp"; break; fi
129 if [ "$r" == "U" ]; then syslog_server_protocol
="udp"; break; fi
131 printf "Invalid input.\n"
134 printf "\nDisabling remote logging.\n"
138 printf "\nLogging will be configured as follows:"
139 printf "\n======================================"
140 printf "\n Max Logfile Size: $max_log_size"
141 if [ -n "$syslog_server_ip" ]; then
142 printf "\n Remote Server: $syslog_server_ip"
143 printf "\n Remote Port: $syslog_server_port"
144 printf "\n Logging Protocol: $syslog_server_protocol"
149 ask_yes_or_no
"Is this correct ([Y]es/[N]o/[A]bort)?" true true
152 printf "\nSaving configuration.\n"
153 if [[ -n "$syslog_server_ip" ]] &&
154 [[ -n "$syslog_server_port" ]] &&
155 [[ -n "$syslog_server_protocol" ]]; then
156 ovirt_rsyslog
$syslog_server_ip \
157 $syslog_server_port \
158 $syslog_server_protocol
160 sed -c -i -e "s/size.*/size ${max_log_size}k/" \
161 /etc
/logrotate.d
/ovirt-node
165 printf "\nRestarting logging configuration.\n"
169 printf "\nAborting logging configuration.\n"
177 function ovirt_netconsole
{
179 set /files/etc/sysconfig/netconsole/SYSLOGADDR $OVIRT_NETCONSOLE_SERVER
180 set /files/etc/sysconfig/netconsole/SYSLOGPORT $OVIRT_NETCONSOLE_PORT
182 ovirt_store_config
/etc
/sysconfig
/netconsole
184 # AUTO for auto-install
185 if [ "$1" = "AUTO" ]; then
186 if [ -z "$OVIRT_SYSLOG_SERVER" -o -z "$OVIRT_SYSLOG_PORT" ]; then
187 printf "\nAttempting to locate remote syslog server..."
189 if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
190 printf "found! Using syslog server '$SRV_HOST:$SRV_PORT'.\n"
191 ovirt_rsyslog
$SRV_HOST $SRV_PORT udp
193 printf "not found!\n"
196 printf "\nUsing default syslog server '$OVIRT_SYSLOG_SERVER:$OVIRT_SYSLOG_PORT'.\n"
197 ovirt_rsyslog
$OVIRT_SYSLOG_SERVER $OVIRT_SYSLOG_PORT udp
199 if [ -n "$OVIRT_NETCONSOLE_SERVER" -a -n "$OVIRT_NETCONSOLE_PORT" ]; then
200 printf "\nConfiguring netconsole server..."
204 printf "\n\n Logging Configuration\n\n"