Extract events from the event logs
()
| 1368 | HTML_EVENTS_ITEMS += 'N/A yet' |
| 1369 | |
| 1370 | def ParseEventLogs(): |
| 1371 | ''' Extract events from the event logs ''' |
| 1372 | |
| 1373 | global HTML_EVENTS_TL |
| 1374 | global HTML_LOG_CONTENT |
| 1375 | global HTML_EVENTS_LANES |
| 1376 | |
| 1377 | PrintAndLog('Event logs', 'SECTION') |
| 1378 | |
| 1379 | SystemLogsPath = os.path.join(ROOT_PATH, 'var/log/') |
| 1380 | |
| 1381 | PrintAndLog('System logs', 'SUBSECTION') |
| 1382 | |
| 1383 | for LogFile in os.listdir(SystemLogsPath): |
| 1384 | LogFilePath = os.path.join(SystemLogsPath, LogFile) |
| 1385 | Year = time.strftime('%Y', time.localtime(os.path.getctime(LogFilePath))) #nasty hack because the syslog format sucks |
| 1386 | |
| 1387 | if re.match('^system\.log$', LogFile): |
| 1388 | ParseSystemlogFile(LogFilePath, Year) |
| 1389 | if re.match('^system\.log\.\d\.bz2$', LogFile): |
| 1390 | ParseSystemlogFile(LogFilePath, Year, Bzip2ed=True) |
| 1391 | if re.match('^system\.log\.\d\.gz$', LogFile): |
| 1392 | ParseSystemlogFile(LogFilePath, Year, Gziped=True) |
| 1393 | |
| 1394 | Lanes = '\', \''.join(HTML_EVENTS_LANES) |
| 1395 | |
| 1396 | HTML_EVENTS_TL += "<script type=\"text/javascript\">var lanes = [\"" + Lanes + "\"], laneLength = lanes.length, items = [" + HTML_EVENTS_ITEMS + "]" |
| 1397 | HTML_EVENTS_TL += """ |
| 1398 | timeBegin = \"Jan 1, 2013 00:00:00\", |
| 1399 | timeEnd = \"Dec 31, 2013 23:59:59\"; |
| 1400 | |
| 1401 | </script> |
| 1402 | <script type=\"text/javascript\"> |
| 1403 | var m = [20, 15, 15, 120], //top right bottom left |
| 1404 | w = 4000 - m[1] - m[3], |
| 1405 | h = 500 - m[0] - m[2], |
| 1406 | miniHeight = laneLength * 12 + 50, |
| 1407 | mainHeight = h - miniHeight - 50; |
| 1408 | |
| 1409 | //var parseDate = d3.time.format(\"%Y-%m-%d %H:%M:%S\").parse; //2013-05-22 15:00:00 |
| 1410 | var parseDate = d3.time.format(\"%b %d, %Y %H:%M:%S\").parse; //Jun 13, 2013 20:07:09 |
| 1411 | |
| 1412 | //scales |
| 1413 | var x = d3.scale.linear() |
| 1414 | //.domain([timeBegin, timeEnd]) |
| 1415 | .domain([parseDate(timeBegin), parseDate(timeEnd)]) |
| 1416 | .range([0, w]); |
| 1417 | var x1 = d3.scale.linear() |
| 1418 | .range([0, w]); |
| 1419 | var y1 = d3.scale.linear() |
| 1420 | .domain([0, laneLength]) |
| 1421 | .range([0, mainHeight]); |
| 1422 | var y2 = d3.scale.linear() |
| 1423 | .domain([0, laneLength]) |
| 1424 | .range([0, miniHeight]); |
| 1425 | |
| 1426 | var chart = d3.select(\"body\") |
| 1427 | .append(\"svg\") |
no test coverage detected