Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant delay first iteration #84

Open
cbrdy opened this issue Sep 29, 2016 · 5 comments
Open

cant delay first iteration #84

cbrdy opened this issue Sep 29, 2016 · 5 comments

Comments

@cbrdy
Copy link

cbrdy commented Sep 29, 2016

From the jvmtop usage, I can see delay can be set between the iterations but I can not have the delay set for the first iteration itself. The reason I'm asking for this is when I run the jvmtop.sh for the first time, it shows higher values of %cpu for jvmtop as well as other jvms running. I wanted to have the correct %cpu after certain time lets say 5 sec.

@mskadu
Copy link

mskadu commented Sep 29, 2016

I hit the same problem. However, as a stop gap arrangement - I skip the first couple of readings (i poll every 2 seconds) before starting to log the CPU. I am sure it's easy to work out how ;-)

Hope this helps.

@cbrdy
Copy link
Author

cbrdy commented Sep 29, 2016

yeah, but I'm sending this data to splunk so you can see the issue here.

@mskadu
Copy link

mskadu commented Sep 29, 2016

Haven't really worked with splunk, so any more information would be useful in making suggestions. My use-case was that I generated a CSV from jvmtop runs that was used as a data source.

@patric-r
Copy link
Owner

patric-r commented Sep 29, 2016

As a rough guess, the initial higher cpu usage might be caused by the attach mechanism itself. Additionally, the remote jvm needs to load additional classes (and may JIT them afterwards) beforehand for the communication with jvmtop. All of this does cost cpu time, of course.

That's why I suspect the higher indicated cpu time within the first seconds after attaching to be correct (and you're free to skip those readings, as mskadu suggested).

@cbrdy
Copy link
Author

cbrdy commented Oct 6, 2016

Yes, that's what I have decided. I have updated jvmtop.sh to my requirements.

#!/bin/sh
# jvmtop - java monitoring for the command-line 
# launch script
#
# author: Markus Kolb
# 

DEFAULT="-help"
PARAM=${@-$DEFAULT}

DIR=`cd "\`dirname "$0"\`" && pwd`

if [ -z "$JAVA_HOME" ] ; then
        JAVA_HOME=`readlink -f \`which java 2>/dev/null\` 2>/dev/null | \
        sed 's/\/bin\/java//'`
fi

TOOLSJAR="$JAVA_HOME/lib/tools.jar"

if [ ! -f "$TOOLSJAR" ] ; then
        echo "$JAVA_HOME seems to be no JDK!" >&2
        exit 1
fi

"$JAVA_HOME"/bin/java $JAVA_OPTS -cp "$DIR/jvmtop.jar:$TOOLSJAR" \
com.jvmtop.JvmTop ${PARAM} |  awk '/load avg/ {c=1; a=$0;next} c>=0{c=c+1;a=a"\n"$0}END{print a}'
exit $?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants