手把手教你给服务器搭建一套资源监控系统

一、前言

本文主要是介绍如何给一台服务器,搭建一个优雅的资源监控系统
如果对你有帮助,欢迎三连 收藏点赞关注!!!

---- Nick.Peng


二、准备

分别下载以下安装包,下载地址:https://prometheus.io/download/

  • grafana-enterprise-9.3.6.linux-amd64
  • node_exporter-1.5.0.linux-amd64
  • prometheus-2.42.0.linux-amd64

三、安装

安装Prometheus

# 源码安装prometheus
tar -zxvf prometheus-2.42.0.linux-amd64.tar.gz -C /monitor/module/
mv prometheus-2.42.0.linux-amd64/ prometheus-2.42.0
# 后台启动,默认端口9090
nohup ./prometheus --config.file=prometheus.yml --web.listen-address=:9089 > ./prometheus.log 2>&1 &

安装Node_exporter

# 源码安装node_exporter
tar -zxvf node_exporter-1.5.0.linux-amd64.tar.gz -C /monitor/module/
mv node_exporter-1.5.0.linux-amd64/ node_exporter-1.5.0

# 启动node_exporter,下面会介绍系统进程自动启动方式
cd node_exporter-1.5.0 && ./node_exporter 
# 测试node_exporter是否能访问 或者 直接在浏览器中访问以下地址
wget http://localhost:9100/metrics

安装Grafana

# 源码安装grafana
tar -zxvf grafana-enterprise-9.3.6.linux-amd64.tar.gz -C /monitor/module/
# 后台启动Grafana
nohup ./bin/grafana-server web > ./grafana.log 2>&1 &

四、配置

Prometheus 配置

编辑配置文件,修改 job_name 和 targets,如下:
vim /monitor/module/prometheus-2.42.0/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 it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_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"]
      - targets: ["localhost:9089"]

  - job_name: "node exporter"
    static_configs:
      # node服务器地址加端口,端口默认9100
      - targets: ["localhost:9100"]

Node_exporter 配置自启动

sudo vim /usr/lib/systemd/system/node_exporter.service

######## 以下是配置开机自启配置 ########
[Unit]
Description=node_export
Documentation=https://github.com/prometheus/node_exporter
After=network.target

[Service]
Type=simple
User=atguigu
ExecStart=/monitor/module/node_exporter-1.5.0/node_exporter 
Restart=on-failure

[Install]
WantedBy=multi-user.target
######## 配置文件结束 ########

Grafana 配置

vim grafana-9.3.6/conf/defaults.ini

# 修改服务端口,默认是3000
http_port = 9090

#################################### SMTP / Emailing #####################
[smtp]
enabled = true
host = smtp.163.com:465
user = xxxxxx@163.com
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password = SISQXWNSUKZB-NICK
cert_file =
key_file =
skip_verify = true
from_address = 邮箱地址
from_name = Grafana
ehlo_identity =
startTLS_policy =

导入node_exporter Dashbord文件
下载地址:https://grafana.com/grafana/dashboards/

image.png

五、效果

image.png

六、参考文献

12_监控报警_添加相关仪表盘模板_哔哩哔哩_bilibili

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当然可以!以下是手把手你搭建 YOLOv5 的步骤: 1. 准备工作: - 确保你的电脑已经安装了 Python 3.8 或更高版本。 - 安装 PyTorch:可以根据你的操作系统和 CUDA 版本选择合适的安装命令,例如: ```shell pip install torch torchvision torchaudio ``` - 安装其他依赖库: ```shell pip install opencv-python matplotlib numpy ``` 2. 下载 YOLOv5 源代码: - 在终端中运行以下命令来克隆 YOLOv5 仓库: ```shell git clone https://github.com/ultralytics/yolov5.git ``` 3. 安装依赖库: - 进入 yolov5 目录: ```shell cd yolov5 ``` - 安装依赖库: ```shell pip install -r requirements.txt ``` 4. 准备数据集: - 准备好你的训练数据集,并将图像和对应的标签文件放入一个文件夹中。 5. 配置模型和数据: - 编辑 `yolov5/models/yolov5s.yaml` 文件,根据你的需求进行配置,例如设置 `nc` 参数为你的类别数量。 - 编辑 `data.yaml` 文件,设置 `train` 和 `val` 的路径,并配置类别数量和类别名称。 6. 训练模型: - 在终端中运行以下命令来开始训练模型: ```shell python train.py --img 640 --batch 16 --epochs 100 --data data.yaml --cfg models/yolov5s.yaml --weights '' ``` - 这个命令将使用默认参数来训练 YOLOv5 模型,你可以根据需要进行调整。 7. 测试模型: - 在终端中运行以下命令来测试模型效果: ```shell python detect.py --source your_image.jpg --weights runs/train/exp/weights/best.pt --conf 0.4 ``` - 这个命令将使用训练好的模型对指定图像进行目标检测,你可以调整 `--conf` 参数来控制检测结果的置信度阈值。 以上就是搭建 YOLOv5 的基本步骤,希望对你有帮助!如果有任何问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值