fix: smart fan unit improvements (#31)

* fix: load config from /etc/computeblade-agent

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: fan target percent reporting

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: fancontroller default config & update interval

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* chore: update Readme

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

---------

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>
This commit is contained in:
Matthias Riegler
2023-11-25 11:10:12 +01:00
committed by GitHub
parent 99920370fb
commit a8d470d4f9
8 changed files with 36 additions and 47 deletions

View File

@@ -41,8 +41,8 @@ fan_controller:
# For now, this is only supporting a two-step configuration.
steps:
- temperature: 45
speed: 40
percent: 40
- temperature: 55
speed: 80
percent: 80
# Critical temperature threshold
critical_temperature_threshold: 60

View File

@@ -1,7 +1,6 @@
package main
import (
"bytes"
"context"
"fmt"
"net"
@@ -14,8 +13,6 @@ import (
"syscall"
"time"
_ "embed"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/spf13/viper"
bladeapiv1alpha1 "github.com/xvzf/computeblade-agent/api/bladeapi/v1alpha1"
@@ -25,22 +22,22 @@ import (
"google.golang.org/grpc"
)
// embed default configuration
//go:embed default-config.yaml
var defaultConfig []byte
func main() {
var wg sync.WaitGroup
// Setup configuration
viper.SetConfigType("yaml")
// auto-bind environment variables
viper.SetEnvPrefix("BLADE")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.AddConfigPath("/etc/computeblade-agent")
// Load potential file configs
if err := viper.ReadConfig(bytes.NewBuffer(defaultConfig)); err != nil {
if err := viper.ReadInConfig(); err != nil {
panic(err)
}