Skip to Content.
Sympa Menu

shibboleth-dev - [Shib-Dev] log report tool (resent)

Subject: Shibboleth Developers

List archive

[Shib-Dev] log report tool (resent)


Chronological Thread 
  • From: Peter Schober <>
  • To:
  • Subject: [Shib-Dev] log report tool (resent)
  • Date: Wed, 4 Aug 2010 16:18:00 +0200
  • Organization: Vienna University Computer Center

Chad, could you commit this please?
-peter
--- Begin Message ---
  • From: Peter Schober <>
  • To:
  • Subject: [Shib-Dev] log report tool
  • Date: Mon, 5 Jul 2010 14:59:59 +0200
  • List-archive: <https://lists.internet2.edu/sympa/arc/shibboleth-dev>
  • List-id: <shibboleth-dev.internet2.edu>
  • Organization: Vienna University Computer Center
Some code cleanup for SC-30 attached.
https://svn.middleware.georgetown.edu/shib-extension/java-idp-log-analysis/trunk
Could someone commit this please, I can't seem to be able to attach
this to SC-30 after the Jira upgrade (or maybe not to closed issues).
-peter
=== modified file 'loganalysis.py' (properties changed: -x to +x)
--- loganalysis.py	2010-03-16 12:54:12 +0000
+++ loganalysis.py	2010-05-20 22:01:02 +0000
@@ -15,40 +15,19 @@
 # limitations under the License.
 #
 
-"""Parse Shibboleth 2.1 Identity Provider audit logfile and generate simple stats.
+"""Parse Shibboleth 2.x Identity Provider audit logfile and generate simple stats.
    Audit log file format: https://spaces.internet2.edu/display/SHIB2/IdPLogging""";
    
-import sys
+import sys,fileinput
 from optparse import OptionParser
 from operator import itemgetter
 
-def getLines(files):
-    """Return lines from file(s) or STDIN."""
-    lines = []
-    for file in files:
-        if file != "-":
-            try:
-                for line in open(file, "r"):
-                    lines.append(line)
-            except IOError:
-                print "File '" + file + "' not found."
-                sys.exit(-1)
-        else:
-            for line in sys.stdin:
-                lines.append(line)
-    return lines
-
-def linesFromFiles(files):
-    """Return lists (events) of lists (data fields)."""
-    lines = getLines(files)
-    table = []
-    for line in lines:
-        table.append(line.rstrip().split("|"))
-    return table
-
 def parseFiles(files,options):
     """Build datastructures from lines."""
-    lines = linesFromFiles(files)
+    lines = []
+    for line in fileinput.input(files):
+        lines.append(line.rstrip().split("|"))
+
     db = {}
     db['rp'], db['users'], db['msgprof'], db['logins'] = {},{},{},0
 
@@ -171,13 +150,10 @@
         parser.error("Options -p and -n are mutually exclusive (just use one or the other).")
 
     # Make sure that at least one option is set, otherwise don't bother parsing any logfiles
-    hasOpt = False
     for value in options.__dict__.values():
         if value:
-            hasOpt = True
+            db = parseFiles(args,options)
             break
-    if hasOpt:
-        db = parseFiles(args,options)
     else:
         print "Missing option: At least one option needs to be supplied.\n"
         parser.print_help()


--- End Message ---



Archive powered by MHonArc 2.6.16.

Top of Page