【Docker项目】之–Glances系统资源监控程序支持API调用
#手册 #教程 #工具 #Docker #Docker-compose #Linux #Ubuntu #系统 #安全防护
Glances是一个由python开发的跨平台系统资源监控程序,支持web查看、系统数据API调用等功能。
官网地址:https://nicolargo.github.io/glances
Github地址:https://github.com/nicolargo/glances
文档地址:https://glances.readthedocs.io/en/latest
Docker Hub:https://hub.docker.com/r/nicolargo/glances
1. 安装准备
系统:ubuntu 20.4
工具:docker和docker-compose
2. 搭建
Docer控制台运行效果。

下面通过docker-compose搭建,实现web和API调用。
2.1. 创建数据存放位置
2.2. 编辑docker-compose.yml
2.3. 新建docker网络
已经创建的略过。
2.4. 拉去镜像开始安装
3. 使用及展示
打开浏览器访问:http://ip:61208

4. 设置用户密码访问
删除已创建的glances容器。
4.1. 创建密码存放位置
4.2. 编辑docker-compose.yml
4.3. 获取密码文件
4.4. 拉去镜像开始安装
4.5. 登录效果


5. API调用
详细的调用方式查看文档:API (Restfull/JSON) documentation — Glances 3.3.0.1 documentation
root@ubuntu:~
[{"time_since_update": 2.9525327682495117, "disk_name": "sr0", "read_count": 0, "write_count": 0, "read_bytes": 0, "write_bytes": 0, "key": "disk_name"}, {"time_since_update": 2.9525327682495117, "disk_name": "sda", "read_count": 0, "write_count": 0, "read_bytes": 0, "write_bytes": 0, "key": "disk_name"}, {"time_since_update": 2.9525327682495117, "disk_name": "sda1", "read_count": 0, "write_count": 0, "read_bytes": 0, "write_bytes": 0, "key": "disk_name"}, {"time_since_update": 2.9525327682495117, "disk_name": "sda2", "read_count": 0, "write_count": 0, "read_bytes": 0, "write_bytes": 0, "key": "disk_name"}, {"time_since_update": 2.9525327682495117, "disk_name": "sda3", "read_count": 0, "write_count": 0, "read_bytes": 0, "write_bytes": 0, "key": "disk_name"}, {"time_since_update": 2.9525327682495117, "disk_name": "dm-0", "read_count": 0, "write_count": 0, "read_bytes": 0, "write_bytes": 0, "key": "disk_name"}]
root@ubuntu:~


6. 关闭web访问
如果仅需要API调用,通过修改docker-compose.yml
关闭web访问。
评论区