jvm_collector.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:ops_agent 作者: sjqzhang 项目源码 文件源码
def get_jvm_option(self, java_bin):
        cmd = '%s -version 2>&1 | grep \' version \' | awk -F"[\\"_]" \'{print $2}\'' %java_bin
        popen = subprocess.Popen(cmd, shell=True, close_fds=True, stdout=subprocess.PIPE)
        excute_data = popen.stdout.readlines()
        try:
                version = excute_data[0].strip('\n')
                major, minor, security = [int(x) for x in version.split('.')]
                if major > 1 or minor >= 8:
                    self.logger.info("using jdk version: {0}, "
                                     "set JVM option with MetaSpace parameter".format(excute_data))
                    return JSTATUS['new_jvm_option']

                else:
                    self.logger.info("using jdk version: {0}, "
                                     "set JVM option with PermSpace parameter".format(excute_data))
                    return JSTATUS['old_jvm_option']

        except Exception as msg:
                self.logger.error("failed to decide the java version from excute_data: {0}, "
                                  "exception msg: {1}".format(excute_data, msg))

                self.logger.error(traceback.format_exc())
                raise JvmCollectorExcept('receive java version error')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号