aboutsummaryrefslogtreecommitdiffstats
path: root/src/extras/htmlog
diff options
context:
space:
mode:
authornavid <navid@ef72aa8b-4018-0410-8976-d6e080ef94d8>2007-08-17 13:42:51 +0000
committernavid <navid@ef72aa8b-4018-0410-8976-d6e080ef94d8>2007-08-17 13:42:51 +0000
commit8092e9862adb06e6cec8f02e0dfe3d8a50030949 (patch)
treea764e897e8e571914346f29e8e2123647505cacc /src/extras/htmlog
parentb451a9da5eedbacd9216409cf8e21b19a0d848c6 (diff)
downloadsos-8092e9862adb06e6cec8f02e0dfe3d8a50030949.tar.gz
merged navid-dev -r r350:r364 into trunk/rhel-5-startr1.7-8
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@368 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src/extras/htmlog')
-rwxr-xr-xsrc/extras/htmlog55
1 files changed, 42 insertions, 13 deletions
diff --git a/src/extras/htmlog b/src/extras/htmlog
index d4680eea..387a5d90 100755
--- a/src/extras/htmlog
+++ b/src/extras/htmlog
@@ -1,16 +1,17 @@
#!/usr/bin/env python
-from optparse import OptionParser, Option
-import time, sys, os
-
-__cmdParser__ = OptionParser()
-__cmdParser__.add_option("-i", "--input", action="append", \
- dest="logfiles", type="string", \
- help="system log to parse")
-__cmdParser__.add_option("-v", "--verbose", action="count", \
- dest="verbosity", \
- help="How obnoxious we're being about telling the user what we're doing.")
-(__cmdLineOpts__, __cmdLineArgs__)=__cmdParser__.parse_args()
+#from optparse import OptionParser, Option
+import time, sys, os, glob
+import getopt
+
+#__cmdParser__ = OptionParser()
+#__cmdParser__.add_option("-i", "--input", action="append",
+# dest="logfiles", type="string", metavar = "FILE",
+# help="system log to parse")
+#__cmdParser__.add_option("-v", "--verbose", action="count",
+# dest="verbosity",
+# help="How obnoxious we're being about telling the user what we're doing.")
+#(__cmdLineOpts__, __cmdLineArgs__)=__cmdParser__.parse_args()
class host_class:
@@ -96,7 +97,6 @@ class host_class:
self.fp().seek(0)
continue
else:
- sys.exit("HOST IS EOF")
return ""
if self.validate_line(toret) or toret == "":
@@ -139,6 +139,7 @@ class logfile_class:
def time_end(self):
pos = self.fp.tell()
bs = 1024
+ if self.size() < bs: bs = self.size()
self.fp.seek(-bs, 2)
line = self.fp.read(bs)
toret = time.strptime(line[line.rfind("\n", 0, bs - 1) + 1:][0:15], "%b %d %H:%M:%S")
@@ -201,15 +202,43 @@ class logfile_class:
print "could not parse time", self.curline
return False
+def usage():
+ print "ciao"
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "hi:v", ["help", "input="])
+except getopt.GetoptError:
+ # print help information and exit:
+ usage()
+ sys.exit(2)
+
+cmdline = {}
+cmdline["logfiles"] = []
+
+for o, a in opts:
+ if o == "-v":
+ verbose = True
+ if o in ("-h", "--help"):
+ usage()
+ sys.exit()
+ if o in ("-i", "--input"):
+ print o,a
+ for fname in sys.argv[2:]:
+ cmdline["logfiles"].append(fname)
+ sys.stderr.write("adding log %s\n" % fname)
+
hosts = {}
-for logname in __cmdLineOpts__.logfiles:
+for logname in cmdline["logfiles"]:
log = logfile_class(logname)
hostname = log.hostname()
+ sys.stderr.write("log %s for host %s\n" % (logname, hostname))
if not hosts.has_key(hostname):
hosts[hostname] = host_class()
hosts[hostname].add_log(log)
+sys.stderr.write("finished adding logs\n")
+
#print hosts["moka"].readline()
#print hosts["moka"].readline()
#print "DIRECT", hosts["moka"].fp().fp.tell()