Last active
August 29, 2015 14:07
-
-
Save vicendominguez/5c54eb26cdf747662453 to your computer and use it in GitHub Desktop.
glassfish server.log stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# https://vicendominguez.blogspot.com | |
# v0.01 | |
import re | |
def main(): | |
# VARIABLES | |
LOG_FILE='/var/log/glassfish/server.log' | |
DATE_REGEXP = "[0-9]{3}-[0-9]{1,2}-[0-9]{1,2}T[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}" | |
totInfo=0 | |
totWarn=0 | |
totSevere=0 | |
totError=0 | |
totExceptions = 0 | |
totFileLines = 0 | |
totProcessingLines = 0 | |
startDate= "" | |
gflog = open(LOG_FILE) | |
for line in gflog: | |
if re.search(DATE_REGEXP,line): | |
totProcessingLines += 1 | |
line_fields = line.split() | |
if startDate == "": | |
startDate = line_fields[0] | |
if line_fields[3] == '[INFO]': | |
totInfo += 1 | |
elif line_fields[3] == '[WARNING]': | |
totWarn += 1 | |
elif line_fields[3] == '[WARN]': | |
totWarn += 1 | |
elif line_fields[3] == '[SEVERE]': | |
totSevere += 1 | |
elif line_fields[3] == '[ERROR]': | |
totError += 1 | |
else: | |
totExceptions += 1 | |
print "Error Processing: " | |
print " " + line_fields[3] | |
print " " | |
endDate = line_fields[0] | |
totFileLines += 1 | |
print "Fecha Inicio: " , startDate | |
print "Fecha Fin: ", endDate | |
print "Total INFO: " , totInfo | |
print "Total WARN: " , totWarn | |
print "Total SEVERE: " , totSevere | |
print "Total ERROR: " , totError | |
print "Total Processing: " , totProcessingLines | |
print "Total Processing Errors: " , totExceptions | |
print "Total logfile lines: " , totFileLines | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment