容器监控工具很多,本文主要对比了cAdvisor、Weave Scope和Prometheus几种监控工具的特性和功能,并结合环境部署测试了各工具的使用。
容器监控工具很多,下表对比了cAdvisor、Weave Scope和Prometheus等几种监控工具在部署便捷性、信息详细度、集成度、告警功能、非Docker资源监控以及软件成本等方面的特性和功能:
4、Weave scope监控
Weave Scope可用于Docker和Kubernetes容器的监控、可视化和管理,它可以自动生成容器之间的关系图,能够直观地理解、监控和控制容器。
4.1 Weave scope监控单机环境
1)安装weave scope
[root@tango-centos01 ~]# curl -L git.io/scope -o /usr/local/bin/scope
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:05 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:06 --:--:-- 0
100 629 100 629 0 0 49 0 0:00:12 0:00:12 --:--:-- 131
100 11664 100 11664 0 0 483 0 0:00:24 0:00:24 --:--:-- 3348
[root@tango-centos01 ~]# chmod a+x /usr/local/bin/scope
2)以容器方式启动Weave Scope
[root@tango-centos01 ~]# scope launch
Unable to find image 'weaveworks/scope:1.13.1' locally
1.13.1: Pulling from weaveworks/scope
c9b1b535fdd9: Pull complete
550073704c23: Pull complete
8738e5bbaf1d: Pull complete
0a8826d26027: Pull complete
387c1aa951b4: Pull complete
e72d45461bb9: Pull complete
75cc44b65e98: Pull complete
11f7584a6ade: Pull complete
a5aa3ebbe1c2: Pull complete
7cdbc028c8d2: Pull complete
Digest: sha256:4342f1c799aba244b975dcf12317eb11858f9879a3699818e2bf4c37887584dc
Status: Downloaded newer image for weaveworks/scope:1.13.1
f00a987cc31265f1daf780446dc124db9e3b094281366ca94bb15895f42c9dd9
Scope probe started
Weave Scope is listening at the following URL(s):
* http://192.168.112.101:4040/
* http://192.168.112.143:4040/
[root@tango-centos01 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f00a987cc312 weaveworks/scope:1.13.1 "/home/weave/entrypo…" 20 seconds ago Up 18 seconds weavescope
[root@tango-centos01 ~]#
3)访问地址http://192.168.112.101:4040/
如果要查看容器的详细信息,比如 weavescope,可以点击该容器的图标。
在容器信息的上面还有一排操作按钮。分别是:
- attach 到容器启动进程,相当于执行docker container attach
- 打开 shell,相当于执行docker container exec
- 重启容器,相当于执行docker container restart
- 暂停容器,相当于执行docker container pause
- 关闭容器,相当于执行docker container stop
除了容器,Weave Scope点击顶部HOSTS菜单项,地图将显示当前host,点击该host图标将显示详细信息。
点击host页面上的shell窗口,相当于进入到了host系统,执行的任何命令都会同步到系统。
4.2 weave scope监控多主机
1)在两台主机上面安装weave scope
[root@tango-centos02 ~]# curl -L git.io/scope -o /usr/local/bin/scope
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:06 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:14 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:15 --:--:-- 0
100 629 100 629 0 0 33 0 0:00:19 0:00:18 0:00:01 183
100 11664 100 11664 0 0 580 0 0:00:20 0:00:20 --:--:-- 22090
[root@tango-centos02 ~]# chmod a+x /usr/local/bin/scope
[root@tango-centos02 ~]#
2)在两台主机上执行如下命令
[root@tango-centos01 ~]# scope launch 192.168.112.101 192.168.112.102
3d0785ec469d324fc96920eab116e90d71d87533bfa2b9ba604730c9e5b22e8f
Scope probe started
Weave Scope is listening at the following URL(s):
* http://192.168.112.101:4040/
* http://192.168.112.143:4040/
[root@tango-centos02 ~]# scope launch 192.168.112.101 192.168.112.102
4cd0eb70897cc8831edd6120f1b4a04469b2dca0a6e0332a2cb2598f04afb342
Scope probe started
Weave Scope is listening at the following URL(s):
* http://192.168.112.102:4040/
这样,无论访问http://192.168.112.101:4040/还是http://192.168.112.102:4040/,都能监控到两个host
3)查看主机
4)查看正在运行的容器
参考资料:
转载请注明原文地址:https://blog.csdn.net/solihawk/article/details/121669187
文章会同步在公众号“牧羊人的方向”更新,感兴趣的可以关注公众号,谢谢!