介紹
該項目爲了方便開發者更快監控多個遠程主機jvm,如果你的項目是Spring boot那麼很方便集成,jar包引入即可,不是Spring boot也不用氣餒,你可以快速自行初始化一個Spirng boot程序引入jar包即可
效果展示
整體架構
git地址
https://github.com/xk4848123/monitor
https://github.com/xk4848123/monitor-server
使用前提
需要機器中有JDK,不僅僅是JRE,配置好java path,程序中依靠ExcuteCmd找尋jdk基本命令
手把手教你用
克隆monitor-server
git clone https://github.com/xk4848123/monitor-server.git
idea -> Project from Existing Sources…
選中項目pom.xml
修改resources/application.properties
monitor.serve[0].name=serve-1
monitor.serve[0].address=http://127.0.0.1:8081/monitor(這裏需要與客戶端的monitor.path對應)
monitor.serve[1].name=serve-2
monitor.serve[1].address=http://127.0.0.1:8082(同上)
....
這裏可以配置多個監控主機,格式注意下
address=http://ip:port/xxx(xxx是你在monitor上配置的,下文中會有)
name=server-1(每個monitor不同即可,便於顯示時區分)
run monitor-server
有異常沒關係,我們把監控客戶端也部起來就好了
說在前面
一個操作系統內部署一個監控客戶端就好,當你有個多個jvm程序時,只要有一個部署就可以監控
下載Release
https://github.com/xk4848123/monitor
進入Release列表,下載jar
本地mvn install(等到博主把jar傳到中心倉庫就不用這麼麼麻煩了)
cmd執行以下命令
mvn install:install-file -DgroupId=com.github.xk4848123 -DartifactId=monitor-spring-boot-starter -Dversion=2.3.1 -Dpackaging=jar -Dfile=C:\Users\Administrator\Downloads\monitor-spring-boot-starter.jar
在任意一個Spring boot項目中使用,我這裏打開我本地一個叫chat的項目
在resources/application.properties增加屬性
#決定訪問路徑,可以自行定義
monitor.path=monitor
#決定是否啓動監控客戶端
monitor.enable=true
pom.xml引入
跑起項目
OK!