Bryan Kearney
2008-Nov-11 14:07 UTC
[Ovirt-devel] [PATCH node] RSyslog configuration for standalone mode.
It looks for a DNS service locator record by default, and lets the user override if desired. Supports setting the maximum log file size. Includes comments from Alan Pevec and Jim Meyering. --- scripts/ovirt-config-logging | 143 ++++++++++++++++++++++++++++++++++++++++++ scripts/ovirt-config-setup | 2 + 2 files changed, 145 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-logging b/scripts/ovirt-config-logging index 8b13789..fb5f96e 100755 --- a/scripts/ovirt-config-logging +++ b/scripts/ovirt-config-logging @@ -1 +1,144 @@ +#!/bin/bash +# +# Configures the rsyslog daemon. +# Source functions library +. /etc/init.d/functions +. /etc/init.d/ovirt-functions + + +RSYSLOG_FILE="/etc/rsyslog.conf" + +# Creates the rsyslog file based on the following inputs +# $1 ipaddress of remote syslog server +# $2 port of remote syslog server +# $3 protocol (tcp or udp) +function ovirt_rsyslog { + +if [[ "$3" = "tcp" ]]; then + DELIM="@@" +else + DELIM="@" +fi + +cat > $RSYSLOG_FILE << EOF +#ovirt rsyslog config file + +#### MODULES #### +\$ModLoad imuxsock.so # provides support for local system logging (e.g. via logger command) +\$ModLoad imklog.so # provides kernel logging support (previously done by rklogd) + +#### GLOBAL DIRECTIVES #### +# Use default timestamp format +\$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat + +#### RULES #### +# Log anything (except mail) of level info or higher. +# Don't log private authentication messages! +*.info;mail.none;authpriv.none;cron.none /var/log/messages + +# The authpriv file has restricted access. +authpriv.* /var/log/secure + +# Log all the mail messages in one place. +mail.* -/var/log/maillog + +# Log cron stuff +cron.* /var/log/cron + +# Everybody gets emergency messages +*.emerg * + +# Save news errors of level crit and higher in a special file. +uucp,news.crit /var/log/spooler + +# Save boot messages also to boot.log +local7.* /var/log/boot.log + +\$WorkDirectory /var/spool/rsyslog +\$ActionQueueFileName ovirtNode +\$ActionQueueMaxDiskSpace 10m +\$ActionQueueSaveOnShutdown on +\$ActionQueueType LinkedList +\$ActionResumeRetryCount -1 +*.* $DELIM$1:$2 +EOF + +/sbin/service rsyslog restart +} + +function prompt_user { + while true ; do + MAX_LOG_SIZE="10k" + printf "\nWhat is the max size for log files on this machine [10k]? " + read + if [[ "$REPLY" != "" ]]; then + MAX_LOG_SIZE=$REPLY + fi + printf "\nWhat is the IP address or server name for the syslog server? " + read + SYSLOG_SERVER_IP=$REPLY + printf "\nWhat port does the syslog daemon run on? " + read + if [[ "$REPLY" =~ '^[0-9]+$' ]]; then + SYSLOG_SERVER_PORT=$REPLY + + PROTOCOLS="tcp udp" + PS3="Please select the protocol to use: " + select SYSLOG_SERVER_PROTOCOL in $PROTOCOLS; + do + case $SYSLOG_SERVER_PROTOCOL in + "tcp") + break ;; + "udp") + break;; + esac + done + + printf "\n" + printf "\nLogging will be configured as follows:" + printf "\n======================================" + printf "\n Max Logfile Size: $MAX_LOG_SIZE" + printf "\n Remote Server: $SYSLOG_SERVER_IP" + printf "\n Remote Port: $SYSLOG_SERVER_PORT" + printf "\n Logging Protocol: $SYSLOG_SERVER_PROTOCOL" + printf "\n" + printf "\nPlease confirm these changes (Y/N)" + read + case $REPLY in + Y|y) + ovirt_rsyslog $SYSLOG_SERVER_IP \ + $SYSLOG_SERVER_PORT \ + $SYSLOG_SERVER_PROTOCOL + sed -i -e "s/^size=.*/size=$MAX_LOG_SIZE/" \ + /etc/logrotate.d/ovirt-logrotate.conf + break + ;; + N|n) + printf "Discarding settings\n" + break + ;; + esac + else + printf "Invalid port number\n" + fi + done + +} + +# check if we were called to attempt to default +# to remote logging +if [[ "$1" = "default" ]] ; then + printf "\nAttempting to locate remote syslog server..." + find_srv syslog udp + if [[ "$SRV_PORT" != "" ]] && [[ "$SRV_SERVER" != "" ]] ; then + printf "found! Useing server '$DEFAULT_SERVER:$DEFAULT_PORT'.\n" + ovirt_rsyslog $DEFAULT_SERVER $DEFAULT_PORT "udp" + else + printf "not found!\n" + fi +else + prompt_user +fi + +exit 0 diff --git a/scripts/ovirt-config-setup b/scripts/ovirt-config-setup index 8408d14..5850aa8 100755 --- a/scripts/ovirt-config-setup +++ b/scripts/ovirt-config-setup @@ -2,6 +2,8 @@ # # Entry point for configuring an oVirt node when running in standalone mode. +#Attempt to default the syslog setting +ovirt-config-logging "default" while true; do PS3="Please select an option: " # TODO should we make this optional, based on whether the password was already set? -- 1.5.6.5
Durn it. THis has the changes which Jim asked for in the ACK email. Darryl.. can you please push when you push your main patch. Thank you! -- bk Bryan Kearney wrote:> -- bk > > > _______________________________________________ > Ovirt-devel mailing list > Ovirt-devel at redhat.com > https://www.redhat.com/mailman/listinfo/ovirt-devel