winmetrics

package module
v0.0.0-...-f1dfc71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 2 Imported by: 0

README

WinMetrics


It's annoying to get hardware sensors metrics from Windows as HTTP server, not anymore.

Now you can monitor your physical server sensors as part of Prometheus stack!

Build

You can just do go build cmd/winmetrics/main.go and that's it

Dependencies

  • This program is Windows only.
  • You must run Libre Hardware Monitor, this would exposes new WMI entries as root/LibreHardwareMonitor namespace and Sensor and Hardware classes.

Run

Run the executable and you can get the data through HTTP API at (default) GET localhost:8123/api/v1/metrics in JSON format:

{
    "sensors": [List of sensors],
    "hardwares": [List of hardwares]
}

Or GET localhost:8123/metrics in Prometheus format.

Documentation

Index

Constants

View Source
const (
	Namespace     = `ROOT\LibreHardwareMonitor`
	QuerySensor   = `SELECT * FROM Sensor`
	QueryHardware = `SELECT * FROM Hardware`
)

Variables

View Source
var DefaultWMIQueryNamespace = wmi.QueryNamespace

Functions

This section is empty.

Types

type Combined

type Combined struct {
	Sensors   []Sensor   `json:"sensors,omitempty"`
	Hardwares []Hardware `json:"hardwares,omitempty"`
}

type Hardware

type Hardware struct {
	Name         string `json:"name"`
	HardwareType string `json:"hardware_type"`
	Identifier   string `json:"identifier"`
}

func GetHardwares

func GetHardwares(queryNamespace QueryNamespaceFn) (hardwares []Hardware, err error)

GetHardwares accept QueryNamespaceFn so it would be easier to test

type Logger

type Logger interface {
	Print(args ...interface{})
	Println(args ...interface{})
	Printf(format string, args ...interface{})

	Debug(args ...interface{})
	Debugln(args ...interface{})
	Debugf(format string, args ...interface{})

	Trace(args ...interface{})
	Traceln(args ...interface{})
	Tracef(format string, args ...interface{})

	Info(args ...interface{})
	Infoln(args ...interface{})
	Infof(format string, args ...interface{})

	Warn(args ...interface{})
	Warnln(args ...interface{})
	Warnf(format string, args ...interface{})

	Warning(args ...interface{})
	Warningln(args ...interface{})
	Warningf(format string, args ...interface{})

	Error(args ...interface{})
	Errorln(args ...interface{})
	Errorf(format string, args ...interface{})

	Fatal(args ...interface{})
	Fatalln(args ...interface{})
	Fatalf(format string, args ...interface{})
}

type QueryNamespaceFn

type QueryNamespaceFn func(query string, dst interface{}, namespace string) (err error)

type Sensor

type Sensor struct {
	Name       string  `json:"name"`
	SensorType string  `json:"sensor_type"`
	Identifier string  `json:"identifier"`
	Value      float32 `json:"value"`
	Max        float32 `json:"max"`
	Min        float32 `json:"min"`
}

func GetSensors

func GetSensors(queryNamespace QueryNamespaceFn) (sensors []Sensor, err error)

GetSensors accept QueryNamespaceFn so it would be easier to test

Directories

Path Synopsis
app
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL