java jps 进程信息不可用 - jconsole 和 jvisualvm 不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5271907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 10:21:31  来源:igfitidea点击:

jps process information unavailable - jconsole and jvisualvm not working

javajconsole

提问by Laurent K

After a windows update, my jps, jconsole et jvisualvm are not working anymore.

Windows 更新后,我的 jps、jconsole 和 jvisualvm 不再工作。

Jps gives me the process ids, but it tells me process information unavailable

Jps 给了我进程 ID,但它告诉我 process information unavailable

And I'm unable to connect to those processes with jvisualvm as I used to.

而且我无法像以前那样使用 jvisualvm 连接到这些进程。

I'm running the 1.6.0_22 jre.

我正在运行 1.6.0_22 jre。

I already had the problem in the past, tries this trick, and it worked. But this time, bad luck, it does not help.

我过去已经遇到过这个问题,尝试了这个技巧,它奏效了。但这一次,倒霉,也无济于事。

Edit :I found a solution: in my temp folder, I did destroy the hsperfdata_<username>folder. Apparently there was an issue with the case of my username. The folder was called hsperfdata_myname. After having been destroyed and re-created by a call to jps, it was called hasperfdata_MYNAME.

编辑:我找到了一个解决方案:在我的临时文件夹中,我确实销毁了该hsperfdata_<username>文件夹。显然,我的用户名存在问题。该文件夹名为 hsperfdata_myname。通过调用 jps 销毁并重新创建后,它被称为 hasperfdata_MYNAME。

Very strange.

很奇怪。

回答by Laurent K

In my temp folder, I did destroy the hsperfdata_ folder. Apparently there was an issue with the case of my username. The folder was called hsperfdata_myname. After having been destroyed and re-created by a call to jps, it was called hasperfdata_MYNAME.

在我的临时文件夹中,我确实销毁了 hsperfdata_ 文件夹。显然,我的用户名存在问题。该文件夹名为 hsperfdata_myname。通过调用 jps 销毁并重新创建后,它被称为 hasperfdata_MYNAME。

Very strange.

很奇怪。

回答by Qiang Li

On unix, make sure you are running as the user that started it.

在 unix 上,确保您以启动它的用户身份运行。

回答by Ava

I wrote a script to apply the work-around, which I call from some of my monitoring scripts, until this is fixed.

我编写了一个脚本来应用变通方法,我从我的一些监控脚本中调用它,直到这个问题得到修复。

#!/bin/bash
# Name: fix_jps.bash
# Author: Cameron Pierce
#
# Purpose: create /tmp/hsperfdata directories that jps and jstat can work with

## VARIABLES
RETVAL=""
fileHSP=""
filePID=""
fileLOG=/tmp/fix_jps.log

# for every /tmp/hsperfdata_[name] directory that exists
for fileHSP in `ls -d /tmp/hsperfdata_*`; do
        #echo "entry ${fileHSP}" # DEBUG
        # if our search returns entries that are not directories, skip them
        if [ ! -d ${fileHSP} ]; then
                continue
        fi
        #ls ${fileHSP} # DEBUG

        # alternative to ls below
        #FINDFILES=(${fileHSP}/*)
        #if [ ${#FINDFILES[@]} -gt 0 ]; then
        #       echo "files in $fileHSP: ${#FINDFILES[@]} "
        #fi
    for filePID in `ls ${fileHSP}/ 2>> ${fileLOG} | grep "[[:digit:]]\{1,\}"`; do
            #echo "pid name: ${filePID}" # DEBUG
            # if the directory was empty, move on to the next fileENTRY
            if [ "${filePID}" == "" ]; then
                    #echo "the contents of the variable filePID appear to be empty \"${filePID}\"" # DEBUG
                    # remove the fileHSP if empty; this will clean up user hsperfdata dirs
                    rmdir ${fileHSP} 2>> ${fileLOG}
                    continue
            # if a symlink already exists, move on to the next fileENTRY
            elif [ -h /tmp/hsperfdata_${filePID} ]; then
                    #echo "symlink already exists for /tmp/hsperfdata_${filePID}" # DEBUG
                    continue
            fi
            #echo "name: ${filePID}"
            # if a process exists for filePID, create a symlink to the source file
            ps -eo pid | awk '{print }' | grep -q "^${filePID}$"
            RETVAL=$?
            # if a process exists with pid of filePID and a symlink doesn't exists, create symlink
            if [ $RETVAL -eq 0 -a ! -e /tmp/hsperfdata_${filePID} ]; then
                    ln -s ${fileHSP}/${filePID} /tmp/hsperfdata_$filePID
                    #echo ls -l /tmp/hs perfdata_${filePID} # DEBUG
            fi
    done
done

# remove broken symlinks
#find -L /tmp/hsperfdata_* -type l # DEBUG
find -L /tmp/hsperfdata_* -type l -delete

回答by Tim DM

we're having the same problem here.

我们在这里遇到了同样的问题。

The tmp folder trick didn't work for us, as well.

tmp 文件夹技巧对我们也不起作用。

So far, we've found a few ways to make things work again:

到目前为止,我们已经找到了一些让事情重新工作的方法:

  • a system restore
  • rename the temp folder under "C:\Documents and Settings\myusername\Local Settings" and create a new temp folder (I'm not sure that this is a safe thing to do, regarding to windows...)
  • start removing stuff from temp folder manually
  • probably the safest: run ccleaner, this will clean up the temp folder
  • 系统还原
  • 重命名“C:\Documents and Settings\myusername\Local Settings”下的临时文件夹并创建一个新的临时文件夹(我不确定这是一个安全的事情,对于 Windows...)
  • 开始手动从临时文件夹中删除内容
  • 可能是最安全的:运行 ccleaner,这将清理临时文件夹