Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins\inputs\system\ps.go:220:26: undefined: host.Warnings #1429

Closed
3 of 5 tasks
powersj opened this issue Mar 13, 2023 · 0 comments · Fixed by #1431
Closed
3 of 5 tasks

plugins\inputs\system\ps.go:220:26: undefined: host.Warnings #1429

powersj opened this issue Mar 13, 2023 · 0 comments · Fixed by #1431

Comments

@powersj
Copy link
Contributor

powersj commented Mar 13, 2023

Describe the bug
On FreeBSD, Darwin, and Windows, builds using host.Warnings now fail. It appears that this was removed in #1347, but then re-added only for Linux in #1379. Telegraf uses these warnings with the call to host.SensorsTemperatures() as it seems to almost always return an error. We need to unwrap the error to see if it contains only a warning:

plugins/inputs/system/ps.go:220:26: undefined: host.Warnings

To Reproduce

package main

import (
    "errors"
    "fmt"
    "os"

    "github.com/shirou/gopsutil/host"
)

func main() {
    temp, err := host.SensorsTemperatures()
    if err != nil {
 	var hostWarnings *host.Warnings
	if !errors.As(err, &hostWarnings) {
	    fmt.Println(err)
	    os.Exit(1)
	}
    }
    fmt.Println(temp)
}

Expected behavior

Sensors print out results, ignoring warnings:

[{"sensorKey":"nvme_composite","temperature":33.85,"sensorHigh":74.85,"sensorCritical":79.85} {"sensorKey":"nvme_composite","temperature":47.85,"sensorHigh":89.85,"sensorCritical":94.85} {"sensorKey":"k10temp_tctl","temperature":46.5,"sensorHigh":0,"sensorCritical":0} {"sensorKey":"k10temp_tccd1","temperature":36.25,"sensorHigh":0,"sensorCritical":0} {"sensorKey":"k10temp_tccd2","temperature":40.5,"sensorHigh":0,"sensorCritical":0}]

Environment (please complete the following information):

  • Windows: [paste the result of ver]
  • Linux: [paste contents of /etc/os-release and the result of uname -a]
  • Mac OS: [paste the result of sw_vers and uname -a
  • FreeBSD: [paste the result of freebsd-version -k -r -u and uname -a]
  • OpenBSD: [paste the result of uname -a]

Additional context

Yes we are cross-compiling, this was reported to us in Telegraf in influxdata/telegraf#12841

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant