[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [master 2/6] logging, fix: setting remote logging from kicstart



Hi,

See 1 comment inline.

On 02/17/2010 05:53 PM, Ales Kozumplik wrote:
First, go through the local rsyslogd to do the remote logging like the rest of
the system does. Second, give command line higher priority than kickstart.
---
  anaconda_log.py |   19 +++++++++++++++++++
  kickstart.py    |   25 +++++++++++++++++--------
  2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/anaconda_log.py b/anaconda_log.py
index 31a8f74..d39ec47 100644
--- a/anaconda_log.py
+++ b/anaconda_log.py
@@ -22,6 +22,8 @@
  #            Michael Fulbright<msf redhat com>
  #

+import os
+import signal
  import sys
  import logging
  from logging.handlers import SysLogHandler, SYSLOG_UDP_PORT
@@ -131,4 +133,21 @@ class AnacondaLog:
          syslogHandler.setLevel(logging.DEBUG)
          logger.addHandler(syslogHandler)

+    def updateRemote(self, remote_syslog):
+        """Updates the location of remote rsyslogd to forward to.
+
+        Requires updating rsyslogd config and sending SIGHUP to the daemon.
+        """
+        PIDFILE  = "/var/run/syslogd.pid"
+        CFGFILE  = "/etc/rsyslog.conf"
+        TEMPLATE = "*.* @@%s\n"
+
+        self.remote_syslog = remote_syslog
+        with open(CFGFILE, 'a') as cfgfile:
+            forward_line = TEMPLATE %(remote_syslog,)

No need to use: "TEMPLATE %(remote_syslog,)", you can use just:
"TEMPLATE % remote_syslog", other then that ack. Feel free to psuh
with this fixed.

+            cfgfile.write(forward_line)
+        with open(PIDFILE, 'r') as pidfile:
+            pid = int(pidfile.read())
+            os.kill(pid, signal.SIGHUP)
+
  logger = AnacondaLog()
diff --git a/kickstart.py b/kickstart.py
index 43e62cf..84434b8 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -56,7 +56,8 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
  import logging
  log = logging.getLogger("anaconda")
  stdoutLog = logging.getLogger("anaconda.stdout")
-from anaconda_log import logger, logLevelMap, setHandlersLevel
+from anaconda_log import logger, logLevelMap, setHandlersLevel,\
+    DEFAULT_TTY_LEVEL

  class AnacondaKSScript(Script):
      def run(self, chroot, serial, intf = None):
@@ -513,13 +514,21 @@ class LogVolData(commands.logvol.F12_LogVolData):

  class Logging(commands.logging.FC6_Logging):
      def execute(self, anaconda):
-        setHandlersLevel(log, logLevelMap[self.level])
-
-        if self.host != "" and self.port != "":
-            logger.addSysLogHandler(log, self.host, port=int(self.port))
-        elif self.host != "":
-            logger.addSysLogHandler(log, self.host)
-
+        if logger.tty_loglevel == DEFAULT_TTY_LEVEL:
+            # not set from the command line
+            level = logLevelMap[self.level]
+            logger.tty_loglevel = level
+            storage_log = logging.getLogger("storage")
+            setHandlersLevel(log, level)
+            setHandlersLevel(storage_log, level)
+
+        if logger.remote_syslog == None and len(self.host)>  0:
+            # not set from the command line, ok to use kickstart
+            remote_server = self.host
+            if self.port:
+                remote_server = "%s:%s" %(self.host, self.port)
+            logger.updateRemote(remote_server)
+
  class NetworkData(commands.network.F8_NetworkData):
      def execute(self, anaconda):
          if self.bootProto:

Regards,

Hans


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]