系统监控
方式一:python用于性能测试的psutil包,有go语言版本gopsutil,采用gopsutil做系统监控信息的采集,写入influxDB,使用grafana展示;
方式二:使用prometheus监控;采集性能指标数据并保存,使用grafana展示.用prometheus采取主动pull拉取指标信息的方式,而非轮循访问,有利用系统性能的提高.
prometheus架构概述:


prometheus下载:
prometheus已经封装好了学多功能的API,下载相应功能服务的API即可快速搭建监控系统
Prometheus configuration在prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
# - "first.rules"
# - "second.rules"
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
运行prometheus:
./prometheus --config.file=prometheus.yml
也可以使用docker启动prometheus:
docker run -d -p 9090:9090 -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -v /etc/localtime:/etc/localtime:ro prom/prometheus
参考:
docker:grafana+prometheus+node_exporter
grafana下载
使用Alpine base镜像的轻量级Docker容器。
docker run -d --name=grafana -p 3000:3000 grafana/grafana-enterprise
对于那些喜欢Ubuntu基础镜像的人来说,Docker容器镜像是另一种选择。
docker run -d --name=grafana -p 3000:3000 grafana/grafana-enterprise:9.0.3-ubuntu
本文介绍了两种系统监控的方法:一是通过Python的psutil包和其Go语言版本gopsutil采集数据,然后存入InfluxDB,并用Grafana展示;二是利用Prometheus进行性能指标监控,其主动pull机制提高了系统效率,同样配合Grafana展示。文中还详细阐述了Prometheus的配置和启动步骤,并提供了Docker启动Prometheus和Grafana的命令。

1065

被折叠的 条评论
为什么被折叠?



