forked from giltene/jHiccup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jHiccupLogProcessor
executable file
·86 lines (79 loc) · 3.13 KB
/
jHiccupLogProcessor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#
# jHiccupLogProcessor
#
# Written by Gil Tene, and released to the public domain, as explained at
# http://creativecommons.org/publicdomain/zero/1.0/
#
JHICCUP_Version=2.0.4
#
# jHiccupLogProcessor will process an input log and can generate two
# different log files from a single jHiccup histogram log file: a
# sequential interval log file and a histogram log file.
#
# The sequential interval log file logs a single %'ile stats line for
# each reporting interval.
#
# The histogram percentile log file includes a detailed %'ile histogram
# of the entire log file range.
#
# jHiccupLogProcessor will process an input log file when provided with
# the -i <filename> option. When no -i option is provided, standard input
# will be processed.
#
# When provided with an output file name <logfile> with the -o option
# (e.g. "-o mylog"), jHiccupLogProcessor will produce both output files
# under the names <logfile> and <logfile>.hgrm (e.g. mylog and mylog.hgrm).
#
# When not provided with an output file name, jHiccupLogProcessor will
# produce [only] the histogram percentile log output to standard output.
#
# jHiccupLogProcessor accepts optional -start and -end time range
# parameters. When provided, the output will only reflect the portion
# of the input log with timestamps that fall within the provided start
# and end time range parameters.
#
# jHiccupLogProcessor also accepts and optional -csv parameter, which
# will cause the output formatting (of both output file forms) to use
# a CSV file format.
#
# Figure out installed path:
# On Linux, we'd do the following:
# PARSED_SCRIPT=`readlink -f $0`
# INSTALLED_PATH=`dirname $PARSED_SCRIPT`
# But readlink -f doesn't work the same everywhere (e.g. Mac OS). We use this instead:
function readlink_f () { _=`pwd`; cd `dirname $1` && echo `pwd` && cd $_; }
INSTALLED_PATH=$(readlink_f $0)
# Check if running from unpacked distribution archive by assuming jHiccup.jar
# in the same directory as this script. If not, try to search in target/ directory
# (running from the source repository build).
JHICCUP_JAR_FILE=$INSTALLED_PATH/jHiccup.jar
if [ ! -f $JHICCUP_JAR_FILE ] ; then
JHICCUP_JAR_FILE=$INSTALLED_PATH/target/jHiccup.jar
fi
JAVA_BIN=`which java`
if [ $JAVA_HOME ]; then
JAVA_CMD=$JAVA_HOME/bin/java
elif [ $JAVA_BIN ]; then
JAVA_CMD=$JAVA_BIN
else
echo "For this command to run, either $JAVA_HOME must be set, or java must be in the path."
exit 1
fi
#
# Parse original java execution arguments:
#
# At this point, we should have valid $PARSED_BinJava, $PARSED_JavaArgs, $PARSED_AppArgs:
#echo PARSED_BinJava = "$PARSED_BinJava"
#echo PARSED_JavaArgs = "$PARSED_JavaArgs"
#echo PARSED_AppArgs = "$PARSED_AppArgs"
# Deal with Windows/cygwin path normalization syntax needs:
# Key Assumption: only cygwin/Windows installations will have a cygpath command...
cygpath -w $JHICCUP_JAR_FILE &> /dev/null
if [ $? -eq 0 ] ; then
# if using cygwin, use valid windows-style classpath
JHICCUP_JAR_FILE=`cygpath -w $JHICCUP_JAR_FILE`
echo Windows path for hiccup jar file is $JHICCUP_JAR_FILE
fi
exec $JAVA_CMD -cp $JHICCUP_JAR_FILE org.jhiccup.internal.hdrhistogram.HistogramLogProcessor $@
#exec $CMD