公司网站怎样备案,永久免费国外vps无需信用卡,投资公司注册条件及经营范围,邓州网络推广有效的方法目录 1.常用命令监控
docker ps
docker top
docker stats
2.weave scope
1.下载
2.安装
3.访问查询即可
3.Prometheus监控平台
1.部署数据收集器cadvisor
2.部署Prometheus
3.部署可视化平台Gragana
4.进入后台控制台 1.常用命令监控
docker ps
[rootlocalhost ~…目录 1.常用命令监控
docker ps
docker top
docker stats
2.weave scope
1.下载
2.安装
3.访问查询即可
3.Prometheus监控平台
1.部署数据收集器cadvisor
2.部署Prometheus
3.部署可视化平台Gragana
4.进入后台控制台 1.常用命令监控
docker ps
[rootlocalhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
30d9a0e764a3 busybox sh 12 seconds ago Up 11 seconds busybox2
0d44a42e10dc busybox sh 17 seconds ago Up 15 seconds busybox1
字段含义
container id容器的ID
images基于创建的镜像
command当前运行环境使用的进程
created创建的时间
status运行的时间
ports映射的端口
names容器的名称
docker top
查看指定容器内的进程
[rootlocalhost ~]# docker top busybox1
UID PID PPID C STIME TTY TIME CMD
root 2335 2314 0 11:16 pts/0 00:00:00 sh
选项
与在Linux中运行的ps选项相同
a 显示现行终端机下的所有进程包括其他用户的进程。
u 以用户为主的格式来显示进程状况。
x 显示所有进程不以终端机来区分。
-A 显示所有进程。
-e 此参数的效果和指定A参数相同。
-f 显示UID,PPID,C与STIME栏位。
查看详细docker容器进程
[rootlocalhost ~]# docker top busybox1 aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2335 0.0 0.0 1320 252 pts/0 Ss 11:16 0:00 sh
docker stats
动态显示容器的运行进程
查看所有容器的进程信息
[rootlocalhost ~]# docker stats
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
30d9a0e764a3 busybox2 0.00% 56KiB / 3.686GiB 0.00% 648B / 0B 0B / 0B 1
0d44a42e10dc busybox1 0.00% 56KiB / 3.686GiB 0.00% 1.09kB / 0B 1.18MB / 0B 1
查看容器的动态进程
[rootlocalhost ~]# docker stats busybox1
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
0d44a42e10dc busybox1 0.00% 56KiB / 3.686GiB 0.00% 1.09kB / 0B 1.18MB / 0B 1
字段含义
container id容器id
name容器名字
CPU %CPU使用百分比
MEM USAGE/limit容器使用的总内存以及它允许使用的总内存
mem%内存使用百分比
net I/O容器通过其网络接口接收和发送的数据量
block I/O容器从主机上的块设备写入和读取的数据量
pids容器已经创建的进程或线程的数量
选项
-a显示所有容器(默认显示正在运行)
--no-stream禁用流统计只拉取第一个结果
--no-trunc不截断输出 2.weave scope
weave scope 的最大的特点就是会自动生成一张docker容器地图让我们能够直观的理解监控和控制器。
1.下载
wget https://github.com/weaveworks/scope/releases/download/v1.13.2/scope
2.安装
[rootlocalhost ~]# chmod x scope
[rootlocalhost ~]# ./scope launch
Unable to find image weaveworks/scope:1.13.2 locally
1.13.2: Pulling from weaveworks/scope
ba3557a56b15: Pull complete
3ac4c0e9800c: Pull complete
d052e74a4dae: Pull complete
aacb9bf49f73: Pull complete
06841e6f61a9: Pull complete
ee99b95c7732: Pull complete
dd0e726a9a15: Pull complete
05cb5f9d0d32: Pull complete
e956cf3e716a: Pull complete
Digest: sha256:8591bb11d72f784f784ac8414660759d40b7c0d8819011660c1cc94271480a83
Status: Downloaded newer image for weaveworks/scope:1.13.2
458ddccb286a03b96e523e41d149ee102f6007cd55b4be179334675e5e7c311e
Scope probe started
Weave Scope is listening at the following URL(s):* http://192.168.2.5:4040/
3.访问查询即可
http://192.168.2.5:4040/ 3.Prometheus监控平台
1.部署数据收集器cadvisor
[rootlocalhost ~]# docker run -v /:/rootfs:ro -v /var/run/:/var/run/:rw -v /sys:/sys:ro -v /var/lib/docker:/var/lib/docker:ro -p 8080:8080 -d --name cadivsor google/cadvisor
访问http://192.168.2.5:8080/containers/ 2.部署Prometheus
[rootlocalhost ~]# docker run -d -p 9100:9100 \
-v /proc:/host/proc \
-v /sys:/host/sys \
-v /:/rootfs \
--nethost \
prom/node-exporter \
--path.procfs /host/proc \
--path.sysfs /host/sys \
--collector.filesystem.ignored-mount-points ^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/devicemapper|rootfs/var/lib/docker/aufs)($$|/)
Unable to find image prom/node-exporter:latest locally
latest: Pulling from prom/node-exporter
aa2a8d90b84c: Pull complete
b45d31ee2d7f: Pull complete
b5db1e299295: Pull complete
Digest: sha256:f2269e73124dd0f60a7d19a2ce1264d33d08a985aed0ee6b0b89d0be470592cd
Status: Downloaded newer image for prom/node-exporter:latest
WARNING: Published ports are discarded when using host network mode
795214fa2248b18fee6e6600bb567493db4be265b5c79c9445eb96020aab3578
编写Prometheus监控配置文件
[rootlocalhost ~]# vi prometheus.yml
# my global config
global:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:alertmanagers:- static_configs:- targets:# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global evaluation_interval.
rule_files:# - first_rules.yml# - second_rules.yml
# A scrape configuration containing exactly one endpoint to scrape:
# Here its Prometheus itself.
scrape_configs:# The job name is added as a label jobjob_name to any timeseries scraped from this config.- job_name: prometheus
# metrics_path defaults to /metrics# scheme defaults to http.
static_configs:- targets: [localhost:9090,localhost:8080,localhost:9100]
主要配置文件内容 static_configs:- targets: [localhost:9090,localhost:8080,localhost:9100]
注意填写你需要监控的cadvisor的IP地址和端口号
3.部署可视化平台Gragana
[rootlocalhost ~]# docker run -d -i -p 3000:3000 \
-e GF_SERVER_ROOT_URLhttp://grafana.server.name \
-e GF_SECURITY_ADMIN_PASSWORDsecret \
--nethost \
grafana/grafana
4.进入后台控制台
http://192.168.2.5:3000/
默认用户名和密码
admin
密码GF_SECURITY_ADMIN_PASSWORDsecret字段内容
注意如果不指定密码为admin
1.添加Prometheus模块 2.添加docker容器监控模板
docker容器模板193
Linux主机监控模板9276 监控结果