Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
6a28053325 | |||
19a3e7a2eb | |||
6f1a6b50dc | |||
7fabd92d2d |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,4 +1,3 @@
|
|||||||
obj
|
obj
|
||||||
.vs/LibreHardwareMonitorExporter
|
.vs
|
||||||
bin/Debug/net8.0
|
bin
|
||||||
bin/Release/net8.0
|
|
||||||
|
@@ -38,7 +38,11 @@ while (true) {
|
|||||||
|
|
||||||
var body = new StringBuilder();
|
var body = new StringBuilder();
|
||||||
AppendMetrics(body, computer);
|
AppendMetrics(body, computer);
|
||||||
var bytes = Encoding.UTF8.GetBytes(body.ToString());
|
var text = body.ToString();
|
||||||
|
// Normalize all line endings to '\n' for Prometheus compatibility
|
||||||
|
text = text.Replace("\r\n", "\n").Replace("\r", "\n");
|
||||||
|
if (!text.EndsWith("\n")) text += "\n";
|
||||||
|
var bytes = Encoding.UTF8.GetBytes(text);
|
||||||
context.Response.StatusCode = 200;
|
context.Response.StatusCode = 200;
|
||||||
context.Response.ContentType = "text/plain; version=0.0.4";
|
context.Response.ContentType = "text/plain; version=0.0.4";
|
||||||
context.Response.ContentEncoding = Encoding.UTF8;
|
context.Response.ContentEncoding = Encoding.UTF8;
|
||||||
|
34
README.md
Normal file
34
README.md
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
## LibreHardwareMonitor Exporter
|
||||||
|
|
||||||
|
Minimal Prometheus exporter using `LibreHardwareMonitorLib` to expose basic hardware metrics (CPU, GPU, memory, motherboard, network, storage).
|
||||||
|
|
||||||
|
### Run
|
||||||
|
|
||||||
|
- Build and run the console app.
|
||||||
|
- Endpoint: `http://localhost:9646/metrics` (set `PORT` env var to change port)
|
||||||
|
- Some sensors may require administrator privileges.
|
||||||
|
|
||||||
|
### Prometheus scrape config
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: lhm_exporter
|
||||||
|
static_configs:
|
||||||
|
- targets: ['localhost:9646']
|
||||||
|
```
|
||||||
|
|
||||||
|
### Metrics
|
||||||
|
|
||||||
|
Exports gauges like:
|
||||||
|
- `lhm_temperature_celsius`
|
||||||
|
- `lhm_load_percent`
|
||||||
|
- `lhm_clock_mhz`
|
||||||
|
- `lhm_power_watts`
|
||||||
|
- `lhm_fan_rpm`
|
||||||
|
- `lhm_voltage_volts`
|
||||||
|
|
||||||
|
Each metric includes `hardware` and `sensor` labels.
|
||||||
|
|
||||||
|
### Upstream library
|
||||||
|
|
||||||
|
Powered by LibreHardwareMonitor: [GitHub repository](https://github.com/LibreHardwareMonitor/LibreHardwareMonitor)
|
11
release.sh
11
release.sh
@@ -20,7 +20,7 @@ TOKEN="$GITEA_API_KEY"
|
|||||||
GITEA="https://git.site.quack-lab.dev"
|
GITEA="https://git.site.quack-lab.dev"
|
||||||
REPO="dave/libre-hardware-monitor-exporter"
|
REPO="dave/libre-hardware-monitor-exporter"
|
||||||
ZIP="libre-hardware-monitor-exporter-${TAG}.zip"
|
ZIP="libre-hardware-monitor-exporter-${TAG}.zip"
|
||||||
APK="libre-hardware-monitor-exporter-${TAG}.apk"
|
|
||||||
# Create a release
|
# Create a release
|
||||||
RELEASE_RESPONSE=$(curl -s -X POST \
|
RELEASE_RESPONSE=$(curl -s -X POST \
|
||||||
-H "Authorization: token $TOKEN" \
|
-H "Authorization: token $TOKEN" \
|
||||||
@@ -40,17 +40,10 @@ RELEASE_ID=$(echo $RELEASE_RESPONSE | awk -F'"id":' '{print $2+0; exit}')
|
|||||||
echo "Release ID: $RELEASE_ID"
|
echo "Release ID: $RELEASE_ID"
|
||||||
|
|
||||||
echo "Uploading the things..."
|
echo "Uploading the things..."
|
||||||
WINRELEASE="./build/windows/x64/runner/Release/"
|
WINRELEASE="bin/Release/net8.0"
|
||||||
7z a $WINRELEASE/$ZIP $WINRELEASE/*
|
7z a $WINRELEASE/$ZIP $WINRELEASE/*
|
||||||
curl -X POST \
|
curl -X POST \
|
||||||
-H "Authorization: token $TOKEN" \
|
-H "Authorization: token $TOKEN" \
|
||||||
-F "attachment=@$WINRELEASE/$ZIP" \
|
-F "attachment=@$WINRELEASE/$ZIP" \
|
||||||
"$GITEA/api/v1/repos/$REPO/releases/${RELEASE_ID}/assets?name=$ZIP"
|
"$GITEA/api/v1/repos/$REPO/releases/${RELEASE_ID}/assets?name=$ZIP"
|
||||||
rm $WINRELEASE/$ZIP
|
rm $WINRELEASE/$ZIP
|
||||||
|
|
||||||
ANDROIDRELEASE="./build/app/outputs/flutter-apk/"
|
|
||||||
mv $ANDROIDRELEASE/app-release.apk $ANDROIDRELEASE/$APK
|
|
||||||
curl -X POST \
|
|
||||||
-H "Authorization: token $TOKEN" \
|
|
||||||
-F "attachment=@$ANDROIDRELEASE/$APK" \
|
|
||||||
"$GITEA/api/v1/repos/$REPO/releases/${RELEASE_ID}/assets?name=$APK"
|
|
Reference in New Issue
Block a user