FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Kernel

 
 
LinkBack Thread Tools
 
Old 02-17-2010, 03:53 PM
Ales Kozumplik
 
Default logging, fix: setting remote logging from kicstart

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
"
+
+ self.remote_syslog = remote_syslog
+ with open(CFGFILE, 'a') as cfgfile:
+ forward_line = TEMPLATE %(remote_syslog,)
+ 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:
--
1.6.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-18-2010, 06:22 AM
Hans de Goede
 
Default 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
"
+
+ 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

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-18-2010, 07:53 AM
Ales Kozumplik
 
Default logging, fix: setting remote logging from kicstart

On 02/18/2010 08:22 AM, Hans de Goede wrote:


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.



Thanks, I wonder why I learned the ugly way.

Ales

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-18-2010, 07:58 AM
Hans de Goede
 
Default logging, fix: setting remote logging from kicstart

Hi,

On 02/18/2010 09:53 AM, Ales Kozumplik wrote:

On 02/18/2010 08:22 AM, Hans de Goede wrote:


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.



Thanks, I wonder why I learned the ugly way.



Well if you have more then one format specifier (so more
then one format arg) then the ugly way is necessary.

Regards,

Hans

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 11:57 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org