在更换了 5900x 以后我需要对我的电脑进行超频微调以适应长时间的压制要求。HWinfo 自带的 1 小时的图形监控并不能满足我的需求,因此我尝试将 HWinfo 的数据记录到 Prometheus 并通过 Grafana 完成绘图。
Contents
准备工作
首先需要 HWinfo,PromDapter,Prometheus,Grafana。
HWinfo 需要开启 Shared Memory 功能,并开启 Sensor-mode。只需要如图勾选并保存配置即可。

然后安装 PromDapter。PromDapter 会监听 10445 端口,需要在 Windows 防火墙中设置一条入站规则,允许 C:\Program Files\PromDapter\PromDapterSvc.exe 的连接请求。
增加 PromDapter 监控规则
PromDapter 已经提供了一些默认规则,我们可以通过修改 C:\ProgramData\PromDapter\Prometheusmapping.yaml 中的规则新增监控项目,例如 PSU,UPS 的功耗。
下面是两个例子:
# PSU - '(?<Entity>PSU) (?<MetricName>Temperature2|Temperature|Fan|Power \(sum\)|Power|Efficiency)' # UPS - '(?<Entity>UPS) (?<MetricName>Load|Charge Level|Estimated Runtime)'
这些规则使用正则表达式,对 Key 进行分组。在 UPS 的信息中 HWinfo 在 Charge Level/Estimated Runtime 中不带有 UPS 前缀字样,则可以右键,修改名称,修改为 UPS Charge Level/UPS Estimated Runtime,以方便正则表达式分组。
修改完成后,重启 PromDapterSvc 服务,并检查 http://localhost:10445/metrics 出现的 metrics。
创建 Prometheus 监控
Prometheus 总是通过 metrics 抓取信息,因此我们只需要将 IP地址:端口 填入 Prometheus 配置文件即可。配置示例如下:
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
# - "first.rules"
# - "second.rules"
scrape_configs:
- job_name: 'AMD-WS'
scheme: http
scrape_interval: 1s
static_configs:
- targets: ['192.168.1.10:10445']
填写后,运行 systemctl restart prometheus 重启服务。
创建 Grafana 面板
PromDapter 带有一个 6.x 版本的 Grafana 模板,但无法直接在 8.x 版本直接使用,因此我们需要直接通过 PromQL 实现对数据的查找。
所有可以查询的 metric 名称都可以在 http://localhost:10445/metrics 中找到,# HELP 之后就是该项数据在 HWinfo 中的名称,我们只需要在 Grafana 面板中通过点击这些名称,设定搜索用的 label 即可轻松过滤到这些信息。
示例:
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__requires": [
{
"type": "panel",
"id": "bargauge",
"name": "Bar gauge",
"version": ""
},
{
"type": "panel",
"id": "gauge",
"name": "Gauge",
"version": ""
},
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "8.2.0"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
},
{
"type": "panel",
"id": "timeseries",
"name": "Time series",
"version": ""
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": null,
"graphTooltip": 0,
"id": null,
"links": [],
"liveNow": false,
"panels": [
{
"collapsed": false,
"datasource": null,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 39,
"panels": [],
"title": "CPU",
"type": "row"
},
{
"cacheTimeout": null,
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"id": 0,
"op": "=",
"text": "N/A",
"type": 1,
"value": "null"
}
],
"max": 100,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "purple",
"value": 50
},
{
"color": "blue",
"value": 90
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 4,
"x": 0,
"y": 1
},
"id": 10,
"links": [],
"options": {
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"last"
],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true,
"text": {}
},
"pluginVersion": "8.2.0",
"targets": [
{
"exemplar": true,
"expr": "hwi_usage{job=\"AMD-WS\", category=\"CPU\"}",
"interval": "",
"legendFormat": "{{instance}}",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "CPU Load",
"type": "gauge"
},
{
"cacheTimeout": null,
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"id": 0,
"op": "=",
"text": "N/A",
"type": 1,
"value": "null"
}
],
"max": 65536,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "blue",
"value": 16000
},
{
"color": "yellow",
"value": 32000
},
{
"color": "red",
"value": 60000
}
]
},
"unit": "decmbytes"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 2,
"x": 4,
"y": 1
},
"id": 23,
"links": [],
"options": {
"displayMode": "basic",
"orientation": "vertical",
"reduceOptions": {
"calcs": [
"last"
],
"fields": "",
"values": false
},
"showUnfilled": true,
"text": {}
},
"pluginVersion": "8.2.0",
"targets": [
{
"exemplar": true,
"expr": "hwi_memory_used_mb{job=\"AMD-WS\", category=\"Physical\"}",
"interval": "",
"legendFormat": "{{instance}}",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Mem Usage",
"type": "bargauge"
},
{
"cacheTimeout": null,
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"from": "",
"id": 1,
"operator": "",
"text": "No",
"to": "",
"type": 1,
"value": "0"
},
{
"from": "1",
"id": 2,
"operator": "",
"text": "Yes",
"to": "10000",
"type": 2,
"value": ""
}
],
"max": 1,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 0.5
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 2,
"x": 6,
"y": 1
},
"id": 34,
"links": [],
"options": {
"displayMode": "basic",
"orientation": "vertical",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showUnfilled": true,
"text": {}
},
"pluginVersion": "8.2.0",
"targets": [
{
"exemplar": true,
"expr": "sum(hwi_cpu_thermal_throttling_yesno{job=\"AMD-WS\"}) by(instance)",
"instant": false,
"interval": "",
"legendFormat": "time_series",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "CPU Throttle",
"type": "bargauge"
},
{
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"decimals": 2,
"mappings": [],
"max": 5,
"min": 0.1,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "blue",
"value": null
},
{
"color": "yellow",
"value": 3.5
},
{
"color": "green",
"value": 4
},
{
"color": "purple",
"value": 4.5
},
{
"color": "red",
"value": 5
}
]
},
"unit": "GHz"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 9,
"x": 8,
"y": 1
},
"id": 6,
"options": {
"displayMode": "lcd",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"last"
],
"fields": "",
"values": false
},
"showUnfilled": true,
"text": {}
},
"pluginVersion": "8.2.0",
"targets": [
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"0\"} / 1000) by(instance)",
"interval": "",
"legendFormat": "core 0",
"refId": "A"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"1\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 1",
"refId": "B"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"2\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 2",
"refId": "C"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"3\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 3",
"refId": "D"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"4\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 4",
"refId": "E"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"5\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 5",
"refId": "F"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"6\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 6",
"refId": "G"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"7\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 7",
"refId": "H"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"8\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 8",
"refId": "I"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"9\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 9",
"refId": "J"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"10\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 10",
"refId": "K"
},
{
"exemplar": true,
"expr": "avg(hwi_core_clock_mhz{job=\"AMD-WS\",coreno=\"11\"} / 1000) by(instance)",
"hide": false,
"interval": "",
"legendFormat": "core 11",
"refId": "L"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Max Core Frequency",
"type": "bargauge"
},
{
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"max": 95,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "yellow",
"value": 75
},
{
"color": "red",
"value": 85
}
]
},
"unit": "celsius"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 8,
"x": 0,
"y": 9
},
"id": 4,
"options": {
"legend": {
"calcs": [
"min",
"max",
"last"
],
"displayMode": "table",
"placement": "right"
},
"tooltip": {
"mode": "single"
}
},
"pluginVersion": "8.2.0",
"targets": [
{
"exemplar": true,
"expr": "hwi_cpu_tctltdie_c{job=\"AMD-WS\"}",
"interval": "",
"legendFormat": "Temperature",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "CPU Temp",
"type": "timeseries"
},
{
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "line"
}
},
"links": [],
"mappings": [],
"max": 180,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "transparent",
"value": null
},
{
"color": "orange",
"value": 140
},
{
"color": "red",
"value": 165
}
]
},
"unit": "watt"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 9,
"x": 8,
"y": 9
},
"id": 2,
"options": {
"legend": {
"calcs": [
"min",
"max",
"last"
],
"displayMode": "table",
"placement": "right"
},
"tooltip": {
"mode": "single"
}
},
"pluginVersion": "8.2.0",
"targets": [
{
"exemplar": true,
"expr": "hwi_cpu_coresoc_power_w{job=\"AMD-WS\"}",
"interval": "",
"legendFormat": "Power",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "CPU Package Power",
"type": "timeseries"
},
{
"collapsed": false,
"datasource": null,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 17
},
"id": 45,
"panels": [],
"title": "PSU",
"type": "row"
},
{
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 16,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "watt"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 7,
"x": 0,
"y": 18
},
"id": 47,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"exemplar": true,
"expr": "hwi_psu_power_sum_w{job=\"AMD-WS\"}",
"interval": "",
"legendFormat": "{{source}}",
"refId": "A"
}
],
"title": "PSU Power",
"type": "timeseries"
},
{
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 8,
"x": 7,
"y": 18
},
"id": 49,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"exemplar": true,
"expr": "hwi_psu_efficiency{job=\"AMD-WS\"}",
"interval": "",
"legendFormat": "{{source}}",
"refId": "A"
}
],
"title": "PSU Efficiency %",
"type": "timeseries"
},
{
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "celsius"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 9,
"x": 15,
"y": 18
},
"id": 51,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"exemplar": true,
"expr": "hwi_psu_temperature_c{job=\"AMD-WS\"}",
"interval": "",
"legendFormat": "{{source}}",
"refId": "A"
}
],
"title": "PSU Temperature °C",
"type": "timeseries"
},
{
"collapsed": false,
"datasource": null,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 27
},
"id": 53,
"panels": [],
"title": "UPS",
"type": "row"
},
{
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "watt"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 7,
"x": 0,
"y": 28
},
"id": 55,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"exemplar": true,
"expr": "hwi_ups_load_w{job=\"AMD-WS\"}",
"interval": "",
"legendFormat": "{{source}}",
"refId": "A"
}
],
"title": "UPS Load W",
"type": "timeseries"
},
{
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"max": 100,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 8,
"x": 7,
"y": 28
},
"id": 57,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"exemplar": true,
"expr": "hwi_ups_charge_level{job=\"AMD-WS\"}",
"interval": "",
"legendFormat": "{{source}}",
"refId": "A"
}
],
"title": "UPS Charge Level %",
"type": "timeseries"
},
{
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "m"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 4,
"x": 15,
"y": 28
},
"id": 59,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto"
},
"pluginVersion": "8.2.0",
"targets": [
{
"exemplar": true,
"expr": "hwi_ups_estimated_runtime_min{job=\"AMD-WS\"}",
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"title": "UPS Estimated Runtime",
"type": "stat"
}
],
"refresh": "5s",
"schemaVersion": 31,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
]
},
"timezone": "",
"title": "HWiNFO",
"uid": "ebfm82rZz",
"version": 17
}