Skip to content

softleader/container-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Container Monitor

Get your own version badge on microbadger.com

build

# build image
mvn clean compile jib:build -Dbuild.tag=v0.4.2

run

  • run as java app

# 透過Maven啟動,紀錄寫在當前目錄
mvn spring-boot:run

# 透過Maven啟動,記錄檔寫在指定目錄
mvn spring-boot:run -Dcontainer.monitor.record.file.path.root=/logs/
  • run as docker image

# 透過Docker啟動,紀錄寫出至mount目錄
docker run \
       --rm \
       -v //var/run/docker.sock:/var/run/docker.sock \
       -v "C:/develop/container-monitor:/var/softleader_home/container_monitor/" \
       softleader/container-monitor:latest

# 透過Docker啟動,紀錄寫出至mount目錄,且以CornJob的方式運行,每分鐘紀錄一次
docker run \
       --rm \
       -v //var/run/docker.sock:/var/run/docker.sock \
       -v "C:/develop/container-monitor:/var/softleader_home/container_monitor/" \
       -e JAVA_TOOL_OPTIONS="-Dcontainer.monitor.run.cron_job='0 * * * * *'" \
       softleader/container-monitor:latest
  • run on Kubernetes

# 1. login kubectl

# 2. apply pv & pvc, 只需要第一次部署執行
kubectl apply -f config/pv.yaml -f config/pvc.yaml

# 3. apply yaml
# cronjob.yaml - 依照 corn 的設定重複執行, 執行的 worker 交由 k8s 安排
# daemonset.yaml - 在每一台 worker 依照 corn 的設定重複執行
# daemonset-run-once.yaml - 在每一台 worker 執行一次
kubectl apply -f config/YAML

properties

name desc value sample default

container.monitor.record.file.path.root

記錄檔儲存位置

~/logs, C:/logs, logs/

run as java app: ./

run as docker image: /var/softleader_home/container_monitor/

container.monitor.run.cron_job

若為空則啟動單次後結束App, 若有值則以CronJob模式啟動

0 * * * * *, doc

null

JVM Metric support

本 App 可以蒐集 JVM 運行資訊,但需要該Container的JavaAPP具有Actuator,並設定以下參數

endpoints.metrics.enabled=true
management.security.enabled=false

behavior

  1. 啟動後,會立即蒐集當前環境的 docker ps, docker stats 資訊

  2. 如果情況允許,將會蒐集Jvm運行資訊 (需要該Container有開出Actuator的Metrics Endpoint)

  3. 蒐集完一切資訊後,根據 image name 產生運行記錄檔 (.csv)

Tips

  1. 可以用Excel開啟CSV繪製圖表

  2. 數值含意

    • jvm.mem = jvm.mem.free + jvm.heap.used + jvm.nonheap.used

  3. 於Excel中可以利用格式化將容量數字轉換為人類看得懂的樣式

[<1000000]#,##0.00," KB";[<1000000000]#,##0.00,," MB";#,##0.00,,," GB"

* memUsage
* memLimit
* netIn
* netOut
* blockIn
* blockOut
[<1000]#,##0.00" KB";[<1000000]#,##0.00," MB";#,##0.00,," GB"

* mem
* mem.free
* heap.committed
* heap.init
* heap.used
* heap
* nonheap.committed
* nonheap.init
* nonheap.used
* nonheap

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages