diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index e0871f9..646e956 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -1,3 +1,17 @@ +# Copyright 2022 Jeremy Edwards +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: diff --git a/README.md b/README.md index 45c9419..befa4f0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,68 @@ # coretemp-exporter -Core Temp Exporter for Prometheus + +[![CI](https://github.com/jeremyje/coretemp-exporter/actions/workflows/ci.yaml/badge.svg)](https://github.com/jeremyje/coretemp-exporter/actions/workflows/ci.yaml) + +A Prometheus exporter that emits CPU health information such as core temperatures. There are also some example dashboards to visualize your computer's sensor data. + +## Building + +To build coretemp-exporter you need [Go](https://go.dev/dl/) and Make installed. You can use Linux or Windows hosts to build. + +```bash +# (optional) Delete all build artifacts. +make clean + +# Build all binaries. +make all -j$(nproc) + +# Binaries are created in build/$GOOS-$GOARCH/ directory. +``` + +## Running + +You can run `coretemp-exporter` on Windows or Linux. By default it'll serve its metrics at [`:8081`](http://localhost:8081). + +### Linux + +```bash +# Install lm-sensors +sudo apt-get install lm-sensors + +# Test that lm-sensors is working. +sensors + +# If it's not working try. +sudo sensors-detect + +# Run coretemp-exporter. +./build/linux_amd64/coretemp-exporter +``` + +### Windows + +1. Install and run [ALCPU CoreTemp](https://www.alcpu.com/CoreTemp/). It is important that this application is running otherwise you will not get any data. + +```powershell +# Windows +.\build\windows_amd64\coretemp-exporter.exe +``` + +## Dashboards + +You'll need [Docker](https://docs.docker.com/get-docker/) and [docker-compose](https://github.com/docker/compose/releases) installed. Windows users should run Docker in Linux mode. + +```bash +# Go to the docker-compose directory. +cd install/compose +# Launch Prometheus and Grafana. +docker-compose up -d +``` + +Once both services are you you can view the graphs via: [`:3000/dashboards`](http://localhost:3000/dashboards). To login use the following credentials: + +* Username: `root` +* Password: `admin` + +Once you've logged in you can visit the `CPU` page and you should see something like: + +![Grafana Charts](docs/example-graphs.png "CPU Health Metrics in Grafana") diff --git a/cmd/converter/converter.go b/cmd/converter/converter.go index ce95c0e..306b43c 100644 --- a/cmd/converter/converter.go +++ b/cmd/converter/converter.go @@ -1,3 +1,17 @@ +// Copyright 2022 Jeremy Edwards +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package main import ( diff --git a/docs/example-graphs.png b/docs/example-graphs.png new file mode 100644 index 0000000..88b26d8 Binary files /dev/null and b/docs/example-graphs.png differ diff --git a/install/compose/grafana/dashboards/cpu.json b/install/compose/grafana/dashboards/cpu.json index bd104d0..27ff120 100644 --- a/install/compose/grafana/dashboards/cpu.json +++ b/install/compose/grafana/dashboards/cpu.json @@ -97,7 +97,7 @@ "overrides": [] }, "gridPos": { - "h": 16, + "h": 29, "w": 12, "x": 0, "y": 0 @@ -268,8 +268,8 @@ }, "gridPos": { "h": 13, - "w": 12, - "x": 0, + "w": 6, + "x": 12, "y": 16 }, "id": 6, @@ -293,14 +293,74 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "builder", - "expr": "cpu_speed", - "legendFormat": "{{model}}", + "expr": "cpu_frequency", + "legendFormat": "{{name}}", "range": true, "refId": "A" } ], "title": "CPU Speed", "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "rothz" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 6, + "x": 18, + "y": 16 + }, + "id": 8, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "9.2.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "editorMode": "builder", + "expr": "cpu_fsb_frequency", + "legendFormat": "Front Side Bus of {{name}}", + "range": true, + "refId": "A" + } + ], + "title": "Front Side Bus Frequency", + "type": "gauge" } ], "refresh": "5s", @@ -318,6 +378,6 @@ "timezone": "", "title": "CPU", "uid": "RwtPEDHVz", - "version": 1, + "version": 2, "weekStart": "" } \ No newline at end of file