jstatd--收集遠程主機資訊

來源:互聯網
上載者:User

標籤:jstatd   Proxy 伺服器   遠程監控   應用程式   電腦   

     命令jstatd是一個RMI服務端程式,它的作用相當於Proxy 伺服器,建立本機電腦與遠程監控工具的通訊。jstatd伺服器將本級的Java應用程式資訊傳遞到遠端電腦。

    當我們直接開啟jstatd伺服器可能會拋出訪問拒絕的異常。

    650) this.width=650;" src="https://s4.51cto.com/wyfs02/M01/8E/22/wKiom1i2eoegU8NgAAEus_P_fYU446.png-wh_500x0-wm_3-wmp_4-s_3696936385.png" title="jstatd.png" alt="wKiom1i2eoegU8NgAAEus_P_fYU446.png-wh_50" />

    這是由於jstatd程式沒有足夠的許可權所致。可以使用java的安全性原則,為其分配相應的許可權,下面代碼為jstatd分配了最大的許可權,將其儲存在jstatd.all.policy檔案中:

            grant codebase "file:/usr/java/jdk1.8.0_25/lib/tools.jar" {

                     permission java.security.AllPermission;

            };

    650) this.width=650;" src="https://s3.51cto.com/wyfs02/M00/8E/20/wKioL1i2e2Oyq4WfAACXbePcv9A537.png-wh_500x0-wm_3-wmp_4-s_3770463893.png" title="jstatd2.png" alt="wKioL1i2e2Oyq4WfAACXbePcv9A537.png-wh_50" />


    然後使用以下命令再次開啟jstatd伺服器

    jstatd -J-Djava.security.policy=jstatd.all.policy  

    伺服器啟動成功。-J參數是一個公用的參數,如jps、jstat等命令都可以接受這個參數。由於jps、jstat命令本身也是Java應用程式,-J參數可以為jps等命令本身設定其java虛擬機器參數

    預設情況下,jstatd將在1099連接埠開啟RMI伺服器。

    [[email protected] lib]# ss -lntup|grep 1099

      tcp    LISTEN     0      50        *:1099                  *:*                   users:(("jstatd",pid=14542,fd=14))

   接下來我們就可以在另一個機器上來查看原生資訊了。(我們規定這個伺服器的網域名稱為 dev.kidcares.cn)

   當我們測試時,出下下面的錯誤。

    [[email protected] lib]# jstat -gcutil [email protected]:1099

    Remote Exception attaching to rmi://[email protected]:1099

後來查詢資料得知:

jstatd可以通過 內部 rmi和外部rmi 註冊,除了在啟動參數中加入許可權意外,也必須加入Java.rmi.server.hostname=101.200.157.115 ,否則會出現 Remote Exception attaching to rmi://[email protected]101.200.157.115, 原因跟jconsole一樣,服務端傳過來的IP地址為 hostname -i的值,所以不一定是101.200.157.115

完整的jstatd啟動選項為  

jstatd -J-Djava.rmi.server.hostname=101.200.157.115  -J-Djava.security.policy=jstatd.all.policy

再次執行:

[[email protected] lib]# jstat -gcutil [email protected]:1099

  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   

  0.00  62.09  80.24  32.11  98.09  98.45     67    3.402     2    2.912    6.314




本文出自 “kisszero” 部落格,請務必保留此出處http://kisszero.blog.51cto.com/9395417/1902359

jstatd--收集遠程主機資訊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.