From 9b7f4f6d50aae3a0d27c2b63e7281d6b7cfcc5d2 Mon Sep 17 00:00:00 2001 From: Tim Laszlo Date: Wed, 26 May 2010 18:23:14 +0000 Subject: Add option to log importscript.py messages to syslog Since we need the ability to do this for DBStats.py it doesn't hurt to add this if importscript.py runs with statistics.xml data. git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5868 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Reports/importscript.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/lib/Server/Reports/importscript.py') diff --git a/src/lib/Server/Reports/importscript.py b/src/lib/Server/Reports/importscript.py index 8b0b5b144..017bfd470 100755 --- a/src/lib/Server/Reports/importscript.py +++ b/src/lib/Server/Reports/importscript.py @@ -218,22 +218,17 @@ if __name__ == '__main__': cpath = "/etc/bcfg2.conf" clientpath = False statpath = False + syslog = False try: - opts, args = getopt(argv[1:], "hvudc:s:C", ["help", "verbose", "updates" , + opts, args = getopt(argv[1:], "hvudc:s:CS", ["help", "verbose", "updates" , "debug", "clients=", "stats=", - "config="]) + "config=", "syslog"]) except GetoptError, mesg: # print help information and exit: - print "%s\nUsage:\nimportscript.py [-h] [-v] [-u] [-d] [-C bcfg2 config file] [-c clients-file] [-s statistics-file]" % (mesg) + print "%s\nUsage:\nimportscript.py [-h] [-v] [-u] [-d] [-S] [-C bcfg2 config file] [-c clients-file] [-s statistics-file]" % (mesg) raise SystemExit, 2 - logger = logging.getLogger('importscript.py') - logging.getLogger().setLevel(logging.INFO) - Bcfg2.Logger.setup_logging('importscript.py', - True, - False) - for o, a in opts: if o in ("-h", "--help"): print "Usage:\nimportscript.py [-h] [-v] -c -s \n" @@ -244,6 +239,7 @@ if __name__ == '__main__': print "C : path to bcfg2.conf config file." print "c : clients.xml file" print "s : statistics.xml file" + print "S : syslog; output to syslog" raise SystemExit if o in ["-C", "--config"]: cpath = a @@ -259,6 +255,14 @@ if __name__ == '__main__': if o in ("-s", "--stats"): statpath = a + if o in ("-S", "--syslog"): + syslog = True + + logger = logging.getLogger('importscript.py') + logging.getLogger().setLevel(logging.INFO) + Bcfg2.Logger.setup_logging('importscript.py', + True, + syslog) cf = ConfigParser.ConfigParser() cf.read([cpath]) -- cgit v1.2.3-1-g7c22