diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/extras/htmlog | 164 |
1 files changed, 117 insertions, 47 deletions
diff --git a/src/extras/htmlog b/src/extras/htmlog index 7765d09f..d8148315 100755 --- a/src/extras/htmlog +++ b/src/extras/htmlog @@ -77,7 +77,7 @@ class logfile_class: self.curline.split()[3] # system is booting - if self.curmessage().startswith("Linux version"): + if self.curmessage().startswith("kernel: Linux version"): self.add_event("system boot") # hostname has changed @@ -87,7 +87,7 @@ class logfile_class: # the clock is wrong wrong if self.prevline and time.strptime(self.prevline[0:15], "%b %d %H:%M:%S") > self.time_current(): - self.add_event("clock is fucked up") + self.add_event("clock is messed up") def add_event(self, message): self.events.append( (self.curline_pos,len(self.curline),message) ) @@ -107,62 +107,109 @@ for logname in __cmdLineOpts__.logfiles: log.parse() logs.append(log) -print """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -<HTML> -<HEAD> -<TITLE>HTMLogs output</TITLE> +print """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> + +<html> +<head> +<title></title> <style type="text/css"> +<!-- + body { - background: #FFF; - color: #000; - font: normal normal 12px Verdana, Geneva, Arial, Helvetica, sans-serif; - margin: 10px; - padding: 0 + font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; + color: #4f6b72; + background: #E6EAE9; +} + +a { + color: #c75f3e; } -table, td, a { - color: #000; - font: normal normal 12px Verdana, Geneva, Arial, Helvetica, sans-serif +#mytable { + width: 97%; + padding: 0; + margin: 0; } -/* make the TH elements pretty */ -thead.fixedHeader th { - background: #C96; - border-left: 1px solid #EB8; - border-right: 1px solid #B74; - border-top: 1px solid #EB8; - font-weight: normal; - padding: 4px 3px; - text-align: left +caption { + padding: 0 0 5px 0; + width: 97%; + font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; + text-align: right; } -/* make the A elements pretty. makes for nice clickable headers */ -thead.fixedHeader a, thead.fixedHeader a:link, thead.fixedHeader a:visited { - color: #FFF; - display: block; - text-decoration: none; - width: 100% +th { + font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; + color: #4f6b72; + letter-spacing: 2px; + text-transform: uppercase; + text-align: left; + padding: 6px 6px 6px 12px; + background: #a50000 url(images/bg_header.jpg) no-repeat; + color: white; } -/* make the A elements pretty. makes for nice clickable headers */ -/* WARNING: swapping the background on hover may cause problems in WinIE 6.x */ -thead.fixedHeader a:hover { - color: #FFF; - display: block; - text-decoration: underline; - width: 100% +th.nobg { + border-top: 0; + border-left: 0; + border-right: 1px solid #C1DAD7; + background: none; + color: black; } -ul#toc {list-style:none;width:320px;} -#toc li {background:url(dot.gif) repeat-x 0 0.85em;} -#toc li a {float:left;background:#FFF;padding: 0 4px 0 0;} -#toc li span {float:right;background:#FFF; padding 0 0 0 4px;} -#toc li br {clear:both;} +td { + border-right: 1px solid #C1DAD7; + border-bottom: 1px solid #C1DAD7; + background: #fff; + padding: 6px 6px 6px 12px; + color: #4f6b72; + letter-spacing: -1px; + white-space:pre-wrap; + font-family: monospace; +} + +pre { + white-space: pre-wrap; /* css-3 */ + white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ +} + +td.alt { + background: #ffbaba; + color: #797268; +} + +th.newday { + text-align: right; + padding: 2px; +} + +th.spec { + border-left: 1px solid #C1DAD7; + border-right: 1px solid #C1DAD7; + border-top: 0; + background: #fff url(images/bullet1.gif) no-repeat; + font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; + color: #797268; +} + +th.specalt { + border-left: 1px solid #C1DAD7; + border-right: 1px solid #C1DAD7; + border-top: 0; + background: #cecfce url(images/bullet2.gif) no-repeat; + font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; + color: #797268; +} --> </style> -</HEAD> -<BODY> + +</head> +<body> """ print '<ul id="toc">' @@ -172,7 +219,14 @@ for log in logs: print ' <li><span>%s</span> <a href="#">Link</a><br /></li>' % event print '</ul>' -print "<TABLE>" +print """ +<table id="mytable" cellspacing="0" summary="The technical specifications of the Apple PowerMac G5 series"> +<caption>Generated by SOS htmlogger 1.0 on March 16th 2008</caption> +""" + +previous_date = None +inc = 0 + while True: # who is next ? lowest_date = None @@ -190,9 +244,21 @@ while True: # all logs are EOF break - print " <TR>" + if inc == 0 or inc % 200 == 0: + print """<tr><th scope="col" abbr="Date/Time" class="nobg">Time of Event</th><th scope="col" abbr="node-1">node-1</th><th scope="col" abbr="node-2">node-2</th><th scope="col" abbr="node-3">node-3</th></tr>""" + + if not previous_date or time.strftime("%b %d", previous_date) != time.strftime("%b %d", lowest_date): + print """<tr><th scope="row" class="newday" colspan=4>%s</th></tr>""" % time.strftime("%A, %B %d", lowest_date) + + if inc % 2 == 0: row_class = "spec" + else: row_class = "altspec" + # FIXME: if this tick has an event, add <a name="..."> - print ' <TD STYLE="white-space:nowrap">' + time.strftime("%b %d %H:%M:%S", lowest_date) + "</TD>" + if not previous_date or previous_date != lowest_date: + print """<TR><th scope="row" class="spec">""" + time.strftime("%H:%M:%S", lowest_date) + """</th>""" + else: + print """<TR><th scope="row" class="spec" style="color: #cacaca">""" + time.strftime("%H:%M:%S", lowest_date) + """</th>""" + for log in logs: if log.time_current() == lowest_date: print " <TD>" + log.curmessage() + "</TD>" @@ -201,7 +267,11 @@ while True: print " <TD></TD>" # print log.curline_pos, time.strftime("%b %d %H:%M:%S", log.time_current()), log.curmessage() print " </TR>" -print "<TABLE>" + + previous_date = lowest_date + inc += 1 + +print "</table>" |