Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Go to start of metadata

Apache Tomcat is an implementation of the Java Servlet and JavaServer Pages technologies. It is used as the servlet container for GX WebManager, and therefore catches all log messages that WebManager generates. How and where the messages are being logged by Tomcat is determined by the System Administrator. By default, the main log file is written to "<Tomcat dir>/logs/catalina.out".

However, often the log files are being rotated to prevent them from getting too big to handle.

Analysis

Log files contain the heartbeat of your WebManager installation and keeping an eye on them is a wise idea.

Below is a linux script to help you analyze the "catalina.out" file. It organizes the messages in the logfile and sorts them according to the number of occurrences in the logfile, meaning the most recurring message will end up on top.


#!/bin/sh
 
# File:         prunelog9.sh
# Version:      1.2
# Author:       Patrick Atoon <patrick.atoon@gxsoftware.com>
# Created:      2009-02-27
# Copyright:    copyright (c) 2009 GX, http://www.gxwebmanager.com/
#               This program is free software: you can redistribute it and/or modify
#               it. This program is distributed in the hope that it will be useful,
#               but WITHOUT ANY WARRANTY; without even the implied warranty of
#               MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Description:  This script will take a Tomcat catalina.out logfile for WebManager 9
#               and prune it to unique error messages while sorting it on the number
#               of occurrences. The result is a sorted list of most occurring errors
#               on a WebManager 9 installation.
#
# Usage:
#               prunelog9.sh [ -g ] logfile
#
# Arguments:    -g (optional) Generalize error messages
#
# History:
#               0.9   OMG! Perl and shell! It's been a while!
#               1.0   Works like a charm.
#               1.1   Removing stacktraces for better totals
#               1.2   Bugfix: Day-of-month can be one or two digits.
#
 
if [ $# -eq 1 ]; then
    LOGFILE=$1
    PERLFILTER='$OUTPUT_AUTOFLUSH = 1;my $outline = "";while (my $line = <STDIN>) { chomp $line; if ($line =~ /^\w{3} \d+, \d{4} \d+:\d+:\d+ \w{2} (.*)$/) { my $leftover = $1; print $outline . "\n"; $outline = $leftover; } else { if (!($line =~ /^\tat /)) { $outline .= " ##### " . $line; } } }'
else
    if [[ "$1" == "-g" ]]; then
        LOGFILE=$2
        PERLFILTER='$OUTPUT_AUTOFLUSH = 1;my $outline = "";while (my $line = <STDIN>) { chomp $line; if ($line =~ /^\w{3} \d+, \d{4} \d+:\d+:\d+ \w{2} (.*)$/) { my $leftover = $1; $outline =~ s/\d{5,9}/xxxxxx/g; print $outline . "\n"; $outline = $leftover; } else { if (!($line =~ /^\tat /)) { $outline .= " ##### " . $line; } } }'
    else
        echo "Usage: $0 [ -g ] logfile";
        exit
    fi
fi
 
if [[ ! -f $LOGFILE ]]; then
    echo "No such file: $LOGFILE"
    echo "Usage: $0 [ -g ] logfile";
    exit
fi
 
# Chain the filters together
/bin/cat $LOGFILE | \
/usr/bin/perl -e "$PERLFILTER" | \
/bin/sort | \
/usr/bin/uniq -c | \
/bin/sort -nr | \
/bin/sed -e "s/ ##### /\n/g"

 

How to make the code above work:

  • Copy and paste the code above to a file named "prunelog9.sh"
  • Make the file executable: "chmod +x prunelog9.sh"
  • Download or copy the logfile you want to analyze, e.g. "catalina.out"
  • Usage examples:

patricka:~> ./prunelog.sh -g catalina.out
     41 nl.gx.webmanager.cms.core.implementation.PresentableImpl render
SEVERE: presentation is null for baseobject with id xxxxxx
     37 nl.gx.siteworks.core.SiteWorksSession getObject
WARNING: Unable to find node with id xxxxxx
...
 
patricka:~> ./prunelog.sh catalina.out
&nbsp;&nbsp;&nbsp;&nbsp; 14 nl.gx.webmanager.cms.core.implementation.PresentableImpl render
SEVERE: presentation is null for baseobject with id 475486
&nbsp;&nbsp;&nbsp;&nbsp; 10 nl.gx.webmanager.services.sessionmanager.impl.WebManagerAPI getWrapper
SEVERE: Unable to create wrapper for id '32314' of class 'interface nl.gx.webmanager.cms.mediarepository.MediaItemVersion'.
...

 




  • No labels