Skip to content

Commit

Permalink
fix compile error for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kongfei605 committed Dec 27, 2023
1 parent b7e16af commit 50054f1
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 205 deletions.
99 changes: 0 additions & 99 deletions inputs/ipmi/connection.go

This file was deleted.

3 changes: 3 additions & 0 deletions inputs/ipmi/exporter/collector_bmc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Copyright 2021 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 3 additions & 0 deletions inputs/ipmi/exporter/collector_bmc_watchdog.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Copyright 2021 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 3 additions & 0 deletions inputs/ipmi/exporter/collector_chassis.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Copyright 2021 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 3 additions & 0 deletions inputs/ipmi/exporter/collector_dcmi.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Copyright 2021 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 3 additions & 0 deletions inputs/ipmi/exporter/collector_ipmi.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Copyright 2021 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Copyright 2021 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 3 additions & 0 deletions inputs/ipmi/exporter/collector_sel.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Copyright 2021 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 3 additions & 0 deletions inputs/ipmi/exporter/collector_sm_lan_mode.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Copyright 2021 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
16 changes: 16 additions & 0 deletions inputs/ipmi/exporter/collector_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build windows
// +build windows

package exporter

import (
"github.com/prometheus/client_golang/prometheus"
)

type IPMIConfig struct {
Timeout uint32
}

func Collect(ch chan<- prometheus.Metric, host, binPath string, config IPMIConfig) {
return
}
106 changes: 3 additions & 103 deletions inputs/ipmi/exporter/config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Copyright 2021 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -138,38 +141,6 @@ func checkOverflow(m map[string]interface{}, ctx string) error {
return nil
}

/*
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (s *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
type plain Config
if err := unmarshal((*plain)(s)); err != nil {
return err
}
if err := checkOverflow(s.XXX, "config"); err != nil {
return err
}
return nil
}
*/
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (s *IPMIConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
*s = defaultConfig
type plain IPMIConfig
if err := unmarshal((*plain)(s)); err != nil {
return err
}
if err := checkOverflow(s.XXX, "modules"); err != nil {
return err
}
for _, c := range s.Collectors {
if err := c.IsValid(); err != nil {
return err
}
}
return nil
}

func (c IPMIConfig) GetCollectors() []Collector {
result := []Collector{}
for _, co := range c.Collectors {
Expand Down Expand Up @@ -212,74 +183,3 @@ func (c IPMIConfig) GetFreeipmiConfig() string {
}
return b.String()
}

/*
// ReloadConfig reloads the config in a concurrency-safe way. If the configFile
// is unreadable or unparsable, an error is returned and the old config is kept.
func (sc *SafeConfig) ReloadConfig(configFile string) error {
var c = &Config{}
var config []byte
var err error
if configFile != "" {
config, err = os.ReadFile(configFile)
if err != nil {
log.Println("msg", "Error reading config file", "error", err)
return err
}
} else {
config = []byte("# use empty file as default")
}
if err = yaml.Unmarshal(config, c); err != nil {
return err
}
sc.Lock()
sc.C = c
sc.Unlock()
if configFile != "" {
log.Println("msg", "Loaded config file", "path", configFile)
}
return nil
}
// HasModule returns true if a given module is configured. It is concurrency-safe.
func (sc *SafeConfig) HasModule(module string) bool {
sc.Lock()
defer sc.Unlock()
_, ok := sc.C.Modules[module]
return ok
}
// ConfigForTarget returns the config for a given target/module, or the
// default. It is concurrency-safe.
func (sc *SafeConfig) ConfigForTarget(target, module string) IPMIConfig {
sc.Lock()
defer sc.Unlock()
var config IPMIConfig
var ok = false
if module != "default" {
config, ok = sc.C.Modules[module]
if !ok {
log.Println("msg", "Requested module not found, using default", "module", module, "target", targetName(target))
}
}
// If nothing found, fall back to defaults
if !ok {
config, ok = sc.C.Modules["default"]
if !ok {
// This is probably fine for running locally, so not making this a warning
log.Println("msg", "Needed default config for, but none configured, using FreeIPMI defaults", "target", targetName(target))
config = defaultConfig
}
}
return config
}
*/
3 changes: 3 additions & 0 deletions inputs/ipmi/exporter/freeipmi/freeipmi.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Copyright 2021 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
8 changes: 5 additions & 3 deletions inputs/ipmi/instances.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package ipmi

import (
"log"

"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"

"flashcat.cloud/categraf/config"
"flashcat.cloud/categraf/inputs/ipmi/exporter"
util "flashcat.cloud/categraf/pkg/metrics"
"flashcat.cloud/categraf/types"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
"log"
)

// Instance stores the configuration values for the ipmi_sensor input plugin
Expand Down

0 comments on commit 50054f1

Please sign in to comment.