In this blog, I will be publishing the Essbase log file parser shell script that I have created. I had designed a JAR file for the same. But I know that many a times people have issues with using jar files in production environment that is downloaded online. So, open source is the way to go… I will be publishing the shell script structure which I used for designing the Essbase log file parser. This is one version of the script. There are other ways to do the same as well…
Now, in order for the shell script to work you would need sed which is a stream editor and tr utility. Most Unix/Linux environments come with these utilities so we are in the green here.
Now this is the structure of the Essbase log file.
The shell script that will parse the log file will basically send the output to a new log file called parsed_essbase_log,txt
The shell script to do the parsing is as shown in the below snapshot.
Logic of the script:
Usage:
To run the script, you need to give the name of the Essbase log file as a parameter while running the script.
This log file is generated in the directory where the shell script is placed.
Disclaimers:
Now, in order for the shell script to work you would need sed which is a stream editor and tr utility. Most Unix/Linux environments come with these utilities so we are in the green here.
Now this is the structure of the Essbase log file.
The shell script that will parse the log file will basically send the output to a new log file called parsed_essbase_log,txt
The shell script to do the parsing is as shown in the below snapshot.
Logic of the script:
- Replace a line which is blank i.e. length is 0 with ###
- Convert new line characters into space so that the file loses individual line markers.
- Replace ### with a new line character.
- Replace the first instance of a closing bracket “)” with a “)”+TAB.
Usage:
To run the script, you need to give the name of the Essbase log file as a parameter while running the script.
sh -x <scriptname.sh> <full path of the log file>
The log file after being parsed is as shown in the below snapshot.
The log file after being parsed is as shown in the below snapshot.
This log file is generated in the directory where the shell script is placed.
Disclaimers:
- This is very basic operation of the shell script. It formats and gives you a readable output in seconds.
- The script is not in place since the existing log file is kept as is and a new log file is created. Thus is the size of the log file is n bytes, you need atleast 2n bytes for running this script.
- It does basic script formatting for you. More customizations can be done by adding additional fields using this script.
Script:
The shell script for formatting the logs is as follows:
# Script designed by Sibin Jose for Hyperion Essbase log file parsing
echo "Hyperion Essbase log parser"
if [ $# -eq 0 ]
then
echo "Incorrect possitional parameters... Usage: log_parser.sh <PATH OF LOG FILE>"
exit 1
fi
export ESSBASE_LOG_FILE=$1
echo ${ESSBASE_LOG_FILE}
#export PARSED_ESSBASE_LOG_FILE=`echo ${ESSBASE_LOG_FILE} | sed 's/.log/_parsed.log/g'`
#echo ${PARSED_ESSBASE_LOG_FILE}
sed 's/^$/###/g' ${ESSBASE_LOG_FILE} | tr '\n' ' ' | sed 's/###/\n/g' | sed 's/)/)\t/1' > parsed_essbase_log.txt
echo "THe script has finished executing...Please check the folder for parsed_essbase_log.txt file"
The shell script for formatting the logs is as follows:
# Script designed by Sibin Jose for Hyperion Essbase log file parsing
echo "Hyperion Essbase log parser"
if [ $# -eq 0 ]
then
echo "Incorrect possitional parameters... Usage: log_parser.sh <PATH OF LOG FILE>"
exit 1
fi
export ESSBASE_LOG_FILE=$1
echo ${ESSBASE_LOG_FILE}
#export PARSED_ESSBASE_LOG_FILE=`echo ${ESSBASE_LOG_FILE} | sed 's/.log/_parsed.log/g'`
#echo ${PARSED_ESSBASE_LOG_FILE}
sed 's/^$/###/g' ${ESSBASE_LOG_FILE} | tr '\n' ' ' | sed 's/###/\n/g' | sed 's/)/)\t/1' > parsed_essbase_log.txt
echo "THe script has finished executing...Please check the folder for parsed_essbase_log.txt file"
No comments:
Post a Comment