def mayne(): TMPFILE = '/tmp/gcdotlog-relative-time-tmpfile' numArgs = len(sys.argv) - 1 if (2 != numArgs): print "Usage: %s {iso8601 combined date and time representations} outputdir" % ( sys.argv[0], ) sys.exit(1) bootTimeStringISO8601 = sys.argv[1] bootTimeSecondsSinceEpochString = vmsgcvizutils.timestamp_to_epoch( bootTimeStringISO8601) bootTimeSecondsSinceEpoch = float(bootTimeSecondsSinceEpochString) outputDir = sys.argv[2] bootTimeEpochFile = open(outputDir + '/jvm_boottime.epoch', 'w') bootTimeEpochFile.write("%s\n" % bootTimeSecondsSinceEpochString) bootTimeEpochFile.close() tmpFile = open(TMPFILE, 'w') lineStartsWithFloatingPointNumberPattern = re.compile( "^([0-9]+[.][0-9]+): ") lastSecsSinceBoot = 0.0 for line in fileinput.input('-'): line = line.rstrip('\r\n') found = lineStartsWithFloatingPointNumberPattern.search(line) if found: secsSinceBootString = found.group(1) secsSinceBoot = float(secsSinceBootString) if secsSinceBoot < lastSecsSinceBoot: # now we need to truncate the output file, since we have # seen a restart; this is not the most recent JVM boot tmpFile.close() tmpFile = open(TMPFILE, 'w') lastSecsSinceBoot = secsSinceBoot timeStamp = vmsgcvizutils.convertTimeStamp( bootTimeSecondsSinceEpoch, secsSinceBoot) tmpFile.write("%s: %s\n" % (timeStamp, line)) else: tmpFile.write("%s\n" % (line, )) tmpFile.close() for line in fileinput.input(TMPFILE): line = line.rstrip('\r\n') print "%s" % (line, ) os.unlink(TMPFILE)
def mayne(): TMPFILE = '/tmp/gcdotlog-relative-time-tmpfile' numArgs = len(sys.argv) - 1 if(2 != numArgs): print "Usage: %s {iso8601 combined date and time representations} outputdir" % (sys.argv[0],) sys.exit(1); bootTimeStringISO8601 = sys.argv[1] bootTimeSecondsSinceEpochString = vmsgcvizutils.timestamp_to_epoch(bootTimeStringISO8601) bootTimeSecondsSinceEpoch = float(bootTimeSecondsSinceEpochString) outputDir = sys.argv[2] bootTimeEpochFile = open(outputDir + '/jvm_boottime.epoch', 'w') bootTimeEpochFile.write("%s\n" % bootTimeSecondsSinceEpochString) bootTimeEpochFile.close() tmpFile = open(TMPFILE, 'w') lineStartsWithFloatingPointNumberPattern = re.compile("^([0-9]+[.][0-9]+): ") lastSecsSinceBoot = 0.0; for line in fileinput.input('-'): line = line.rstrip('\r\n') found = lineStartsWithFloatingPointNumberPattern.search(line) if found: secsSinceBootString = found.group(1) secsSinceBoot = float(secsSinceBootString) if secsSinceBoot < lastSecsSinceBoot: # now we need to truncate the output file, since we have # seen a restart; this is not the most recent JVM boot tmpFile.close() tmpFile = open(TMPFILE, 'w') lastSecsSinceBoot = secsSinceBoot timeStamp = vmsgcvizutils.convertTimeStamp(bootTimeSecondsSinceEpoch, secsSinceBoot) tmpFile.write("%s: %s\n" % (timeStamp, line)) else: tmpFile.write("%s\n" % (line,)) tmpFile.close() for line in fileinput.input(TMPFILE): line = line.rstrip('\r\n') print "%s" % (line,) os.unlink(TMPFILE)
def mayne(): print "secs_since_epoch" for line in fileinput.input('-'): line = line.rstrip('\r\n') print "%s" % (vmsgcvizutils.timestamp_to_epoch(line),)
def mayne(): print "secs_since_epoch" for line in fileinput.input('-'): line = line.rstrip('\r\n') print "%s" % (vmsgcvizutils.timestamp_to_epoch(line), )
'objectCache\(([^)]*)\) references\(([^)]*)\) size\(([^)]*)\) ratio\(([^)]*)\) prevsize\(([^)]*)\) additions\(([^)]*)\) transfers\(([^)]*)\) hits\(([^)]*)\) orphans\(([^)]*)\)' ) header = "secsSinceEpoch,iso8601Timestamp,references,size,ratio,prevsize,additions,transfers,hits,orphans\n" iso8601Timestamp = "1970-01-01T00:00:00.000+0000" secsSinceEpoch = "0.000" for line in fileinput.input(objectCacheStatsFile): line = line.rstrip('\r\n') foundTimestamp = timestampPattern.search(line) if foundTimestamp: ymd = foundTimestamp.group(1) hms = foundTimestamp.group(2) milliseconds = foundTimestamp.group(3) iso8601Timestamp = '%sT%s.%s+0000' % (ymd, hms, milliseconds) secsSinceEpoch = vmsgcvizutils.timestamp_to_epoch(iso8601Timestamp) continue foundObjectCache = objectCachePattern.search(line) if foundObjectCache: cacheName = foundObjectCache.group(1) references = foundObjectCache.group(2) size = foundObjectCache.group(3) ratio = foundObjectCache.group(4) prevsize = foundObjectCache.group(5) additions = foundObjectCache.group(6) transfers = foundObjectCache.group(7) hits = foundObjectCache.group(8) orphans = foundObjectCache.group(9) l = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n" % ( secsSinceEpoch, iso8601Timestamp, references, size, ratio,
timestampPattern = re.compile('^([0-9]{4}-[0-9]{2}-[0-9]{2}) ([0-9]{2}:[0-9]{2}:[0-9]{2}),([0-9]{3}) INFO (main|vms-timer-refresh) VMClientCacheManager - Processed Countries') objectCachePattern = re.compile('objectCache\(([^)]*)\) references\(([^)]*)\) size\(([^)]*)\) ratio\(([^)]*)\) prevsize\(([^)]*)\) additions\(([^)]*)\) transfers\(([^)]*)\) hits\(([^)]*)\) orphans\(([^)]*)\)') header="secsSinceEpoch,iso8601Timestamp,references,size,ratio,prevsize,additions,transfers,hits,orphans\n" iso8601Timestamp = "1970-01-01T00:00:00.000+0000" secsSinceEpoch = "0.000" for line in fileinput.input(objectCacheStatsFile): line = line.rstrip('\r\n') foundTimestamp = timestampPattern.search(line) if foundTimestamp: ymd = foundTimestamp.group(1) hms = foundTimestamp.group(2) milliseconds = foundTimestamp.group(3) iso8601Timestamp = '%sT%s.%s+0000' % (ymd,hms,milliseconds) secsSinceEpoch = vmsgcvizutils.timestamp_to_epoch(iso8601Timestamp) continue foundObjectCache = objectCachePattern.search(line) if foundObjectCache: cacheName = foundObjectCache.group(1) references = foundObjectCache.group(2) size = foundObjectCache.group(3) ratio = foundObjectCache.group(4) prevsize = foundObjectCache.group(5) additions = foundObjectCache.group(6) transfers = foundObjectCache.group(7) hits = foundObjectCache.group(8) orphans = foundObjectCache.group(9) l = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n" % (secsSinceEpoch,iso8601Timestamp,references,size,ratio,prevsize,additions,transfers,hits,orphans) f = outputFiles.get(cacheName)