Bookmark

Chạy HostMon trong Docker: dashboard và monitor cho HomeLab

HostMon là dashboard web đơn giản để theo dõi trạng thái host/service trong HomeLab. Tutorial 0706 của i12bretro mô tả các chức năng ping realtime, Wake-on-LAN, SSH client và liên kết Apache Guacamole; ứng dụng viết bằng JavaScript và dùng SQLite.[11]

Youtube video player

Video gốc của tutorial có trên YouTube.[16]

1. Cài Docker trên Linux host

  1. Đăng nhập thiết bị Linux.[11]
  2. Mở terminal và chạy:[11]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# install prerequisites
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
# add docker gpg key
curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
# add docker software repository
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
# install docker
sudo apt install docker-ce docker-compose containerd.io -y
# enable and start docker service
sudo systemctl enable docker && sudo systemctl start docker
# add the current user to the docker group
sudo usermod -aG docker $USER
# reauthenticate for the new group membership to take effect
su - $USER

Sau khi đăng nhập lại, kiểm tra docker version/docker ps trước khi chạy HostMon.[11]

2. Tạo database persistent và chạy HostMon

Thực hiện đúng thứ tự để lấy database mới ra host trước khi xóa container tạm:[11]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# create working directories
mkdir ~/docker/hostmon -p
# set owner of working directories
sudo chown "$USER":"$USER" ~/docker -R
# create the hostmon docker container
docker create -ti --name hostmon i12bretro/hostmon
# export the hostmon database
docker cp hostmon:/app/data/hostmon.db ~/docker/hostmon/hostmon.db
# remove the temporary hostmon container
docker rm hostmon -f
# run hostmon with persistent database
docker run -d --name hostmon -v ~/docker/hostmon:/app/data -p 3000:3000 --restart=unless-stopped i12bretro/hostmon

Lệnh docker cp giữ hostmon.db~/docker/hostmon; volume này được mount vào /app/data của container chạy thật. Tôi không bỏ qua bước này nếu muốn database tồn tại khi recreate/update.[11]

3. Mở giao diện

  1. Mở trình duyệt tới http://DNSorIP:3000.[11]
  2. Kiểm tra HostMon hiển thị và bắt đầu thêm host/service.[11]
  3. Dùng đúng DNS/IP của Docker host thay cho placeholder.[11]

Kiểm tra và giới hạn

Tôi xác nhận container đang Up, port 3000 chỉ bind ở mạng cần dùng và file ~/docker/hostmon/hostmon.db có quyền đọc/ghi đúng. WOL cần broadcast/network phù hợp, SSH cần credential nhập trong cấu hình cục bộ, còn liên kết Guacamole cần endpoint thật; tutorial không biến các tính năng đó thành cấu hình tự động. Không expose dashboard có thông tin hạ tầng ra Internet nếu chưa có auth/VPN.[11]

Video gốc của tutorial: [xem trên YouTube]1.[16]

Nguồn

Tài liệu gốc: [Running HostMon in Docker]2, đăng/cập nhật 2022-03-23.[11]

[11] https://i12bretro.github.io/tutorials/0706.html — Running HostMon in Docker [16] https://www.youtube.com/watch?v=DvPxP8y65Qs — Running HostMon in Docker — i12bretro video


  1. https://www.youtube.com/watch?v=DvPxP8y65Qs — video chính thức của i12bretro. ↩︎

  2. https://i12bretro.github.io/tutorials/0706.html — Running HostMon in Docker. ↩︎


0 Bình luận

Góp Ý / Bình Luận / Đánh giá